f.write instead of print
@@ -291,7 +291,7 @@ def write_buffer(f, mesh, float_fmt):
for block in mesh.cells:
cells_per_dim[_topological_dimension[block.type]] += len(block)
- print(
+ f.write(
f"""# Generated by meshio {__version__}
mesh3d
@@ -302,36 +302,34 @@ geomtype
0
""".format(
__version__
- ),
- file=f,
)
- print("\n# surfnr bcnr domin domout np p1 p2 p3", file=f)
- print("surfaceelements", file=f)
- print(cells_per_dim[2], file=f)
+ )
+ f.write("\n# surfnr bcnr domin domout np p1 p2 p3")
+ f.write("surfaceelements")
+ f.write(f"{cells_per_dim[2]}\n")
for block, index in zip(mesh.cells, cells_index):
if _topological_dimension[block.type] == 2:
_write_cells(f, block, index)
- print("\n# matnr np p1 p2 p3 p4", file=f)
- print("volumeelements", file=f)
- print(cells_per_dim[3], file=f)
+ f.write("\n# matnr np p1 p2 p3 p4")
+ f.write("volumeelements")
+ f.write(f"{cells_per_dim[3]}\n")
for block, index in zip(mesh.cells, cells_index):
if _topological_dimension[block.type] == 3:
_write_cells(f, block, index)
- print(
+ f.write(
"\n# surfid 0 p1 p2 trignum1 trignum2 domin/surfnr1 domout/surfnr2 ednr1 dist1 ednr2 dist2",
- file=f,
)
- print("edgesegmentsgi2", file=f)
- print(cells_per_dim[1], file=f)
+ f.write("edgesegmentsgi2\n")
+ f.write(f"{cells_per_dim[1]}\n")
for block, index in zip(mesh.cells, cells_index):
if _topological_dimension[block.type] == 1:
_write_cells(f, block, index)
- print("\n# X Y Z", file=f)
- print("points", file=f)
- print(len(mesh.points), file=f)
+ f.write("\n# X Y Z\n")
+ f.write("points\n")
+ f.write(f"{len(mesh.points)}\n")
points = mesh.points
if dimension == 2:
@@ -341,14 +339,14 @@ geomtype
p = points
np.savetxt(f, p, "%" + float_fmt)
- print("\n# pnum index", file=f)
- print("pointelements", file=f)
- print(cells_per_dim[0], file=f)
+ f.write("\n# pnum index")
+ f.write("pointelements")
+ f.write(str(cells_per_dim[0]))
for block, index in zip(mesh.cells, cells_index):
if _topological_dimension[block.type] == 0:
_write_cells(f, block, index)
- print("endmesh", file=f)
+ f.write("endmesh")
register("netgen", [".vol", ".vol.gz"], read, {"netgen": write})
