Package PyFoam :: Package Applications :: Module UpgradeDictionariesTo20
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Applications.UpgradeDictionariesTo20

  1  #  ICE Revision: $Id: /local/openfoam/Python/PyFoam/PyFoam/Applications/UpgradeDictionariesTo20.py 7660 2012-01-07T16:44:40.128256Z bgschaid  $  
  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   
15 -class BlockMeshUpgradeInfo(DictionaryUpgradeInfo):
16 - def __init__(self):
18
19 - def location(self):
20 return path.join("constant","polyMesh","blockMeshDict")
21
22 - def checkUpgrade(self,content):
23 return "boundary" not in content
24
25 - def manipulate(self,content):
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
33 -class ThermophysicalUpgradeInfo(DictionaryUpgradeInfo):
34 - def __init__(self):
36
37 - def location(self):
38 return path.join("constant","thermophysicalProperties")
39
40 - def analyzeThermoType(self,content):
41 return content["thermoType"].replace('>','').split('<')
42
43 - def checkUpgrade(self,content):
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: # Maybe there is a better criterium 52 return True 53 54 return False
55
56 - def manipulate(self,content):
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 ## gasDict={} 116 ## if gas=="perfectGas": 117 ## pass 118 ## else: 119 ## error("Gas type",gas,"not implemented") 120
121 -class UpgradeDictionariesTo20(UpgradeDictionariesTo17):
122 - def __init__(self,args=None):
123 description="""\ 124 Examines dictionaries in a case and tries to upgrade them to a form 125 that is compatible with OpenFOAM 2.0 126 """ 127 128 UpgradeDictionariesTo17.__init__(self, 129 args=args, 130 description=description)
131
132 - def addDicts(self):
137 138 ## def addOptions(self): 139 ## UpgradeDictionariesTo17.addOptions(self) 140