Adapt the Hydro-Quebec scripts
a) to conform to the new PyFoam.Site-package b) Run on Python 2 and Python 3 (by replacing print with the print_ from the six-library)
This commit is contained in:
parent
f450b35fd4
commit
b1ab3694fa
10 changed files with 59 additions and 61 deletions
|
@ -9,8 +9,9 @@ Author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyFoamApplication import PyFoamApplication
|
from PyFoam.Applications.PyFoamApplication import PyFoamApplication
|
||||||
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
||||||
|
from PyFoam.ThirdParty.six import print_
|
||||||
from os import path
|
from os import path
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
@ -143,14 +144,13 @@ Change GGI boundary condition parameters
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "Unsupported GGI type '",bcType,"' for patch",bName
|
print_("Unsupported GGI type '",bcType,"' for patch",bName)
|
||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
self.error("Boundary",bName,"not found in",bnd[::2])
|
self.error("Boundary",bName,"not found in",bnd[::2])
|
||||||
|
|
||||||
if self.parser.getOptions().test:
|
if self.parser.getOptions().test:
|
||||||
print boundary
|
print_(boundary)
|
||||||
else:
|
else:
|
||||||
boundary.writeFile()
|
boundary.writeFile()
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,9 @@ Author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyFoamApplication import PyFoamApplication
|
from PyFoam.Applications.PyFoamApplication import PyFoamApplication
|
||||||
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
||||||
|
from PyFoam.ThirdParty.six import print_
|
||||||
from os import path
|
from os import path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -94,7 +95,7 @@ Change MixingPlane boundary condition parameters
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
|
||||||
if type(bnd)!=list:
|
if type(bnd)!=list:
|
||||||
print "Problem with boundary file (not a list)"
|
print_("Problem with boundary file (not a list)")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
found=False
|
found=False
|
||||||
|
@ -143,11 +144,10 @@ Change MixingPlane boundary condition parameters
|
||||||
break
|
break
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
print "Boundary",bName,"not found in",bnd[::2]
|
print_("Boundary",bName,"not found in",bnd[::2])
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if self.parser.getOptions().test:
|
if self.parser.getOptions().test:
|
||||||
print boundary
|
print_(boundary)
|
||||||
else:
|
else:
|
||||||
boundary.writeFile()
|
boundary.writeFile()
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,9 @@ Author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyFoamApplication import PyFoamApplication
|
from PyFoam.Applications.PyFoamApplication import PyFoamApplication
|
||||||
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
||||||
|
from PyFoam.ThirdParty.six import print_
|
||||||
from os import path
|
from os import path
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -93,7 +94,7 @@ Change MixingPlane boundary condition parameters
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
|
||||||
if type(bnd)!=list:
|
if type(bnd)!=list:
|
||||||
print "Problem with boundary file (not a list)"
|
print_("Problem with boundary file (not a list)")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
found=False
|
found=False
|
||||||
|
@ -107,12 +108,12 @@ Change MixingPlane boundary condition parameters
|
||||||
|
|
||||||
if bnd[indexDefPatch]["type"]=="mixingPlane":
|
if bnd[indexDefPatch]["type"]=="mixingPlane":
|
||||||
if bnd[indexDefPatch].has_key("assembly"):
|
if bnd[indexDefPatch].has_key("assembly"):
|
||||||
print " Replacing the parameter 'assembly' for patch", bnd[index]
|
print_(" Replacing the parameter 'assembly' for patch", bnd[index])
|
||||||
oldAssembly=bnd[indexDefPatch]["assembly"]
|
oldAssembly=bnd[indexDefPatch]["assembly"]
|
||||||
del bnd[indexDefPatch]["assembly"]
|
del bnd[indexDefPatch]["assembly"]
|
||||||
|
|
||||||
if bnd[indexDefPatch].has_key("orientation"):
|
if bnd[indexDefPatch].has_key("orientation"):
|
||||||
print " Replacing the parameter 'orientation' for patch", bnd[index]
|
print_(" Replacing the parameter 'orientation' for patch", bnd[index])
|
||||||
oldOrientation=bnd[indexDefPatch]["orientation"]
|
oldOrientation=bnd[indexDefPatch]["orientation"]
|
||||||
del bnd[indexDefPatch]["orientation"]
|
del bnd[indexDefPatch]["orientation"]
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ Change MixingPlane boundary condition parameters
|
||||||
bnd[indexDefPatch]["ribbonPatch"]["discretisation"]="userDefined"
|
bnd[indexDefPatch]["ribbonPatch"]["discretisation"]="userDefined"
|
||||||
break
|
break
|
||||||
if case(): # default
|
if case(): # default
|
||||||
print "Unsupported assembly type: ", oldAssembly
|
print_("Unsupported assembly type: ", oldAssembly)
|
||||||
|
|
||||||
if oldOrientation != "":
|
if oldOrientation != "":
|
||||||
# Converting "orientation" to ribbonPatch/ribbonPatchSweepAxis and
|
# Converting "orientation" to ribbonPatch/ribbonPatchSweepAxis and
|
||||||
|
@ -194,10 +195,9 @@ Change MixingPlane boundary condition parameters
|
||||||
bnd[indexDefPatch]["ribbonPatch"]["sweepAxis"]="R"
|
bnd[indexDefPatch]["ribbonPatch"]["sweepAxis"]="R"
|
||||||
break
|
break
|
||||||
if case(): # default
|
if case(): # default
|
||||||
print "Unsupported orientation type: ", oldOrientation
|
print_("Unsupported orientation type: ", oldOrientation)
|
||||||
|
|
||||||
if self.parser.getOptions().test:
|
if self.parser.getOptions().test:
|
||||||
print boundary
|
print_(boundary)
|
||||||
else:
|
else:
|
||||||
boundary.writeFile()
|
boundary.writeFile()
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ import sys, fnmatch, re
|
||||||
from os import path, listdir, chmod
|
from os import path, listdir, chmod
|
||||||
from stat import *
|
from stat import *
|
||||||
|
|
||||||
from PyFoamApplication import PyFoamApplication
|
from PyFoam.Applications.PyFoamApplication import PyFoamApplication
|
||||||
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
||||||
|
from PyFoam.ThirdParty.six import print_
|
||||||
from PyFoam.RunDictionary.TimeDirectory import TimeDirectory
|
from PyFoam.RunDictionary.TimeDirectory import TimeDirectory
|
||||||
from PyFoam.Basics.BasicFile import BasicFile
|
from PyFoam.Basics.BasicFile import BasicFile
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ Modify GGI zones information in decomposeParDict file.
|
||||||
Create a default definition for a ggi patch, and replace
|
Create a default definition for a ggi patch, and replace
|
||||||
the current definition
|
the current definition
|
||||||
"""
|
"""
|
||||||
print "Replacing definition of patch: ", patchName, ":", patch
|
print_("Replacing definition of patch: ", patchName, ":", patch)
|
||||||
newPatch={
|
newPatch={
|
||||||
'type' : ggiType,
|
'type' : ggiType,
|
||||||
'nFaces' : patch["nFaces"],
|
'nFaces' : patch["nFaces"],
|
||||||
|
@ -123,7 +124,7 @@ the current definition
|
||||||
description="""\
|
description="""\
|
||||||
Modify the definition of a ggi patch
|
Modify the definition of a ggi patch
|
||||||
"""
|
"""
|
||||||
print " Modifying ggi boundary definition in constant/polyMesh/boundary for patch", patchName
|
print_(" Modifying ggi boundary definition in constant/polyMesh/boundary for patch", patchName)
|
||||||
|
|
||||||
patch["type"]=ggiType
|
patch["type"]=ggiType
|
||||||
|
|
||||||
|
@ -167,12 +168,12 @@ Modify the definition of a ggi patch in the time directories
|
||||||
|
|
||||||
for timeDir in listdir(caseDir):
|
for timeDir in listdir(caseDir):
|
||||||
if reobj.match(timeDir):
|
if reobj.match(timeDir):
|
||||||
print " Modifying ggi boundaryFields in timeDir", timeDir, "for patch", patchName
|
print_(" Modifying ggi boundaryFields in timeDir", timeDir, "for patch", patchName)
|
||||||
|
|
||||||
td=TimeDirectory(caseDir, timeDir, yieldParsedFiles=True)
|
td=TimeDirectory(caseDir, timeDir, yieldParsedFiles=True)
|
||||||
|
|
||||||
for f in td:
|
for f in td:
|
||||||
print " Modifying field", f.name
|
print_(" Modifying field", f.name)
|
||||||
f["boundaryField"][patchName]["type"]=ggiType
|
f["boundaryField"][patchName]["type"]=ggiType
|
||||||
f.writeFile()
|
f.writeFile()
|
||||||
|
|
||||||
|
@ -186,7 +187,7 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
# Default file: genFaceSetForGgiZones.setSet
|
# Default file: genFaceSetForGgiZones.setSet
|
||||||
bfGenFaceSets = BasicFile(path.join(caseDir, self.parser.getOptions().genFaceSetForGgiZonesScriptName))
|
bfGenFaceSets = BasicFile(path.join(caseDir, self.parser.getOptions().genFaceSetForGgiZonesScriptName))
|
||||||
|
|
||||||
print " Updating file ", bfGenFaceSets.name, " for generating GGI zones faceSet using the setSet command"
|
print_(" Updating file ", bfGenFaceSets.name, " for generating GGI zones faceSet using the setSet command")
|
||||||
|
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
|
||||||
|
@ -209,7 +210,7 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
# Default file: initGgiZones.sh
|
# Default file: initGgiZones.sh
|
||||||
bfInitGgiZones = BasicFile(path.join(caseDir, self.parser.getOptions().initGgiZonesScriptName))
|
bfInitGgiZones = BasicFile(path.join(caseDir, self.parser.getOptions().initGgiZonesScriptName))
|
||||||
|
|
||||||
print " Updating file ", bfInitGgiZones.name, " for inititalizing GGI zones"
|
print_(" Updating file ", bfInitGgiZones.name, " for inititalizing GGI zones")
|
||||||
|
|
||||||
bfInitGgiZones.writeLine([ "#!/bin/bash" ])
|
bfInitGgiZones.writeLine([ "#!/bin/bash" ])
|
||||||
bfInitGgiZones.writeLine([ "setSet -batch " + self.parser.getOptions().genFaceSetForGgiZonesScriptName ])
|
bfInitGgiZones.writeLine([ "setSet -batch " + self.parser.getOptions().genFaceSetForGgiZonesScriptName ])
|
||||||
|
@ -222,7 +223,7 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
# DecomposeParDict
|
# DecomposeParDict
|
||||||
decomposeParDictPath=path.join(caseDir,"system","decomposeParDict")
|
decomposeParDictPath=path.join(caseDir,"system","decomposeParDict")
|
||||||
if path.exists(decomposeParDictPath):
|
if path.exists(decomposeParDictPath):
|
||||||
print " Updating file ", decomposeParDictPath, " for GGI zones"
|
print_(" Updating file ", decomposeParDictPath, " for GGI zones")
|
||||||
decomposeParDict=ParsedParameterFile(decomposeParDictPath,debug=False,backup=True)
|
decomposeParDict=ParsedParameterFile(decomposeParDictPath,debug=False,backup=True)
|
||||||
dcp=decomposeParDict.content
|
dcp=decomposeParDict.content
|
||||||
dcp["globalFaceZones"]="(\n " + '\n '.join(list(listOfGgiZones)) + "\n)"
|
dcp["globalFaceZones"]="(\n " + '\n '.join(list(listOfGgiZones)) + "\n)"
|
||||||
|
@ -287,10 +288,9 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
self.error("Boundary patch",shadowbName,"not found in",bnd[::2])
|
self.error("Boundary patch",shadowbName,"not found in",bnd[::2])
|
||||||
|
|
||||||
if self.parser.getOptions().test:
|
if self.parser.getOptions().test:
|
||||||
print boundary
|
print_(boundary)
|
||||||
else:
|
else:
|
||||||
boundary.writeFile()
|
boundary.writeFile()
|
||||||
|
|
||||||
# Write companion files
|
# Write companion files
|
||||||
self.generateCompanionFiles(caseDir, boundary)
|
self.generateCompanionFiles(caseDir, boundary)
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@ Author:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from PyFoamApplication import PyFoamApplication
|
from PyFoam.Applications.PyFoamApplication import PyFoamApplication
|
||||||
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
|
||||||
from PyFoam.RunDictionary.TimeDirectory import TimeDirectory
|
from PyFoam.RunDictionary.TimeDirectory import TimeDirectory
|
||||||
|
from PyFoam.ThirdParty.six import print_
|
||||||
from os import path, listdir
|
from os import path, listdir
|
||||||
import sys, fnmatch, re
|
import sys, fnmatch, re
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ Init MixingPlane boundary condition parameters
|
||||||
Create a default definition for a mixingPlane patch, and replace
|
Create a default definition for a mixingPlane patch, and replace
|
||||||
the current definition
|
the current definition
|
||||||
"""
|
"""
|
||||||
print "Replacing definition of patch: ", patchName, ":", patch
|
print_("Replacing definition of patch: ", patchName, ":", patch)
|
||||||
newPatch={
|
newPatch={
|
||||||
'type' : "mixingPlane",
|
'type' : "mixingPlane",
|
||||||
'nFaces' : patch["nFaces"],
|
'nFaces' : patch["nFaces"],
|
||||||
|
@ -120,7 +121,7 @@ the current definition
|
||||||
description="""\
|
description="""\
|
||||||
Modify the definition of a mixingPlane patch
|
Modify the definition of a mixingPlane patch
|
||||||
"""
|
"""
|
||||||
print " Modifying mixingPlane boundary definition in constant/polyMesh/boundary for patch", patchName
|
print_(" Modifying mixingPlane boundary definition in constant/polyMesh/boundary for patch", patchName)
|
||||||
|
|
||||||
patch["shadowPatch"]=shadowName
|
patch["shadowPatch"]=shadowName
|
||||||
|
|
||||||
|
@ -166,12 +167,12 @@ Modify the definition of a mixingPlane patch in the time directories
|
||||||
|
|
||||||
for timeDir in listdir(caseDir):
|
for timeDir in listdir(caseDir):
|
||||||
if reobj.match(timeDir):
|
if reobj.match(timeDir):
|
||||||
print " Modifying mixingPlane boundaryFields in timeDir", timeDir, "for patch", patchName
|
print_(" Modifying mixingPlane boundaryFields in timeDir", timeDir, "for patch", patchName)
|
||||||
|
|
||||||
td=TimeDirectory(caseDir, timeDir, yieldParsedFiles=True)
|
td=TimeDirectory(caseDir, timeDir, yieldParsedFiles=True)
|
||||||
|
|
||||||
for f in td:
|
for f in td:
|
||||||
print " Modifying field", f.name
|
print_(" Modifying field", f.name)
|
||||||
f["boundaryField"][patchName]["type"]='mixingPlane'
|
f["boundaryField"][patchName]["type"]='mixingPlane'
|
||||||
f.writeFile()
|
f.writeFile()
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ Modify the definition of a mixingPlane patch in the time directories
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
|
||||||
if type(bnd)!=list:
|
if type(bnd)!=list:
|
||||||
print "Problem with boundary file (not a list)"
|
print_("Problem with boundary file (not a list)")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
masterFound=False
|
masterFound=False
|
||||||
|
@ -197,7 +198,7 @@ Modify the definition of a mixingPlane patch in the time directories
|
||||||
timeDirs=self.parser.getOptions().timeDirs
|
timeDirs=self.parser.getOptions().timeDirs
|
||||||
updateTimeDirs=True
|
updateTimeDirs=True
|
||||||
|
|
||||||
print "UpdateTimeDirs: ", updateTimeDirs
|
print_("UpdateTimeDirs: ", updateTimeDirs)
|
||||||
|
|
||||||
for index in range(len(bnd)):
|
for index in range(len(bnd)):
|
||||||
|
|
||||||
|
@ -233,9 +234,6 @@ Modify the definition of a mixingPlane patch in the time directories
|
||||||
self.error("Boundary patch",shadowbName,"not found in",bnd[::2])
|
self.error("Boundary patch",shadowbName,"not found in",bnd[::2])
|
||||||
|
|
||||||
if self.parser.getOptions().test:
|
if self.parser.getOptions().test:
|
||||||
print boundary
|
print_(boundary)
|
||||||
else:
|
else:
|
||||||
boundary.writeFile()
|
boundary.writeFile()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from PyFoam.Applications.ChangeGGIBoundary import ChangeGGIBoundary
|
from PyFoam.Site.ChangeGGIBoundary import ChangeGGIBoundary
|
||||||
|
|
||||||
ChangeGGIBoundary()
|
ChangeGGIBoundary()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from PyFoam.Applications.ChangeMixingPlaneBoundary import ChangeMixingPlaneBoundary
|
from PyFoam.Site.ChangeMixingPlaneBoundary import ChangeMixingPlaneBoundary
|
||||||
|
|
||||||
ChangeMixingPlaneBoundary()
|
ChangeMixingPlaneBoundary()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from PyFoam.Applications.ConvertMixingPlaneBoundaryToNewSyntax import ConvertMixingPlaneBoundaryToNewSyntax
|
from PyFoam.Site.ConvertMixingPlaneBoundaryToNewSyntax import ConvertMixingPlaneBoundaryToNewSyntax
|
||||||
|
|
||||||
ConvertMixingPlaneBoundaryToNewSyntax()
|
ConvertMixingPlaneBoundaryToNewSyntax()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from PyFoam.Applications.InitGgiInterface import InitGgiInterface
|
from PyFoam.Site.InitGgiInterface import InitGgiInterface
|
||||||
|
|
||||||
InitGgiInterface()
|
InitGgiInterface()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from PyFoam.Applications.InitMixingPlaneInterface import InitMixingPlaneInterface
|
from PyFoam.Site.InitMixingPlaneInterface import InitMixingPlaneInterface
|
||||||
|
|
||||||
InitMixingPlaneInterface()
|
InitMixingPlaneInterface()
|
||||||
|
|
Reference in a new issue