cape.pyfun.case
: FUN3D case control module¶
This module contains the important function case.run_fun3d()
,
which actually runs nodet
or nodet_mpi
, along with the utilities
that support it.
It also contains FUN3D-specific versions of some of the generic methods
from cape.case
. For instance the function GetCurrentIter()
determines how many FUN3D iterations have been run in the current
folder, which is obviously a solver-specific task. It also contains the
function LinkPLT()
, which creates links to fixed Tecplot file
names from the most recent output created by FUN3D.
All of the functions from cape.case
are imported here. Thus they
are available unless specifically overwritten by specific
cape.pyfun
versions.
- cape.pyfun.case.CheckSuccess(rc=None, i=None)¶
Check for errors before continuing
Currently the following checks are performed.
Check for NaN residual in the output file
- Call:
>>> CheckSuccess(rc=None, i=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface from
case.json
- i:
int
Phase number
- rc:
- Outputs:
- q:
bool
Whether or not the case ran successfully
- q:
- Versions:
2016-04-18
@ddalle
: v1.02023-10-18
@ddalle
: v1.1; check for nan files i/o STDOUT
- cape.pyfun.case.CopyHist(nml, i)¶
Copy all force and moment histories along with residual history
- Call:
>>> CopyHist(nml, i)
- Inputs:
- nml:
cape.pyfun.namelist.Namelist
Fun3D namelist interface for phase i
- i:
int
Phase number to use for storing histories
- nml:
- Versions:
2016-10-28
@ddalle
: v1.0
- cape.pyfun.case.FinalizeFiles(rc, i=None)¶
Clean up files after running one cycle of phase i
- Call:
>>> FinalizeFiles(rc, i=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface from
case.json
- i:
int
Phase number
- rc:
- Versions:
2016-04-14
@ddalle
: v1.0
- cape.pyfun.case.GetCurrentIter()¶
Get the most recent iteration number
- Call:
>>> n = case.GetHistoryIter()
- Outputs:
- n:
int
|None
Last iteration number
- n:
- Versions:
2015-10-19
@ddalle
: v1.02016-04-28
@ddalle
: v1.1;Flow/
folder
- cape.pyfun.case.GetFromGlob(fglb, fname=None)¶
Find the most recently edited file matching a glob
- Call:
>>> fname = case.GetFromGlob(fglb, fname=None) >>> fname = case.GetFromGlob(fglbs, fname=None)
- Inputs:
- fglb:
str
Glob for targeted file names
- fglbs:
list
[str
] Multiple glob file name patterns
- fname: {
None
} |str
Optional alternate file name to consider
- fglb:
- Outputs:
- fbest:
str
Name of file matching glob that was most recently modified
- fbest:
- Versions:
2016-12-19
@ddalle
: v1.02023-02-03
@ddalle
: v1.1; add fname input2023-03-26
@ddalle
: v1.2; multiple fglbs
- cape.pyfun.case.GetHistoryIter()¶
Get the most recent iteration number for a history file
- Call:
>>> nh, n = case.GetHistoryIter()
- Outputs:
- nh:
int
Iterations from previous cases before Fun3D deleted history
- n:
int
|None
Most recent iteration number
- nh:
- Versions:
2015-10-20
@ddalle
: v1.02016-04-28
@ddalle
: Accounting forFlow/
folder2016-10-29
@ddalle
: Handling Fun3D’s iteration reset2017-02-23
@ddalle
: Handling for adaptive
- cape.pyfun.case.GetHistoryIterFile(fname)¶
Get the most recent iteration number from a history file
- Call:
>>> n = case.GetHistoryIterFile(fname)
- Inputs:
- fname: {
"pyfun_hist.dat"
} |str
Name of file to read
- fname: {
- Outputs:
- n:
int
|None
Most recent iteration number
- n:
- Versions:
2016-05-04
@ddalle
: Extracted fromGetHistoryIter()
- cape.pyfun.case.GetNamelist(rc=None, i=None)¶
Read case namelist file
- Call:
>>> nml = case.GetNamelist(rc=None, i=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Run control options
- i:
int
Phase number
- rc:
- Outputs:
- nml:
cape.pyfun.namelist.Namelist
Namelist interface
- nml:
- Versions:
2015-10-19
@ddalle
: v1.0
- cape.pyfun.case.GetPBSScript(i=None)¶
Determine the file name of the PBS script to call
This is a compatibility function for cases that do or do not have multiple PBS scripts in a single run directory
- Call:
>>> fpbs = case.GetPBSScript(i=None)
- Inputs:
- i:
int
Run index
- i:
- Outputs:
- fpbs:
str
Name of PBS script to call
- fpbs:
- Versions:
2014-12-01
@ddalle
: v1.02015-10-19
@ddalle
: FUN3D version
- cape.pyfun.case.GetPhaseNumber(rc)¶
Determine the phase number based on files in folder
- Call:
>>> i = case.GetPhaseNumber(rc)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface for run control
- rc:
- Outputs:
- i:
int
Most appropriate phase number for a restart
- i:
- Versions:
2014-10-02
@ddalle
: v1.02015-10-19
@ddalle
: FUN3D version
- cape.pyfun.case.GetPltFile()¶
Get most recent boundary
plt
file and its associated iterations- Call:
>>> fplt, n, i0, i1 = GetPltFile()
- Outputs:
- fplt:
str
Name of
plt
file- n:
int
Number of iterations included
- i0:
int
First iteration in the averaging
- i1:
int
Last iteration in the averaging
- fplt:
- Versions:
2016-12-20
@ddalle
: v1.0
- cape.pyfun.case.GetProjectRootname(rc=None, i=None, nml=None)¶
Read namelist and return project namelist
- Call:
>>> rname = case.GetProjectRootname() >>> rname = case.GetProjectRootname(rc=None, i=None, nml=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Run control options
- i:
int
Phase number
- nml:
cape.pyfun.namelist.Namelist
Namelist interface; overrides rc and i if used
- rc:
- Outputs:
- rname:
str
Project rootname
- rname:
- Versions:
2015-10-19
@ddalle
: v1.0
- cape.pyfun.case.GetRestartIter()¶
Get total iteration number of most recent flow file
This function works by checking FUN3D output files for particular lines of text. If the
fun3d.out
file exists, only that file is checked. Otherwise, all files matchingrun.[0-9]*.[0-9]*
are checked.The lines in the FUN3D output file that report each new restart file have the following format.
inserting previous and current history iterations 300 + 80 = 380
- Call:
>>> n = GetRestartIter()
- Outputs:
- n:
int
Index of most recent check file
- n:
- Versions:
2015-10-19
@ddalle
: v1.02016-04-19
@ddalle
: Checks STDIO file for iteration number2020-01-15
@ddalle
: Proper glob sorting order
- cape.pyfun.case.GetRunningIter()¶
Get the most recent iteration number for a running file
- Call:
>>> n = case.GetRunningIter()
- Outputs:
- n:
int
|None
Most recent iteration number
- n:
- Versions:
2015-10-19
@ddalle
: v1.02016-04-28
@ddalle
: Now handlesFlow/
folder
- cape.pyfun.case.LinkFromGlob(fname, fglb)¶
Link the most recent file to a generic Tecplot file name
- Call:
>>> case.LinkFromGlob(fname, fglb) >>> case.LinkFromGlob(fname, fglbs)
- Inputs:
- fname:
str
Name of unmarked file, like
Components.i.plt
- fglb:
str
Glob for marked file names
- fglbs:
list
[str
] Multiple glob file name patterns
- fname:
- Versions:
2016-10-24
@ddalle
: v1.02023-03-26
@ddalle
: v1.1; multiple fglbs
- cape.pyfun.case.LinkPLT()¶
Link the most recent Tecplot files to fixed file names
- Call:
>>> case.LinkPLT()
- Versions:
2016-10-24
@ddalle
: v1.0
- cape.pyfun.case.PrepareFiles(rc, i=None)¶
Prepare file names appropriate to run phase i of FUN3D
- Call:
>>> PrepareFiles(rc, i=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface from
case.json
- i:
int
Phase number
- rc:
- Versions:
2016-04-14
@ddalle
: v1.0
- cape.pyfun.case.PrepareWarmStart(rc, nml)¶
Process WarmStart settings and copy files if appropriate
- Call:
>>> warmstart = PrepareWarmStart(rc, nml)
- Inputs:
- rc:
RunControlOpts
RunControl options from
case.json
- nml:
Fun3DNamelist
Namelist interface
- rc:
- Outputs:
- warmstart:
True
|False
Whether or not case is a valid warm-start
- warmstart:
- Versions:
2023-03-14
@ddalle
: v1.0
- cape.pyfun.case.ReadCaseJSON()¶
Read RunControl settings for local case
- Call:
>>> rc = case.ReadCaseJSON()
- Outputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface for run control settings
- rc:
- Versions:
2014-10-02
@ddalle
: v1.02015-10-19
@ddalle
: FUN3D version
- cape.pyfun.case.RestartCase(i0=None)¶
Restart a case by either submitting it or calling with a system command
This version of the command is called within
run_fun3d()
after running a phase or attempting to run a phase.- Call:
>>> case.RestartCase(i0=None)
- Inputs:
- i0:
int
|None
Run sequence index of the previous run
- i0:
- Versions:
2015-12-30
@ddalle
: Split from pyCart
- cape.pyfun.case.RunPhase(rc, i)¶
Run one phase using appropriate commands
- Call:
>>> RunPhase(rc, i)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Options interface from
case.json
- i:
int
Phase number
- rc:
- Versions:
2016-04-13
@ddalle
: v1.0
- cape.pyfun.case.SetRestartIter(rc, n=None)¶
Set a given check file as the restart point
- Call:
>>> case.SetRestartIter(rc, n=None)
- Inputs:
- rc:
cape.pyfun.options.runControl.RunControl
Run control options
- n:
int
Restart iteration number, defaults to most recent available
- rc:
- Versions:
2014-10-02
@ddalle
: v1.02023-03-14
@ddalle
: v1.1; add WarmStart
- cape.pyfun.case.StartCase()¶
Start a case by either submitting it or calling locally
- Call:
>>> case.StartCase()
- Versions:
2014-10-06
@ddalle
: v1.02015-10-19
@ddalle
: Copied fromcape.pycart
- cape.pyfun.case.WriteStartTime(tic, rc, i, fname='pyfun_start.dat')¶
Write the start time in tic
- Call:
>>> WriteStartTime(tic, rc, i, fname="pyfun_start.dat")
- Inputs:
- tic:
datetime.datetime
Time to write into data file
- rc:
pyOver.options.runControl.RunControl
Options interface
- i:
int
Phase number
- fname: {
"pyfun_start.dat"
} |str
Name of file containing run start times
- tic:
- Versions:
2016-08-31
@ddalle
: v1.0
- cape.pyfun.case.WriteUserTime(tic, rc, i, fname='pyfun_time.dat')¶
Write time usage since time tic to file
- Call:
>>> toc = WriteUserTime(tic, rc, i, fname="pyfun_time.dat")
- Inputs:
- tic:
datetime.datetime
Time from which timer will be measured
- rc:
pyCart.options.runControl.RunControl
Options interface
- i:
int
Phase number
- fname:
str
Name of file containing CPU usage history
- tic:
- Outputs:
- toc:
datetime.datetime
Time at which time delta was measured
- toc:
- Versions:
2015-12-09
@ddalle
: v1.0
- cape.pyfun.case.run_fun3d()¶
Setup and run the appropriate FUN3D command
- Call:
>>> case.run_fun3d()
- Versions:
2015-10-19
@ddalle
: v1.02016-04-05
@ddalle
: Added AFLR3 to this function