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

Function test_save_2d_vector

python/test/unit/io/test_vtk.py:111–126  ·  view source on GitHub ↗
(tempdir, cell_type)

Source from the content-addressed store, hash-verified

109
110@pytest.mark.parametrize("cell_type", cell_types_2D)
111def test_save_2d_vector(tempdir, cell_type):
112 mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, cell_type=cell_type)
113 gdim = mesh.geometry.dim
114 u = Function(functionspace(mesh, ("Lagrange", 1, (gdim,))))
115
116 def f(x):
117 vals = np.zeros((2, x.shape[1]))
118 vals[0] = x[0]
119 vals[1] = 2 * x[0] * x[1]
120 return vals
121
122 u.interpolate(f)
123 filename = Path(tempdir, "u.pvd")
124 with VTKFile(MPI.COMM_WORLD, filename, "w") as vtk:
125 vtk.write_function(u, 0.0)
126 vtk.write_function(u, 1.0)
127
128
129@pytest.mark.skip_in_parallel

Callers

nothing calls this directly

Calls 6

interpolateMethod · 0.95
create_unit_squareFunction · 0.90
FunctionClass · 0.90
functionspaceFunction · 0.90
VTKFileClass · 0.90
write_functionMethod · 0.45

Tested by

no test coverage detected