本文整理汇总了Python中PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory.timeIndex方法的典型用法代码示例。如果您正苦于以下问题:Python SolutionDirectory.timeIndex方法的具体用法?Python SolutionDirectory.timeIndex怎么用?Python SolutionDirectory.timeIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory
的用法示例。
在下文中一共展示了SolutionDirectory.timeIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doRegion
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import timeIndex [as 别名]
def doRegion(self,theRegion):
ReST=RestructuredTextHelper(defaultHeading=self.opts.headingLevel)
if self.opts.allRegions:
print_(ReST.buildHeading("Region: ",theRegion,level=self.opts.headingLevel-1))
sol=SolutionDirectory(self.parser.getArgs()[0],
archive=None,
parallel=self.opts.parallel,
paraviewLink=False,
region=theRegion)
if self.opts.all:
self.opts.caseSize=True
self.opts.shortBCreport=True
self.opts.longBCreport=True
self.opts.dimensions=True
self.opts.internal=True
self.opts.linearSolvers=True
self.opts.relaxationFactors=True
self.opts.processorMatrix=True
self.opts.decomposition=True
if self.opts.time:
try:
self.opts.time=sol.timeName(sol.timeIndex(self.opts.time,minTime=True))
except IndexError:
error("The specified time",self.opts.time,"doesn't exist in the case")
print_("Using time t="+self.opts.time+"\n")
needsPolyBoundaries=False
needsInitialTime=False
if self.opts.longBCreport:
needsPolyBoundaries=True
needsInitialTime=True
if self.opts.shortBCreport:
needsPolyBoundaries=True
needsInitialTime=True
if self.opts.dimensions:
needsInitialTime=True
if self.opts.internal:
needsInitialTime=True
if self.opts.decomposition:
needsPolyBoundaries=True
defaultProc=None
if self.opts.parallel:
defaultProc=0
if needsPolyBoundaries:
proc=None
boundary=BoundaryDict(sol.name,
region=theRegion,
time=self.opts.time,
treatBinaryAsASCII=self.opts.treatBinaryAsASCII,
processor=defaultProc)
boundMaxLen=0
boundaryNames=[]
for b in boundary:
if b.find("procBoundary")!=0:
boundaryNames.append(b)
if self.opts.patches!=None:
tmp=boundaryNames
boundaryNames=[]
for b in tmp:
for p in self.opts.patches:
if fnmatch(b,p):
boundaryNames.append(b)
break
if self.opts.expatches!=None:
tmp=boundaryNames
boundaryNames=[]
for b in tmp:
keep=True
for p in self.opts.expatches:
if fnmatch(b,p):
keep=False
break
if keep:
boundaryNames.append(b)
for b in boundaryNames:
boundMaxLen=max(boundMaxLen,len(b))
boundaryNames.sort()
if self.opts.time==None:
procTime="constant"
else:
procTime=self.opts.time
if needsInitialTime:
fields={}
if self.opts.time==None:
try:
time=sol.timeName(0)
except IndexError:
#.........这里部分代码省略.........
示例2: doRegion
# 需要导入模块: from PyFoam.RunDictionary.SolutionDirectory import SolutionDirectory [as 别名]
# 或者: from PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory import timeIndex [as 别名]
def doRegion(self, theRegion):
ReST = RestructuredTextHelper(defaultHeading=self.opts.headingLevel)
if self.opts.allRegions:
print ReST.buildHeading("Region: ", theRegion, level=self.opts.headingLevel - 1)
sol = SolutionDirectory(
self.parser.getArgs()[0], archive=None, parallel=self.opts.parallel, paraviewLink=False, region=theRegion
)
if self.opts.all:
self.opts.caseSize = True
self.opts.shortBCreport = True
self.opts.longBCreport = True
self.opts.dimensions = True
self.opts.internal = True
self.opts.linearSolvers = True
self.opts.relaxationFactors = True
self.opts.processorMatrix = True
self.opts.decomposition = True
if self.opts.time:
try:
self.opts.time = sol.timeName(sol.timeIndex(self.opts.time, minTime=True))
except IndexError:
error("The specified time", self.opts.time, "doesn't exist in the case")
print "Using time t=" + self.opts.time + "\n"
needsPolyBoundaries = False
needsInitialTime = False
if self.opts.longBCreport:
needsPolyBoundaries = True
needsInitialTime = True
if self.opts.shortBCreport:
needsPolyBoundaries = True
needsInitialTime = True
if self.opts.dimensions:
needsInitialTime = True
if self.opts.internal:
needsInitialTime = True
if self.opts.decomposition:
needsPolyBoundaries = True
defaultProc = None
if self.opts.parallel:
defaultProc = 0
if needsPolyBoundaries:
proc = None
boundary = BoundaryDict(sol.name, region=theRegion, time=self.opts.time, processor=defaultProc)
boundMaxLen = 0
boundaryNames = []
for b in boundary:
if b.find("procBoundary") != 0:
boundaryNames.append(b)
if self.opts.patches != None:
tmp = boundaryNames
boundaryNames = []
for b in tmp:
for p in self.opts.patches:
if fnmatch(b, p):
boundaryNames.append(b)
break
if self.opts.expatches != None:
tmp = boundaryNames
boundaryNames = []
for b in tmp:
keep = True
for p in self.opts.expatches:
if fnmatch(b, p):
keep = False
break
if keep:
boundaryNames.append(b)
for b in boundaryNames:
boundMaxLen = max(boundMaxLen, len(b))
boundaryNames.sort()
if self.opts.time == None:
procTime = "constant"
else:
procTime = self.opts.time
if needsInitialTime:
fields = {}
if self.opts.time == None:
try:
time = sol.timeName(0)
except IndexError:
error("There is no timestep in the case")
else:
time = self.opts.time
tDir = sol[time]
#.........这里部分代码省略.........