Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def writer(*args, **kwargs):
return meshio.vtk.write(*args, binary=binary, **kwargs)
"VTK (ASCII)": (lambda f, m: meshio.vtk.write(f, m, binary=False), ["out.vtk"]),
"Gmsh 4.1 (binary)": (
lambda f, m: meshio.vtk.write(f, m, binary=True),
meshio.vtk.read,
"VTK (binary)": (lambda f, m: meshio.vtk.write(f, m, binary=True), ["out.vtk"]),
"VTK (ASCII)": (lambda f, m: meshio.vtk.write(f, m, binary=False), ["out.vtk"]),
elif fmt == "h5m":
h5m.write(
args.infile, mesh, compression="gzip", compression_opts=9 if args.max else 4
)
elif fmt == "mdpa":
mdpa.write(args.infile, mesh, binary=True)
elif fmt == "med":
med.write(
args.infile, mesh, compression="gzip", compression_opts=9 if args.max else 4
)
elif fmt == "ply":
ply.write(args.infile, mesh, binary=True)
elif fmt == "stl":
stl.write(args.infile, mesh, binary=True)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=True)
elif fmt == "vtu":
vtu.write(
args.infile, mesh, binary=True, compression="lzma" if args.max else "zlib"
)
elif fmt == "xdmf":
xdmf.write(
args.infile,
mesh,
data_format="HDF",
compression="gzip",
compression_opts=9 if args.max else 4,
)
else:
print("Don't know how to compress {}.".format(args.infile))
exit(1)
# write it out
if fmt == "ansys":
ansys.write(args.infile, mesh, binary=False)
elif fmt == "flac3d":
flac3d.write(args.infile, mesh, binary=False)
elif fmt == "gmsh":
gmsh.write(args.infile, mesh, binary=False)
elif fmt == "mdpa":
mdpa.write(args.infile, mesh, binary=False)
elif fmt == "ply":
ply.write(args.infile, mesh, binary=False)
elif fmt == "stl":
stl.write(args.infile, mesh, binary=False)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=False)
elif fmt == "vtu":
vtu.write(args.infile, mesh, binary=False)
elif fmt == "xdmf":
xdmf.write(args.infile, mesh, data_format="XML")
else:
print("Don't know how to convert {} to ASCII format.".format(args.infile))
exit(1)
size = os.stat(args.infile).st_size
print("File size after: {:.2f} MB".format(size / 1024 ** 2))
# write it out
if fmt == "ansys":
ansys.write(args.infile, mesh, binary=True)
elif fmt == "flac3d":
flac3d.write(args.infile, mesh, binary=True)
elif fmt == "gmsh":
gmsh.write(args.infile, mesh, binary=True)
elif fmt == "mdpa":
mdpa.write(args.infile, mesh, binary=True)
elif fmt == "ply":
ply.write(args.infile, mesh, binary=True)
elif fmt == "stl":
stl.write(args.infile, mesh, binary=True)
elif fmt == "vtk":
vtk.write(args.infile, mesh, binary=True)
elif fmt == "vtu":
vtu.write(args.infile, mesh, binary=True)
elif fmt == "xdmf":
xdmf.write(args.infile, mesh, data_format="HDF")
else:
print("Don't know how to convert {} to binary format.".format(args.infile))
exit(1)
size = os.stat(args.infile).st_size
print("File size after: {:.2f} MB".format(size / 1024 ** 2))