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
|
||||||
|
@ -74,7 +75,7 @@ Change GGI boundary condition parameters
|
||||||
dest="separationOffset",
|
dest="separationOffset",
|
||||||
default=None,
|
default=None,
|
||||||
help='separation offset for cyclicGgi')
|
help='separation offset for cyclicGgi')
|
||||||
|
|
||||||
self.parser.add_option("--test",
|
self.parser.add_option("--test",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -84,7 +85,7 @@ Change GGI boundary condition parameters
|
||||||
def run(self):
|
def run(self):
|
||||||
fName=self.parser.getArgs()[0]
|
fName=self.parser.getArgs()[0]
|
||||||
bName=self.parser.getArgs()[1]
|
bName=self.parser.getArgs()[1]
|
||||||
|
|
||||||
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
||||||
|
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
@ -123,7 +124,7 @@ Change GGI boundary condition parameters
|
||||||
val["separationOffset"]=self.parser.getOptions().separationOffset
|
val["separationOffset"]=self.parser.getOptions().separationOffset
|
||||||
|
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
if self.parser.getOptions().shadowName!=None:
|
if self.parser.getOptions().shadowName!=None:
|
||||||
self.warning("\n PatchName:",bName,": Option --shadowName is deprecated. Use --shadowPatch instead\n")
|
self.warning("\n PatchName:",bName,": Option --shadowName is deprecated. Use --shadowPatch instead\n")
|
||||||
shadowName=self.parser.getOptions().shadowName
|
shadowName=self.parser.getOptions().shadowName
|
||||||
|
@ -131,26 +132,25 @@ Change GGI boundary condition parameters
|
||||||
if shadowName not in bnd:
|
if shadowName not in bnd:
|
||||||
self.error("\n Option --shadowName for patch:",bName,": there is no patch called",shadowName,"\n")
|
self.error("\n Option --shadowName for patch:",bName,": there is no patch called",shadowName,"\n")
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
if self.parser.getOptions().patchZoneName!=None:
|
if self.parser.getOptions().patchZoneName!=None:
|
||||||
self.warning("\n PatchName:",bName,": Option --patchZoneName is deprecated. Use --zone instead\n")
|
self.warning("\n PatchName:",bName,": Option --patchZoneName is deprecated. Use --zone instead\n")
|
||||||
val["zone"]=self.parser.getOptions().patchZoneName
|
val["zone"]=self.parser.getOptions().patchZoneName
|
||||||
|
|
||||||
# Deprecated
|
# Deprecated
|
||||||
if self.parser.getOptions().bridgeOverlapFlag!=None:
|
if self.parser.getOptions().bridgeOverlapFlag!=None:
|
||||||
self.warning("\n PatchName:",bName,": Option --bridgeOverlapFlag is deprecated. Use --bridgeOverlap instead\n")
|
self.warning("\n PatchName:",bName,": Option --bridgeOverlapFlag is deprecated. Use --bridgeOverlap instead\n")
|
||||||
val["bridgeOverlap"]=self.parser.getOptions().bridgeOverlapFlag
|
val["bridgeOverlap"]=self.parser.getOptions().bridgeOverlapFlag
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ Change MixingPlane boundary condition parameters
|
||||||
action="store",
|
action="store",
|
||||||
dest="zone",
|
dest="zone",
|
||||||
default=None,
|
default=None,
|
||||||
help='Name of the zone for mixingPlanePatch')
|
help='Name of the zone for mixingPlanePatch')
|
||||||
self.parser.add_option("--coordinateSystemName",
|
self.parser.add_option("--coordinateSystemName",
|
||||||
action="store",
|
action="store",
|
||||||
dest="coordinateSystemName",
|
dest="coordinateSystemName",
|
||||||
|
@ -78,7 +79,7 @@ Change MixingPlane boundary condition parameters
|
||||||
dest="ribbonPatchDiscretisation",
|
dest="ribbonPatchDiscretisation",
|
||||||
default=None,
|
default=None,
|
||||||
help='ribbonPatch discretisation (masterPatch|slavePatch|bothPatches|uniform|userDefined)')
|
help='ribbonPatch discretisation (masterPatch|slavePatch|bothPatches|uniform|userDefined)')
|
||||||
|
|
||||||
self.parser.add_option("--test",
|
self.parser.add_option("--test",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
default=False,
|
||||||
|
@ -88,13 +89,13 @@ Change MixingPlane boundary condition parameters
|
||||||
def run(self):
|
def run(self):
|
||||||
fName=self.parser.getArgs()[0]
|
fName=self.parser.getArgs()[0]
|
||||||
bName=self.parser.getArgs()[1]
|
bName=self.parser.getArgs()[1]
|
||||||
|
|
||||||
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@ class switch(object):
|
||||||
"""Return the match method once, then stop"""
|
"""Return the match method once, then stop"""
|
||||||
yield self.match
|
yield self.match
|
||||||
raise StopIteration
|
raise StopIteration
|
||||||
|
|
||||||
def match(self, *args):
|
def match(self, *args):
|
||||||
"""Indicate whether or not to enter a case suite"""
|
"""Indicate whether or not to enter a case suite"""
|
||||||
if self.fall or not args:
|
if self.fall or not args:
|
||||||
|
@ -87,13 +88,13 @@ Change MixingPlane boundary condition parameters
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
fName=self.parser.getArgs()[0]
|
fName=self.parser.getArgs()[0]
|
||||||
|
|
||||||
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True)
|
||||||
|
|
||||||
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,23 +108,23 @@ 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"]
|
||||||
|
|
||||||
if bnd[indexDefPatch].has_key("ribbonPatch")==False:
|
if bnd[indexDefPatch].has_key("ribbonPatch")==False:
|
||||||
bnd[indexDefPatch]["ribbonPatch"]={}
|
bnd[indexDefPatch]["ribbonPatch"]={}
|
||||||
|
|
||||||
if bnd[indexDefPatch].has_key("zone")==False:
|
if bnd[indexDefPatch].has_key("zone")==False:
|
||||||
bnd[indexDefPatch]["zone"]=bnd[index] + "Zone"
|
bnd[indexDefPatch]["zone"]=bnd[index] + "Zone"
|
||||||
|
|
||||||
if oldAssembly != "":
|
if oldAssembly != "":
|
||||||
# Converting "assembly" to ribbonPatch/discretisation
|
# Converting "assembly" to ribbonPatch/discretisation
|
||||||
for case in switch(oldAssembly):
|
for case in switch(oldAssembly):
|
||||||
if case('master'):
|
if case('master'):
|
||||||
bnd[indexDefPatch]["ribbonPatch"]["discretisation"]="masterPatch"
|
bnd[indexDefPatch]["ribbonPatch"]["discretisation"]="masterPatch"
|
||||||
|
@ -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,15 +19,16 @@ 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
|
||||||
|
|
||||||
class InitGgiInterface(PyFoamApplication):
|
class InitGgiInterface(PyFoamApplication):
|
||||||
def __init__(self,args=None):
|
def __init__(self,args=None):
|
||||||
description="""
|
description="""
|
||||||
Init GGI boundary condition parameters in boundary file.
|
Init GGI boundary condition parameters in boundary file.
|
||||||
Init GGI boundary fields in time directories.
|
Init GGI boundary fields in time directories.
|
||||||
Generate faceSet scripts for ggi zones.
|
Generate faceSet scripts for ggi zones.
|
||||||
Modify GGI zones information in decomposeParDict file.
|
Modify GGI zones information in decomposeParDict file.
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
@ -183,10 +184,10 @@ Generate a setSet batch file based on the zone info specified in the ggi interfa
|
||||||
Generate a bash file for invoking setSet and setsToZones
|
Generate a bash file for invoking setSet and setsToZones
|
||||||
Update GGI zone infoprmation in decomposeParDict
|
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,8 +210,8 @@ 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 ])
|
||||||
bfInitGgiZones.writeLine([ "setsToZones -noFlipMap" ])
|
bfInitGgiZones.writeLine([ "setsToZones -noFlipMap" ])
|
||||||
|
@ -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)"
|
||||||
|
@ -232,7 +233,7 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
caseDir=self.parser.getArgs()[0]
|
caseDir=self.parser.getArgs()[0]
|
||||||
masterbName=self.parser.getArgs()[1]
|
masterbName=self.parser.getArgs()[1]
|
||||||
shadowbName=self.parser.getArgs()[2]
|
shadowbName=self.parser.getArgs()[2]
|
||||||
|
|
||||||
boundary=ParsedParameterFile(path.join(".",caseDir,"constant","polyMesh","boundary"),debug=False,boundaryDict=True,backup=True)
|
boundary=ParsedParameterFile(path.join(".",caseDir,"constant","polyMesh","boundary"),debug=False,boundaryDict=True,backup=True)
|
||||||
|
|
||||||
bnd=boundary.content
|
bnd=boundary.content
|
||||||
|
@ -249,7 +250,7 @@ Update GGI zone infoprmation in decomposeParDict
|
||||||
timeDirs=self.parser.getOptions().timeDirs
|
timeDirs=self.parser.getOptions().timeDirs
|
||||||
updateTimeDirs=True
|
updateTimeDirs=True
|
||||||
|
|
||||||
ggiType=self.parser.getOptions().ggiType
|
ggiType=self.parser.getOptions().ggiType
|
||||||
|
|
||||||
rotationAngle=0.0
|
rotationAngle=0.0
|
||||||
if self.parser.getOptions().rotationAngle!=None:
|
if self.parser.getOptions().rotationAngle!=None:
|
||||||
|
@ -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()
|
||||||
|
|
||||||
|
@ -179,13 +180,13 @@ Modify the definition of a mixingPlane patch in the time directories
|
||||||
fName=self.parser.getArgs()[0]
|
fName=self.parser.getArgs()[0]
|
||||||
masterbName=self.parser.getArgs()[1]
|
masterbName=self.parser.getArgs()[1]
|
||||||
shadowbName=self.parser.getArgs()[2]
|
shadowbName=self.parser.getArgs()[2]
|
||||||
|
|
||||||
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True,backup=True)
|
boundary=ParsedParameterFile(path.join(".",fName,"constant","polyMesh","boundary"),debug=False,boundaryDict=True,backup=True)
|
||||||
|
|
||||||
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