diff options
Diffstat (limited to 'pyfrs2vtu')
-rwxr-xr-x | pyfrs2vtu | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pyfrs2vtu b/pyfrs2vtu new file mode 100755 index 0000000..a0e6042 --- /dev/null +++ b/pyfrs2vtu @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import argparse +import os +from sys import stdout +from subprocess import call + +def meshFile(param): + base, ext = os.path.splitext(param) + if ext.lower() != '.pyfrm': + raise argparse.ArgumentTypeError('Mesh file must have a .pyfrm extension') + return param + +parser = argparse.ArgumentParser(description="convert pyfrs files to vtu format") +parser.add_argument("-d", help="level of sub-division", type=int) +parser.add_argument("mesh", help="mesh file (.pyfrm)", type=meshFile) +parser.add_argument("solution", help="solution file(s) (.pyfrs)", nargs="+") +args = parser.parse_args() + +if args.d: + for fn in args.solution: + call(["pyfr", "export", args.mesh, fn, os.path.splitext(fn)[0] + ".vtu", "-d", str(args.d)]) + stdout.write(".") + stdout.flush() +else: + for fn in args.solution: + call(["pyfr", "export", args.mesh, fn, os.path.splitext(fn)[0] + ".vtu"]) + stdout.write(".") + stdout.flush() + +stdout.write("\n") |