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 __iter__(self):
26 for p in self.content: 27 yield p
28
29 - def patches(self,patchType=None):
30 """Returns a list with the names of the patches 31 @param patchType: If specified only patches of the specific type are returned""" 32 33 if patchType==None: 34 return self.content.keys() 35 else: 36 result=[] 37 for k,v in self.content.iteritems(): 38 if v["type"]==patchType: 39 result.append(k) 40 return result
41