MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / test_save_vtk_cell_point

Function test_save_vtk_cell_point

python/test/unit/io/test_vtk.py:205–222  ·  view source on GitHub ↗

Test writing cell-wise and point-wise data.

(tempdir)

Source from the content-addressed store, hash-verified

203
204
205def test_save_vtk_cell_point(tempdir):
206 """Test writing cell-wise and point-wise data."""
207 mesh = create_unit_cube(MPI.COMM_WORLD, 3, 3, 3)
208 P2 = element("Lagrange", mesh.basix_cell(), 1, shape=(3,), dtype=default_real_type)
209 P1 = element("Discontinuous Lagrange", mesh.basix_cell(), 0, dtype=default_real_type)
210
211 V2, V1 = functionspace(mesh, P2), functionspace(mesh, P1)
212 U2, U1 = Function(V2), Function(V1)
213 U2.interpolate(lambda x: np.vstack((x[0], 0.2 * x[1], np.zeros_like(x[0]))))
214 U1.interpolate(lambda x: 0.5 * x[0])
215 U2.name = "A"
216 U1.name = "B"
217
218 filename = Path(tempdir, "u.pvd")
219 with VTKFile(mesh.comm, filename, "w") as vtk:
220 vtk.write_function([U2, U1], 0.0)
221 with VTKFile(mesh.comm, filename, "w") as vtk:
222 vtk.write_function((U1, U2), 0.0)
223
224
225def test_save_1d_tensor(tempdir):

Callers

nothing calls this directly

Calls 7

create_unit_cubeFunction · 0.90
functionspaceFunction · 0.90
FunctionClass · 0.90
VTKFileClass · 0.90
basix_cellMethod · 0.80
interpolateMethod · 0.45
write_functionMethod · 0.45

Tested by

no test coverage detected