1
2 """
3 Application class that implements pyFoamUpgradeDictionariesTo20
4 """
5
6 import sys,re
7 from os import path
8
9 from UpgradeDictionariesTo17 import UpgradeDictionariesTo17,DictionaryUpgradeInfo
10
11 from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
12 from PyFoam.Basics.DataStructures import DictProxy,TupleProxy
13 from PyFoam.Error import error,warning
14
18
20 return path.join("constant","polyMesh","blockMeshDict")
21
23 return "boundary" not in content
24
26 p=content["patches"]
27 bnd=[]
28 for t,n,f in zip(p[0::3],p[1::3],p[2::3]):
29 bnd+=[ n, { "type" : t,
30 "faces" : f }]
31 content["boundary"]=bnd
32
36
38 return path.join("constant","thermophysicalProperties")
39
41 return content["thermoType"].replace('>','').split('<')
42
44 tt=self.analyzeThermoType(content)
45 if len(tt)!=6:
46 return False
47
48 for nm in content:
49 data=content[nm]
50 if type(data) in [tuple,TupleProxy]:
51 if len(data)>4:
52 return True
53
54 return False
55
57 what,mix,trans,spec,therm,gas=self.analyzeThermoType(content)
58 for nm in content:
59 data=content[nm]
60 used=0
61
62 if type(data) not in [tuple,TupleProxy]:
63 continue
64 if len(data)<5:
65 continue
66
67 transDict={}
68 if trans=="constTransport":
69 transDict["Pr"]=data[-1-used]
70 transDict["mu"]=data[-2-used]
71 used+=2
72 elif trans=="sutherlandTransport":
73 transDict["Ts"]=data[-1-used]
74 transDict["As"]=data[-2-used]
75 used+=2
76 else:
77 error("Transport type",trans,"not implemented")
78
79 thermDict={}
80 if therm=="hConstThermo":
81 thermDict["Hf"]=data[-1-used]
82 thermDict["Cp"]=data[-2-used]
83 used+=2
84 elif therm=="eConstThermo":
85 thermDict["Hf"]=data[-1-used]
86 thermDict["Cv"]=data[-2-used]
87 used+=2
88 elif therm=="janafThermo":
89 thermDict["lowCpCoeffs"]=data[-7-used:-0-used]
90 thermDict["highCpCoeffs"]=data[-14-used:-7-used]
91 thermDict["Tcommon"]=data[-15-used]
92 thermDict["Thigh"]=data[-16-used]
93 thermDict["Tlow"]=data[-17-used]
94 used+=2*7+3
95 else:
96 error("Thermodynamics type",therm,"not implemented")
97
98 specDict={}
99 if spec=="specieThermo":
100 specDict["molWeight"]=data[-1-used]
101 specDict["nMoles"]=data[-2-used]
102 used+=2
103 else:
104 error("Specie type",spec,"not implemented")
105
106 if len(data)!=used+1:
107 warning("Not all data for",nm,"used")
108
109 comment=self.makeComment(data)
110 content[nm]={"specie":specDict,
111 "thermodynamics":thermDict,
112 "transport":transDict}
113 content.addDecoration(nm,comment)
114
115
116
117
118
119
120
137
138
139
140