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