diff options
author | Paul Garlick <pgarlick@tourbillion-technology.com> | 2016-03-07 15:07:18 +0000 |
---|---|---|
committer | Paul Garlick <pgarlick@tourbillion-technology.com> | 2016-03-07 15:07:18 +0000 |
commit | 730cc34523c9ff93eba95a62d7d3c6fa0bb811f8 (patch) | |
tree | c72f04e0b11afdea325bb9edc6ed0109b5c0d3a4 /pyfrs2vtu | |
download | pyfrUtils-730cc34523c9ff93eba95a62d7d3c6fa0bb811f8.tar.gz |
creation of mesh and solution file conversion scripts
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") |