15 description="""
16 Runs a OpenFoam Utility and analyzes the output. Needs a regular
17 expression to look for. The next 3 arguments are the usual OpenFoam
18 argumens (<solver> <directory> <case>) and passes them on (plus
19 additional arguments). Output is sent to stdout and a logfile inside
20 the case directory (PyFoamUtility.logfile). The Directory
21 PyFoamUtility.analyzed contains a file test with the information of
22 the regexp (the pattern groups).
23 """
24
25 PyFoamApplication.__init__(self,description=description)
26
28 self.parser.add_option("-r","--regexp",type="string",dest="regexp",help="The regular expression to look for")
29 self.parser.add_option("-n","--name",type="string",dest="name",default="test",help="The name for the resulting file")
30 self.parser.add_option("--echo",action="store_true",dest="echo",default=False,help="Echo the result file after the run")
31 self.parser.add_option("--silent",action="store_true",dest="silent",default=False,help="Don't print the output of the utility to the console")
32
34 if self.opts.regexp==None:
35 self.parser.error("Regular expression needed")
36
37 run=UtilityRunner(argv=self.parser.getArgs(),silent=self.opts.silent,server=True)
38
39 run.add(self.opts.name,self.opts.regexp)
40
41 run.start()
42
43 fn=path.join(run.getDirname(),self.opts.name)
44
45 data=run.analyzer.getData(self.opts.name)
46
47 if data==None:
48 print sys.argv[0]+": No data found"
49 else:
50 if self.opts.echo:
51 fh=open(fn)
52 print fh.read()
53 fh.close()
54 else:
55 print sys.argv[0]+": Output written to file "+fn