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