-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdolfin_convert.py
More file actions
32 lines (24 loc) · 993 Bytes
/
dolfin_convert.py
File metadata and controls
32 lines (24 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import dolfin as df
import argparse
def main():
parser = argparse.ArgumentParser(description="Trace particles")
parser.add_argument("mesh_file", type=str,
help="Path to mesh file")
parser.add_argument("u_file", type=str,
help="Path to velocity field file")
parser.add_argument("out_file", type=str,
help="Path to .xdmf file to save to")
args = parser.parse_args()
mesh = df.Mesh()
with df.HDF5File(mesh.mpi_comm(), args.mesh_file, "r") as h5f_mesh:
h5f_mesh.read(mesh, "/mesh", False)
V = df.VectorFunctionSpace(mesh, "CG", 1)
u = df.Function(V)
with df.HDF5File(mesh.mpi_comm(), args.u_file, "r") as h5f_u:
h5f_u.read(u, "/velocity")
xdmff = df.XDMFFile(mesh.mpi_comm(), args.out_file)
xdmff.parameters["rewrite_function_mesh"] = False
xdmff.parameters["flush_output"] = True
xdmff.write(u, float(0.))
if __name__ == "__main__":
main()