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

Function test_save_1d_vector

python/test/unit/io/test_vtk.py:93–107  ·  view source on GitHub ↗
(tempdir)

Source from the content-addressed store, hash-verified

91
92
93def test_save_1d_vector(tempdir):
94 mesh = create_unit_interval(MPI.COMM_WORLD, 32)
95
96 def f(x):
97 vals = np.zeros((2, x.shape[1]))
98 vals[0] = x[0]
99 vals[1] = 2 * x[0] * x[0]
100 return vals
101
102 e = element("Lagrange", mesh.basix_cell(), 2, shape=(2,), dtype=default_real_type)
103 u = Function(functionspace(mesh, e))
104 u.interpolate(f)
105 filename = Path(tempdir, "u.pvd")
106 with VTKFile(MPI.COMM_WORLD, filename, "w") as vtk:
107 vtk.write_function(u, 0.0)
108
109
110@pytest.mark.parametrize("cell_type", cell_types_2D)

Callers

nothing calls this directly

Calls 7

interpolateMethod · 0.95
create_unit_intervalFunction · 0.90
FunctionClass · 0.90
functionspaceFunction · 0.90
VTKFileClass · 0.90
basix_cellMethod · 0.80
write_functionMethod · 0.45

Tested by

no test coverage detected