1 """Works with a polyMesh/boundary-File"""
2
3 from PyFoam.RunDictionary.ParsedParameterFile import ParsedBoundaryDict
4 from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory
5 from PyFoam.Error import PyFoamException
6
7 from PyFoam.ThirdParty.six import iteritems
8
10 """Handles data in a boundary-File"""
11
12 - def __init__(self,
13 case,
14 backup=False,
15 treatBinaryAsASCII=False,
16 region=None,
17 processor=None,
18 time=None):
19 """@param case: Path to the case-directory"""
20 try:
21 ParsedBoundaryDict.__init__(self,
22 SolutionDirectory(case,
23 archive=None,
24 paraviewLink=False).boundaryDict(time=time,
25 region=region,
26 processor=processor),
27 treatBinaryAsASCII=treatBinaryAsASCII,
28 backup=backup)
29 except IOError:
30 ParsedBoundaryDict.__init__(self,
31 SolutionDirectory(case,
32 archive=None,
33 paraviewLink=False).boundaryDict(region=region,
34 processor=processor),
35 treatBinaryAsASCII=treatBinaryAsASCII,
36 backup=backup)
37
39 return self.content[key]
40
42 if not type(value)==dict:
43 raise PyFoamException("Type of boundary element must be dict, is"+str(type(value)))
44 for k in ["type","nFaces","startFace"]:
45 if k not in value:
46 raise PyFoamException("Required key "+str(k)+" is missing from"+str(value)+"not a valid patch")
47
48 self.content[key]=value
49
51 for p in self.content:
52 yield p
53
55 """Returns a list with the names of the patches
56 @param patchType: If specified only patches of the specific type are returned"""
57
58 if patchType==None:
59 return list(self.content.keys())
60 else:
61 result=[]
62 for k,v in iteritems(self.content):
63 if v["type"]==patchType:
64 result.append(k)
65 return result
66
67
68