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  from PyFoam.Error import PyFoamException 
 6   
7 -class BoundaryDict(ParsedBoundaryDict):
8 """Handles data in a boundary-File""" 9
10 - def __init__(self,case,backup=False,region=None):
11 """@param case: Path to the case-directory""" 12 ParsedBoundaryDict.__init__(self,SolutionDirectory(case).boundaryDict(region=region),backup=backup)
13
14 - def __getitem__(self,key):
15 return self.content[key]
16
17 - def __setitem__(self,key,value):
18 if not type(value)==dict: 19 raise PyFoamException("Type of boundary element must be dict, is"+str(type(value))) 20 for k in ["type","nFaces","startFace"]: 21 if not value.has_key(k): 22 raise PyFoamException("Required key "+str(k)+" is missing from"+str(value)+"not a valid patch") 23 24 self.content[key]=value
25
26 - def __iter__(self):
27 for p in self.content: 28 yield p
29
30 - def patches(self,patchType=None):
31 """Returns a list with the names of the patches 32 @param patchType: If specified only patches of the specific type are returned""" 33 34 if patchType==None: 35 return self.content.keys() 36 else: 37 result=[] 38 for k,v in self.content.iteritems(): 39 if v["type"]==patchType: 40 result.append(k) 41 return result
42