本文整理汇总了Python中PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory.getRegions方法的典型用法代码示例。如果您正苦于以下问题:Python SolutionDirectory.getRegions方法的具体用法?Python SolutionDirectory.getRegions怎么用?Python SolutionDirectory.getRegions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory
的用法示例。
在下文中一共展示了SolutionDirectory.getRegions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
def run(self):
if self.opts.file:
sys.stdout = open(self.opts.file, "w")
if self.opts.allRegions:
sol = SolutionDirectory(
self.parser.getArgs()[0], archive=None, parallel=self.opts.parallel, paraviewLink=False
)
for r in sol.getRegions():
self.doRegion(r)
else:
self.doRegion(self.opts.region)
示例2: run
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
def run(self):
oldStdout=None
try:
if self.opts.file:
oldStdout=sys.stdout
if isinstance(self.opts.file,string_types):
sys.stdout=open(self.opts.file,"w")
else:
sys.stdout=self.opts.file
if self.opts.allRegions:
sol=SolutionDirectory(self.parser.getArgs()[0],
archive=None,
parallel=self.opts.parallel,
paraviewLink=False)
for r in sol.getRegions():
self.doRegion(r)
else:
self.doRegion(self.opts.region)
finally:
if oldStdout:
sys.stdout=oldStdout
示例3: run
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
#.........这里部分代码省略.........
error("Method",method,"not yet implementes")
gen=FoamFileGenerator(result)
if self.opts.test:
print_(str(gen))
return -1
else:
f=open(path.join(case,"system","decomposeParDict"),"w")
writeDictionaryHeader(f)
f.write(str(gen))
f.close()
if self.opts.clear:
print_("Clearing processors")
for p in glob(path.join(case,"processor*")):
print_("Removing",p)
rmtree(p,ignore_errors=True)
self.checkAndCommit(SolutionDirectory(case,archive=None))
if self.opts.doDecompose:
if self.opts.region:
regionNames=self.opts.region[:]
while True:
try:
i=regionNames.index("region0")
regionNames[i]=None
except ValueError:
break
else:
regionNames=[None]
regions=None
sol=SolutionDirectory(case)
if not decomposeParWithRegion:
if self.opts.regions or self.opts.region!=None:
print_("Building Pseudocases")
regions=RegionCases(sol,clean=True,processorDirs=False)
if self.opts.regions:
regionNames=sol.getRegions(defaultRegion=True)
for theRegion in regionNames:
theCase=path.normpath(case)
if theRegion!=None and not decomposeParWithRegion:
theCase+="."+theRegion
if oldApp():
argv=[self.opts.decomposer,".",theCase]
else:
argv=[self.opts.decomposer,"-case",theCase]
if foamVersion()>=(2,0) and not self.opts.doFunctionObjects:
argv+=["-noFunctionObjects"]
if theRegion!=None and decomposeParWithRegion:
argv+=["-region",theRegion]
f=open(path.join(case,"system",theRegion,"decomposeParDict"),"w")
writeDictionaryHeader(f)
f.write(str(gen))
f.close()
self.setLogname(default="Decomposer",useApplication=False)
run=UtilityRunner(argv=argv,
silent=self.opts.progress or self.opts.silent,
logname=self.opts.logname,
compressLog=self.opts.compress,
server=self.opts.server,
noLog=self.opts.noLog,
logTail=self.opts.logTail,
echoCommandLine=self.opts.echoCommandPrefix,
jobId=self.opts.jobId)
run.start()
if theRegion!=None and not decomposeParWithRegion:
print_("Syncing into master case")
regions.resync(theRegion)
if regions!=None and not decomposeParWithRegion:
if not self.opts.keeppseudo:
print_("Removing pseudo-regions")
regions.cleanAll()
else:
for r in sol.getRegions():
if r not in regionNames:
regions.clean(r)
if self.opts.doConstantLinks:
print_("Adding symlinks in the constant directories")
constPath=path.join(case,"constant")
for f in listdir(constPath):
srcExpr=path.join(path.pardir,path.pardir,"constant",f)
for p in range(nr):
dest=path.join(case,"processor%d"%p,"constant",f)
if not path.exists(dest):
symlink(srcExpr,dest)
self.addToCaseLog(case)
示例4: run
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
def run(self):
if self.cmdname in ["create","copy"]:
if self.cmdname=="create":
dest=self.parser.getArgs()[0]
else:
dest=self.parser.getArgs()[1]
sol=SolutionDirectory(dest,
paraviewLink=False,
archive=None)
fName=path.join(sol.name,path.basename(sol.name)+".ipynb")
if self.opts.destinationFile:
fName=self.opts.destinationFile
if path.isdir(fName):
fName=path.join(fName,path.basename(sol.name))
if path.splitext(fName)[1]!=".ipynb":
fName+=".ipynb"
if self.opts.absolutePath:
usedDest=sol.name
else:
usedDest=path.relpath(sol.name,
start=path.dirname(path.abspath(
fName)))
if path.exists(fName):
if not self.opts.forceWrite:
self.error("File",fName,"already existing")
else:
self.warning("Overwriting",fName)
nb=Notebook(name=path.basename(sol.name))
nb.pyFoamMetaData()["description"]="Created by "+self.parser.get_prog_name()
if self.cmdname=="create":
nb.addHeading("Imports and administrative stuff",
level=1,classes="heading")
if self.opts.developerMode:
nb.addMarkdown("This part only needed by developers (reload imports)",
classes=("comment","developer"))
nb.addCode("%load_ext autoreload",classes="developer")
nb.addCode("%autoreload 2",classes="developer")
nb.addMarkdown("Make sure that plots are inlined",
classes="comment")
nb.addCode("%matplotlib inline")
if self.opts.additional:
nb.addHeading("Additional imports for convenience",
level=2,classes=("heading","additional"))
nb.addMarkdown("Allow panning and zooming in plots. Slower than regular plotting so for big data you might want to use `mpld3.disable_notebook()` and erase this cell.",
classes=("comment","additional"))
nb.addCode(
"""try:
import mpld3
mpld3.enable_notebook()
except ImportError:
print 'No mpld3-library. No interactive plots'""",classes="additional")
nb.addMarkdown(
"""Wrapper with additional functionality to the regular Pandas-`DataFrame`:
* `addData()` for adding columns from other data sets (with resampling
* `integrals()` and `weightedAverage()`. Also extended `descripe()` that returns this data
Most Pandas-operations (like slicing) will return a Pandas-`DataFrame`. By enclosing this in `DataFrame(...)` you can 'add' this functionality to your data. PyFoam operations return this extended `DataFrame` automatically""",
classes=("comment","additional"))
nb.addCode("from PyFoam.Wrappers.Pandas import PyFoamDataFrame as DataFrame",classes="additional")
nb.addHeading("Data storage",
level=2,classes=("heading"))
nb.addMarkdown("This is the support for permanently storing data into the notebook",
classes="comment")
nb.addCode("from PyFoam.IPython import storage")
nb.addMarkdown("Due to technical problems the next line has to be executed 'by hand' (it will not work poperly if called from `Run All` or similar). When reopening the page the JavaScript-error is normal (it will go away once the cell is executed). Reading can take some time and the next command will appear to 'hang'",
classes="comment")
nb.addCode("store=storage()")
nb.addMarkdown("The next line switches on the behaviour that items specified with `store(name,func)` will be stored permanently in the notebook. Uncomment if you want this behaviour",
classes="comment")
nb.addCode("# store.autowriteOn()")
nb.addMarkdown("The next line switches off the default behaviour that for items specified with `store(name,func)` if `name` is already specified in the permant storage this value is used and `func` is ignored",
classes="comment")
nb.addCode("# store.autoreadOff()")
nb.addHeading("Case data",
level=2,classes=("heading"))
nb.addMarkdown("This class makes it easy to access case data. Use tab-completion for available methods",
classes="comment")
nb.addCode("from PyFoam.IPython.Case import Case")
nb.addHeading("The Case",classes="heading")
v=self.opts.caseVariable
nb.addCode("%s=Case('%s')" % (v,usedDest),classes="case",
pyFoam={"caseVar":v,"usedDirectory":usedDest,
"casePath":sol.name})
if self.opts.caseReport:
nb.addHeading("Case Report",level=2,
classes=("report","heading"))
regions=sorted(sol.getRegions(defaultRegion=True))
namedRegions=[r for r in regions if r!=None]
if len(namedRegions)>0:
nb.addMarkdown("Contains named regions *"+
", ".join(namedRegions)+"*",
classes=("info","report"))
if sol.procNr>0:
nb.addMarkdown("Case seems to be decomposed to "+
str(sol.procNr)+" processors",
classes=("info","report"))
for region in regions:
if region==None:
level=3
#.........这里部分代码省略.........
示例5: Case
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
class Case(object):
"""This class is initialized with a path and gives access to
reporting functions
"""
def __init__(self,input):
"""@param input: either a SolutionDirectory-instance or a string
with a pathname"""
if isinstance(input,SolutionDirectory):
self.__sol=input
elif isinstance(input,string_types):
self.__sol=SolutionDirectory(input,
paraviewLink=False,
archive=None)
else:
error(type(input),"not supported")
@property
def sol(self):
"""The actual solution directory"""
return self.__sol
@property
def path(self):
"""The path to the solution"""
return self.__sol.name
@property
def regions(self):
"""Regions in the case"""
return self.__sol.getRegions(defaultRegion=True)
def __callCaseReport(self,region=None,level=3,**kwargs):
"""Helper function that does the actual calling of CaseReport
and returning of the HTML-formatted output"""
s=StringIO()
if region!=None:
level=level+1
CaseReport(args=[self.path],
region=region,
file=s,
headingLevel=level,
**kwargs)
return HTML(publish_parts(s.getvalue(),
writer_name='html',
settings_overrides={
"initial_header_level":level,
"doctitle_xform":False
})['html_body'])
def size(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
caseSize=True,
**kwargs)
def boundaryConditions(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
shortBcReport=True,
**kwargs)
def longBoundaryConditions(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
longBcReport=True,
**kwargs)
def dimensions(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
dimensions=True,
**kwargs)
def internalField(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
internalField=True,
**kwargs)
def linearSolvers(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
linearSolvers=True,
**kwargs)
def relaxationFactors(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
relaxationFactors=True,
**kwargs)
def processorMatrix(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
processorMatrix=True,
**kwargs)
def decomposition(self,region=None,**kwargs):
return self.__callCaseReport(region=region,
decomposition=True,
**kwargs)
def timeline(self,directory,fieldname):
if isinstance(fieldname,string_types):
#.........这里部分代码省略.........
示例6: run
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import getRegions [as 别名]
def run(self):
if self.opts.keeppseudo and (not self.opts.regions and self.opts.region==None):
warning("Option --keep-pseudocases only makes sense for multi-region-cases")
if self.opts.region:
regionNames=self.opts.region
else:
regionNames=[None]
regions=None
casePath=self.parser.casePath()
self.checkCase(casePath)
# self.addLocalConfig(casePath)
self.addToCaseLog(casePath,"Starting")
self.prepareHooks()
if self.opts.regions or self.opts.region!=None:
print_("Building Pseudocases")
sol=SolutionDirectory(casePath,archive=None)
regions=RegionCases(sol,clean=True)
if self.opts.regions:
regionNames=sol.getRegions()
self.processPlotLineOptions(autoPath=casePath)
self.clearCase(SolutionDirectory(casePath,archive=None))
lam=self.getParallel(SolutionDirectory(casePath,archive=None))
self.checkAndCommit(SolutionDirectory(casePath,archive=None))
for theRegion in regionNames:
args=self.buildRegionArgv(casePath,theRegion)
self.setLogname()
run=AnalyzedRunner(BoundingLogAnalyzer(progress=self.opts.progress,
doFiles=self.opts.writeFiles,
singleFile=self.opts.singleDataFilesOnly,
doTimelines=True),
silent=self.opts.progress or self.opts.silent,
argv=args,
server=self.opts.server,
lam=lam,
restart=self.opts.restart,
logname=self.opts.logname,
compressLog=self.opts.compress,
logTail=self.opts.logTail,
noLog=self.opts.noLog,
remark=self.opts.remark,
parameters=self.getRunParameters(),
echoCommandLine=self.opts.echoCommandPrefix,
jobId=self.opts.jobId)
run.createPlots(customRegexp=self.lines_,
writeFiles=self.opts.writeFiles)
self.addWriteAllTrigger(run,SolutionDirectory(casePath,archive=None))
self.addLibFunctionTrigger(run,SolutionDirectory(casePath,archive=None))
self.runPreHooks()
run.start()
if len(regionNames)>1:
self.setData({theRegion:run.data})
else:
self.setData(run.data)
self.runPostHooks()
self.reportUsage(run)
self.reportRunnerData(run)
if theRegion!=None:
print_("Syncing into master case")
regions.resync(theRegion)
if regions!=None:
if not self.opts.keeppseudo:
print_("Removing pseudo-regions")
regions.cleanAll()
else:
for r in sol.getRegions():
if r not in regionNames:
regions.clean(r)
self.addToCaseLog(casePath,"Ended")