Package PyFoam :: Package Applications :: Module ModifyGGIBoundary
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.ModifyGGIBoundary

  1  """ 
  2  Application-class that implements pyFoamModifyGGIBoundary.py 
  3   
  4  Modification of GGI and cyclicGGI interface parameters in 
  5  constant/polymesh/boundary file. 
  6   
  7  Author: 
  8    Martin Beaudoin, Hydro-Quebec, 2009.  All rights reserved 
  9   
 10  """ 
 11   
 12  from PyFoamApplication import PyFoamApplication 
 13  from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile 
 14  from os import path 
 15  import sys 
 16  import re 
 17   
18 -class ModifyGGIBoundary(PyFoamApplication):
19 - def __init__(self,args=None):
20 description="""\ 21 Modify GGI boundary condition parameters 22 """ 23 PyFoamApplication.__init__(self, 24 args=args, 25 description=description, 26 usage="%prog <caseDirectory> ggiPatchName", 27 interspersed=True, 28 changeVersion=False, 29 nr=2)
30
31 - def addOptions(self):
32 self.parser.add_option("--shadowName", 33 action="store", 34 dest="shadowName", 35 default=None, 36 help='Name of the shadowPatch') 37 self.parser.add_option("--patchZoneName", 38 action="store", 39 dest="patchZoneName", 40 default=None, 41 help='Name of the zone for the GGI patch') 42 self.parser.add_option("--bridgeOverlapFlag", 43 action="store", 44 dest="bridgeOverlapFlag", 45 default=None, 46 help='bridgeOverlap flag (on/off)') 47 self.parser.add_option("--rotationAxis", 48 action="store", 49 dest="rotationAxis", 50 default=None, 51 help='rotation axis for cyclicGgi') 52 self.parser.add_option("--rotationAngle", 53 action="store", 54 dest="rotationAngle", 55 default=None, 56 help='rotation axis angle for cyclicGgi') 57 self.parser.add_option("--separationOffset", 58 action="store", 59 dest="separationOffset", 60 default=None, 61 help='separation offset for cyclicGgi') 62 63 self.parser.add_option("--test", 64 action="store_true", 65 default=False, 66 dest="test", 67 help="Only print the new boundary file")
68
69 - def run(self):
70 fName=self.parser.getArgs()[0] 71 bName=self.parser.getArgs()[1] 72 73 boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True) 74 75 bnd=boundary.content 76 77 if type(bnd)!=list: 78 self.error("Problem with boundary file (not a list)") 79 80 found=False 81 82 for val in bnd: 83 if val==bName: 84 found=True 85 elif found: 86 bcType=val["type"] 87 if re.match("cyclicGgi", bcType)!= None or re.match("ggi", bcType)!= None: 88 if self.parser.getOptions().shadowName!=None: 89 shadowName=self.parser.getOptions().shadowName 90 val["shadowPatch"]=shadowName 91 if shadowName not in bnd: 92 print "Warning: Setting the shadowName option for patch",bName,": there is no patch called",shadowName 93 print " The boundary file was still modified for patch",bName 94 95 if self.parser.getOptions().patchZoneName!=None: 96 val["zone"]=self.parser.getOptions().patchZoneName 97 98 if self.parser.getOptions().bridgeOverlapFlag!=None: 99 val["bridgeOverlap"]=self.parser.getOptions().bridgeOverlapFlag 100 101 if val["type"]=="cyclicGgi": 102 if self.parser.getOptions().rotationAxis!=None: 103 val["rotationAxis"]=self.parser.getOptions().rotationAxis 104 105 if self.parser.getOptions().rotationAngle!=None: 106 val["rotationAngle"]=self.parser.getOptions().rotationAngle 107 108 if self.parser.getOptions().separationOffset!=None: 109 val["separationOffset"]=self.parser.getOptions().separationOffset 110 else: 111 print "Unsupported GGI type '",bcType,"' for patch",bName 112 break 113 114 if not found: 115 self.error("Boundary",bName,"not found in",bnd[::2]) 116 117 if self.parser.getOptions().test: 118 print boundary 119 else: 120 boundary.writeFile()
121