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