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
|
#!/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")
|