当前位置: 首页>>代码示例>>Python>>正文


Python SolutionDirectory.systemDir方法代码示例

本文整理汇总了Python中PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory.systemDir方法的典型用法代码示例。如果您正苦于以下问题:Python SolutionDirectory.systemDir方法的具体用法?Python SolutionDirectory.systemDir怎么用?Python SolutionDirectory.systemDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory的用法示例。


在下文中一共展示了SolutionDirectory.systemDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import systemDir [as 别名]
    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
开发者ID:floli,项目名称:tools,代码行数:62,代码来源:PotentialRunner.py

示例2: doRegion

# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import systemDir [as 别名]

#.........这里部分代码省略.........
        if self.opts.processorMatrix:
            print_(ReST.heading("Processor matrix"))

            if sol.nrProcs()<2:
                print_("This case is not decomposed")
            else:
                matrix=[ [0,]*sol.nrProcs() for i in range(sol.nrProcs())]

                for i,p in enumerate(sol.processorDirs()):
                    try:
                        bound=ParsedBoundaryDict(sol.boundaryDict(processor=p,
                                                                  region=theRegion,
                                                                  time=self.opts.time)
                                                 ,treatBinaryAsASCII=self.opts.treatBinaryAsASCII)
                    except IOError:
                        bound=ParsedBoundaryDict(sol.boundaryDict(processor=p,
                                                                  treatBinaryAsASCII=self.opts.treatBinaryAsASCII,
                                                                  region=theRegion)
                                                 ,treatBinaryAsASCII=self.opts.treatBinaryAsASCII)

                    for j in range(sol.nrProcs()):
                        name="procBoundary%dto%d" %(j,i)
                        name2="procBoundary%dto%d" %(i,j)
                        if name in bound:
                            matrix[i][j]=bound[name]["nFaces"]
                        if name2 in bound:
                            matrix[i][j]=bound[name2]["nFaces"]

                print_("Matrix of processor interactions (faces)")
                print_()

                tab=ReST.table()
                tab[0]=["CPU"]+list(range(sol.nrProcs()))
                tab.addLine(head=True)

                for i,col in enumerate(matrix):
                    tab[i+1]=[i]+matrix[i]

                print_(tab)

        if self.opts.linearSolvers:
            print_(ReST.heading("Linear Solvers"))

            linTable=ReST.table()

            fvSol=ParsedParameterFile(path.join(sol.systemDir(),"fvSolution"),
                                      treatBinaryAsASCII=self.opts.treatBinaryAsASCII)
            allInfo={}
            for sName in fvSol["solvers"]:
                raw=fvSol["solvers"][sName]
                info={}
                if type(raw) in [dict,DictProxy]:
                    # fvSolution format in 1.7
                    info["solver"]=raw["solver"]
                    solverData=raw
                else:
                    info["solver"]=raw[0]
                    solverData=raw[1]

                if type(solverData) in [dict,DictProxy]:
                    try:
                        info["tolerance"]=solverData["tolerance"]
                    except KeyError:
                        info["tolerance"]=1.
                    try:
                        info["relTol"]=solverData["relTol"]
                    except KeyError:
                        info["relTol"]=0.
                else:
                    # the old (pre-1.5) fvSolution-format
                    info["tolerance"]=solverData
                    info["relTol"]=raw[2]

                allInfo[sName]=info

            linTable[0]=["Name","Solver","Abs. Tolerance","Relative Tol."]
            linTable.addLine(head=True)

            nr=0
            for n,i in iteritems(allInfo):
                nr+=1
                linTable[nr]=(n,i["solver"],i["tolerance"],i["relTol"])
            print_(linTable)

        if self.opts.relaxationFactors:
            print_(ReST.heading("Relaxation"))

            fvSol=ParsedParameterFile(path.join(sol.systemDir(),"fvSolution"),
                                      treatBinaryAsASCII=self.opts.treatBinaryAsASCII)
            if "relaxationFactors" in fvSol:
                tab=ReST.table()
                tab[0]=["Name","Factor"]
                tab.addLine(head=True)
                nr=0
                for n,f in iteritems(fvSol["relaxationFactors"]):
                    nr+=1
                    tab[nr]=[n,f]
                print_(tab)
            else:
                print_("No relaxation factors defined for this case")
开发者ID:martinep,项目名称:foam-extend-svn,代码行数:104,代码来源:CaseReport.py

示例3: __init__

# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import systemDir [as 别名]
    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
开发者ID:martinep,项目名称:foam-extend-svn,代码行数:82,代码来源:PotentialRunner.py


注:本文中的PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory.systemDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。