def XoodlesPitzTutorial(): prefix=foamTutorials() if oldTutorialStructure(): prefix=path.join(prefix,"Xoodles") else: prefix=path.join(prefix,"combustion","XiFoam","les") return path.join(prefix,"pitzDaily3D")
def potentialCylinderTutorial(): prefix=foamTutorials() if oldTutorialStructure(): prefix=path.join(prefix,"potentialFoam") else: prefix=path.join(prefix,"basic","potentialFoam") return path.join(prefix,"cylinder")
def turbCavityTutorial(): prefix=foamTutorials() if oldTutorialStructure(): prefix=path.join(prefix,"turbFoam") else: prefix=path.join(prefix,"incompressible","pisoFoam","ras") return path.join(prefix,"cavity")
def damBreakTutorial(): prefix=foamTutorials() if oldTutorialStructure(): prefix=path.join(prefix,"interFoam") else: prefix=path.join(prefix,"multiphase","interFoam","laminar") return path.join(prefix,"damBreak")
def __init__(self,sol,correctors,tolerance,relTol,pRefValue=None,pRefCell=None): self.solution=ParsedParameterFile(path.join(sol.systemDir(),"fvSolution"),backup=True) self.schemes=ParsedParameterFile(path.join(sol.systemDir(),"fvSchemes"),backup=True) self.control=ParsedParameterFile(path.join(sol.systemDir(),"controlDict"),backup=True) self.controlOrig=ParsedParameterFile(path.join(sol.systemDir(),"controlDict"),backup=False) pre=environ["FOAM_TUTORIALS"] if not oldTutorialStructure(): pre=path.join(pre,"basic") pot=SolutionDirectory(path.join(pre,"potentialFoam","cylinder"),archive=None,paraviewLink=False) self.fresh=True try: if "SIMPLE" not in self.solution: self.solution["SIMPLE"]=ParsedParameterFile(path.join(pot.systemDir(),"fvSolution"),backup=False)["SIMPLE"] if "nNonOrthogonalCorrectors" not in self.solution["SIMPLE"] and correctors==None: correctors=3 warning("Setting number of correctors to default value",correctors) if correctors!=None: self.solution["SIMPLE"]["nNonOrthogonalCorrectors"]=correctors if pRefCell!=None: self.solution["SIMPLE"]["pRefCell"]=pRefCell if pRefValue!=None: self.solution["SIMPLE"]["pRefValue"]=pRefValue if tolerance!=None: try: self.solution["solvers"]["p"][1]["tolerance"]=tolerance except KeyError: # 1.6 format self.solution["solvers"]["p"]["tolerance"]=tolerance if relTol!=None: try: self.solution["solvers"]["p"][1]["relTol"]=relTol except KeyError: # 1.6 format self.solution["solvers"]["p"]["relTol"]=relTol self.schemes.content=ParsedParameterFile(path.join(pot.systemDir(),"fvSchemes"),backup=False).content self.control.content=ParsedParameterFile(path.join(pot.systemDir(),"controlDict"),backup=False).content if "functions" in self.controlOrig: print "Copying functions over" self.control["functions"]=self.controlOrig["functions"] if "libs" in self.controlOrig: print "Copying libs over" self.control["libs"]=self.controlOrig["libs"] self.solution.writeFile() self.schemes.writeFile() self.control.writeFile() except Exception,e: warning("Restoring defaults") self.solution.restore() self.schemes.restore() self.control.restore() raise e
def damBreakTutorial(): prefix = foamTutorials() if oldTutorialStructure(): prefix = path.join(prefix, "interFoam") else: prefix = path.join(prefix, "multiphase", "interFoam", "laminar") return path.join(prefix, "damBreak")
def bubbleColumnTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"multiphase") if foamVersionNumber()>=(3,): return path.join(prefix,"twoPhaseEulerFoam","laminar","bubbleColumn") else: return path.join(prefix,"twoPhaseEulerFoam","bubbleColumn")
def simpleBikeTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"incompressible") else: error("The simpleFoam-motorBike-case does not exist before 1.6") return path.join(prefix,"simpleFoam","motorBike")
def setUp(self): if oldTutorialStructure(): null="0" elif foamFork() in ["openfoam","openfoamplus"] and foamVersionNumber()>=(4,): null="0.orig" else: null="0.org" self.fileName=path.join(simpleBikeTutorial(),null,"U")
def buoyHotRoomTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"heatTransfer") if foamVersionNumber()>=(3,): return path.join(prefix,"buoyantSimpleFoam","hotRadiationRoom") else: return path.join(prefix,"buoyantSimpleFoam","hotRoom")
def setUp(self): self.theDir=tmpnam() if oldTutorialStructure(): null="0" else: null="0.org" system("cp -r "+path.join(simpleBikeTutorial(),null)+" "+self.theDir) self.theFile=path.join(self.theDir,"U")
def damBreakTutorial(): prefix=foamTutorials() if oldTutorialStructure(): prefix=path.join(prefix,"interFoam") else: prefix=path.join(prefix,"multiphase","interFoam","laminar") if foamFork() in ["openfoam","openfoamplus"] and foamVersionNumber()>=(4,): prefix=path.join(prefix,"damBreak") return path.join(prefix,"damBreak")
def setUp(self): self.theDir=mkdtemp() if oldTutorialStructure(): null="0" else: null="0.org" usedDir=path.join(self.theDir,"data") copytree(path.join(simpleBikeTutorial(),null),usedDir) self.theFile=path.join(usedDir,"U")
def setUp(self): self.theDir=mkdtemp() if oldTutorialStructure(): null="0" elif foamFork() in ["openfoam","openfoamplus"] and foamVersionNumber()>=(4,): null="0.orig" else: null="0.org" usedDir=path.join(self.theDir,"data") copytree(path.join(simpleBikeTutorial(),null),usedDir) self.theFile=path.join(usedDir,"U")
def bubbleColumnTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"multiphase") return path.join(prefix,"twoPhaseEulerFoam","bubbleColumn")
def setUp(self): if oldTutorialStructure(): null="0" else: null="0.org" self.fileName=path.join(simpleBikeTutorial(),null,"U")
def dieselAachenTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"combustion") return path.join(prefix,"dieselFoam","aachenBomb")
def __init__(self, sol, correctors, tolerance, relTol, pRefValue=None, pRefCell=None, removeLibs=False, removeFunctions=False): self.solution = ParsedParameterFile(path.join(sol.systemDir(), "fvSolution"), backup=True) self.schemes = ParsedParameterFile(path.join(sol.systemDir(), "fvSchemes"), backup=True) self.control = ParsedParameterFile(path.join(sol.systemDir(), "controlDict"), backup=True) self.controlOrig = ParsedParameterFile(path.join( sol.systemDir(), "controlDict"), backup=False) pre = environ["FOAM_TUTORIALS"] if not oldTutorialStructure(): pre = path.join(pre, "basic") pot = SolutionDirectory(path.join(pre, "potentialFoam", "cylinder"), archive=None, paraviewLink=False) self.fresh = True try: if "SIMPLE" not in self.solution and foamVersion()[0] < 2: self.solution["SIMPLE"] = ParsedParameterFile( path.join(pot.systemDir(), "fvSolution"), backup=False)["SIMPLE"] if foamVersion()[0] < 2: solutionBlock = self.solution["SIMPLE"] else: self.solution["potentialFlow"] = {} solutionBlock = self.solution["potentialFlow"] if "nNonOrthogonalCorrectors" not in solutionBlock and correctors == None: correctors = 3 warning("Setting number of correctors to default value", correctors) if correctors != None: solutionBlock["nNonOrthogonalCorrectors"] = correctors if pRefCell != None: solutionBlock["pRefCell"] = pRefCell if pRefValue != None: solutionBlock["pRefValue"] = pRefValue if tolerance != None: try: self.solution["solvers"]["p"][1]["tolerance"] = tolerance except KeyError: # 1.6 format self.solution["solvers"]["p"]["tolerance"] = tolerance if relTol != None: try: self.solution["solvers"]["p"][1]["relTol"] = relTol except KeyError: # 1.6 format self.solution["solvers"]["p"]["relTol"] = relTol self.schemes.content = ParsedParameterFile(path.join( pot.systemDir(), "fvSchemes"), backup=False).content self.control.content = ParsedParameterFile(path.join( pot.systemDir(), "controlDict"), backup=False).content for k in ["functions", "libs"]: if k in self.control: print_("Remove", k, "from controlDict") del self.control[k] if "functions" in self.controlOrig and not removeFunctions: print_("Copying functions over") self.control["functions"] = self.controlOrig["functions"] if "libs" in self.controlOrig and not removeLibs: print_("Copying libs over") self.control["libs"] = self.controlOrig["libs"] self.solution.writeFile() self.schemes.writeFile() self.control.writeFile() except Exception: e = sys.exc_info()[ 1] # Needed because python 2.5 does not support 'as e' warning("Restoring defaults") self.solution.restore() self.schemes.restore() self.control.restore() raise e
def buoyHotRoomTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"heatTransfer") return path.join(prefix,"buoyantSimpleFoam","hotRoom")
def setUp(self): if oldTutorialStructure(): null = "0" else: null = "0.org" self.fileName = path.join(simpleBikeTutorial(), null, "U")
def plateHoleTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"stressAnalysis") return path.join(prefix,"solidDisplacementFoam","plateHole")
def simplePitzTutorial(): prefix=foamTutorials() if not oldTutorialStructure(): prefix=path.join(prefix,"incompressible") return path.join(prefix,"simpleFoam","pitzDaily")
def plateHoleTutorial(): prefix = foamTutorials() if not oldTutorialStructure(): prefix = path.join(prefix, "stressAnalysis") return path.join(prefix, "solidDisplacementFoam", "plateHole")
def __init__(self, sol, correctors, tolerance, relTol, pRefValue=None, pRefCell=None, removeLibs=False, removeFunctions=False): self.solution=ParsedParameterFile(path.join(sol.systemDir(),"fvSolution"),backup=True) self.schemes=ParsedParameterFile(path.join(sol.systemDir(),"fvSchemes"),backup=True) self.control=ParsedParameterFile(path.join(sol.systemDir(),"controlDict"),backup=True) self.controlOrig=ParsedParameterFile(path.join(sol.systemDir(),"controlDict"),backup=False) pre=environ["FOAM_TUTORIALS"] if not oldTutorialStructure(): pre=path.join(pre,"basic") pot=SolutionDirectory(path.join(pre,"potentialFoam","cylinder"),archive=None,paraviewLink=False) self.fresh=True try: if "SIMPLE" not in self.solution and foamVersion()[0]<2: self.solution["SIMPLE"]=ParsedParameterFile(path.join(pot.systemDir(),"fvSolution"),backup=False)["SIMPLE"] if foamVersion()[0]<2: solutionBlock=self.solution["SIMPLE"] else: self.solution["potentialFlow"]={} solutionBlock=self.solution["potentialFlow"] if "nNonOrthogonalCorrectors" not in solutionBlock and correctors==None: correctors=3 warning("Setting number of correctors to default value",correctors) if correctors!=None: solutionBlock["nNonOrthogonalCorrectors"]=correctors if pRefCell!=None: solutionBlock["pRefCell"]=pRefCell if pRefValue!=None: solutionBlock["pRefValue"]=pRefValue if tolerance!=None: try: self.solution["solvers"]["p"][1]["tolerance"]=tolerance except KeyError: # 1.6 format self.solution["solvers"]["p"]["tolerance"]=tolerance if relTol!=None: try: self.solution["solvers"]["p"][1]["relTol"]=relTol except KeyError: # 1.6 format self.solution["solvers"]["p"]["relTol"]=relTol self.schemes.content=ParsedParameterFile(path.join(pot.systemDir(),"fvSchemes"),backup=False).content self.control.content=ParsedParameterFile(path.join(pot.systemDir(),"controlDict"),backup=False).content for k in ["functions","libs"]: if k in self.control: print_("Remove",k,"from controlDict") del self.control[k] if "functions" in self.controlOrig and not removeFunctions: print_("Copying functions over") self.control["functions"]=self.controlOrig["functions"] if "libs" in self.controlOrig and not removeLibs: print_("Copying libs over") self.control["libs"]=self.controlOrig["libs"] self.solution.writeFile() self.schemes.writeFile() self.control.writeFile() except Exception: e = sys.exc_info()[1] # Needed because python 2.5 does not support 'as e' warning("Restoring defaults") self.solution.restore() self.schemes.restore() self.control.restore() raise e