Package PyFoam :: Package RunDictionary :: Module BoundaryDict
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.RunDictionary.BoundaryDict

 1  """Works with a polyMesh/boundary-File""" 
 2   
 3  from ParsedParameterFile import ParsedBoundaryDict 
 4  from SolutionDirectory import SolutionDirectory 
 5   
6 -class BoundaryDict(ParsedBoundaryDict):
7 """Handles data in a boundary-File""" 8
9 - def __init__(self,case,backup=False,region=None):
10 """@param case: Path to the case-directory""" 11 ParsedBoundaryDict.__init__(self,SolutionDirectory(case).boundaryDict(region=region),backup=backup)
12
13 - def __getitem__(self,key):
14 return self.content[key]
15
16 - def __setitem__(self,key,value):
17 if not type(value)==dict: 18 raise "BoundaryType",("Type of boundary element must be dict, is",type(value)) 19 for k in ["type","nFaces","startFace"]: 20 if not value.has_key(k): 21 raise "BoundaryType",("Required key",k,"is missing from",value,"not a valid patch") 22 23 self.content[key]=value
24
25 - def patches(self,patchType=None):
26 """Returns a list with the names of the patches 27 @param patchType: If specified only patches of the specific type are returned""" 28 29 if patchType==None: 30 return self.content.keys() 31 else: 32 result=[] 33 for k,v in self.content.iteritems(): 34 if v["type"]==patchType: 35 result.append(k) 36 return result
37