cape.cfdx.case: Generic case control¶
This module contains templates for interacting with individual cases. Since this is one of the most highly customized modules of the Cape system, there are few functions here, and the functions that are present are mostly templates.
In general, the case module is used for actually running the CFD solver
(and any additional binaries that may be required as part of the run process),
and it contains other capabilities for renaming files and determining the
settings for a particular case. Cape saves many settings for the CFD solver
and archiving in a file called case.json within each case folder, which
prevents changes to the master JSON file from unpredictably affecting cases
that have already been initialized or are already running.
Actual functionality is left to individual modules listed below.
Several of the key methods for this API module are described below.
- cape.cfdx.case.CaseAFLR3(rc, proj='Components', fmt='lb8.ugrid', n=0)¶
Create volume mesh using
aflr3This function looks for several files to determine the most appropriate actions to take, replacing
Componentswith the value from proj for each file name andlb8.ugridwith the value from fmt:Components.i.tri: Triangulation fileComponents.surf: AFLR3 surface fileComponents.aflr3bc: AFLR3 boundary conditionsComponents.xml: Surface component ID mapping fileComponents.lb8.ugrid: Output volume meshComponents.FAIL.surf: AFLR3 surface indicating failure
If the volume grid file already exists, this function takes no action. If the
surffile does not exist, the function attempts to create it by reading thetri,xml, andaflr3bcfiles usingcape.tri.Tri. The function then callscape.bin.aflr3()and finally checks for theFAILfile.- Call:
>>> CaseAFLR3(rc, proj="Components", fmt='lb8.ugrid', n=0)
- Inputs:
- rc:
cape.options.runControl.RunControl Case options interface from
case.json- proj: {
"Components"} |str Project root name
- fmt: {
"b8.ugrid"} |str AFLR3 volume mesh format
- n:
int Iteration number
- rc:
- Versions:
2016-04-05
@ddalle: Version 1.0
- cape.cfdx.case.CaseIntersect(rc, proj='Components', n=0, fpre='run')¶
Run
intersectto combine geometries if appropriateThis is a multistep process in order to preserve all the component IDs of the input triangulations. Normally
intersectrequires each intersecting component to have a single component ID, and each component must be a water-tight surface.Cape utilizes two input files,
Components.c.tri, which is the original triangulation file with intersections and the original component IDs, andComponents.tri, which maps each individual originaltrifile to a single component. The files involved are tabulated below.Components.tri: Intersecting components, each with own compIDComponents.c.tri: Intersecting triangulation, original compIDsComponents.o.tri: Output ofintersect, only a few compIDsComponents.i.tri: Original compIDs mapped to intersected tris
More specifically, these files are
"%s.i.tri" % proj, etc.; the default project name is"Components". This function also calls the Chimera Grid Tools programtrigedto remove unused nodes from the intersected triangulation and optionally remove small triangles.- Call:
>>> CaseIntersect(rc, proj='Components', n=0, fpre='run')
- Inputs:
- rc:
cape.options.runControl.RunControl Case options interface from
case.json- proj: {
'Components'} |str Project root name
- n:
int Iteration number
- fpre: {
'run'} |str Standard output file name prefix
- rc:
- See also:
cape.bin.intersect()
- Versions:
2015-09-07
@ddalle: Split fromrun_flowCart()2016-04-05
@ddalle: Generalized tocape
- cape.cfdx.case.CaseVerify(rc, proj='Components', n=0, fpre='run')¶
Run
verifyto check triangulation if appropriateThis function checks the validity of triangulation in file
"%s.i.tri" % proj. It callscape.bin.verify().- Call:
>>> CaseVerify(rc, proj='Components', n=0, fpre='run')
- Inputs:
- rc:
cape.options.runControl.RunControl Case options interface from
case.json- proj: {
'Components'} |str Project root name
- n:
int Iteration number
- fpre: {
'run'} |str Standard output file name prefix
- rc:
- Versions:
2015-09-07
@ddalle: Version 1.0; fromrun_flowCart()2016-04-05
@ddalle: Version 1.1; generalize tocape
- cape.cfdx.case.GetCurrentIter()¶
Template function to report the most recent iteration
- Call:
>>> n = cape.case.GetCurrentIter()
- Outputs:
- n:
0 Most recent index, customized for each solver
- n:
- Versions:
2015-09-27
@ddalle: Version 1.0
- cape.cfdx.case.GetPhaseNumber(rc, n=None, fpre='run')¶
Determine the phase number based on results available
- Call:
>>> j = GetPhaseNumber(rc, n=None, fpre='run')
- Inputs:
- rc:
cape.options.runControl.RunControl Options interface for run control
- n:
int Iteration number
- fpre: {
"run"} |str Prefix for output files
- rc:
- Outputs:
- j:
int Most appropriate phase number for a restart
- j:
- Versions:
2014-10-02
@ddalle: Version 1.02015-10-19
@ddalle: Version 1.1; FUN3D version2016-04-14
@ddalle: Version 1.2; CAPE version
- cape.cfdx.case.GetRestartIter()¶
Get the restart iteration
This is a placeholder function and is only called in error.
- Call:
>>> cape.case.GetRestartIter()
- Raises:
- RuntimeError:
Exception Error regarding where this was called
- RuntimeError:
- Versions:
2016-04-14
@ddalle: Version 1.0
- cape.cfdx.case.GetTriqFile(proj='Components')¶
Get most recent
triqfile and its associated iterationsThis is a template version with specific implementations for each solver. The
capeversion simply returns the most recenttriqfile in the current folder with no iteration information.- Call:
>>> ftriq, n, i0, i1 = GetTriqFile(proj='Components')
- Inputs:
- proj: {
"Components"} |str File root name
- proj: {
- Outputs:
- ftriq:
str Name of most recently modified
triqfile- n: {
None} Number of iterations included
- i0: {
None} First iteration in the averaging
- i1: {
None} Last iteration in the averaging
- ftriq:
- Versions:
2016-12-19
@ddalle: Version 1.0
- cape.cfdx.case.PrepareEnvironment(rc, i=0)¶
Set environment variables, alter resource limits (
ulimit)This function relies on the system module
resource.- Call:
>>> case.PrepareEnvironment(rc, i=0)
- Inputs:
- rc:
cape.options.runControl.RunControl Options interface for run control and command-line inputs
- i:
int Phase number
- rc:
- See also:
- Versions:
2015-11-10
@ddalle: Version 1.0
- cape.cfdx.case.ReadCaseJSON(fjson='case.json')¶
Read Cape settings for local case
- Call:
>>> rc = cape.case.ReadCaseJSON()
- Inputs:
- fjson: {
"case.json"} |str Name of JSON settings file
- fjson: {
- Outputs:
- rc:
cape.options.runControl.RunControl Options interface for run control and command-line inputs
- rc:
- Versions:
2014-10-02
@ddalle: Version 1.0
- cape.cfdx.case.ReadConditions(k=None)¶
Read run matrix variable value in the current folder
- Call:
>>> conds = cape.case.ReadConditions() >>> v = cape.case.ReadConditions(k)
- Inputs:
- k:
str Name of run matrix variable/trajectory key
- k:
- Outputs:
- conds:
dict(any) Dictionary of run matrix conditions
- v:
any Run matrix conditions of key k
- conds:
- Versions:
2017-03-28
@ddalle: Version 1.0
- cape.cfdx.case.ReadStartTimeProg(fname)¶
Read the most recent start time to file
- Call:
>>> nProc, tic = ReadStartTimeProg(fname)
- Inputs:
- fname:
str Name of file containing CPU usage history
- fname:
- Outputs:
- nProc:
int Number of cores
- tic:
datetime.datetime Time at which most recent run was started
- nProc:
- Versions:
2016-08-30
@ddalle: Version 1.0
- cape.cfdx.case.SetResourceLimit(r, ulim, u, i=0, unit=1024)¶
Set resource limit for one variable
- Call:
>>> SetResourceLimit(r, ulim, u, i=0, unit=1024)
- Inputs:
- r:
int Integer code of particular limit, from
resource- ulim:
cape.options.ulimit.ulimit System resource options interface
- u:
str Name of limit to set
- i:
int Phase number
- unit:
int Multiplier, usually for a kbyte
- r:
- See also:
cape.options.ulimit
- Versions:
2016-03-13
@ddalle: Version 1.02021-10-21
@ddalle: Version 1.1; check if Windows
- cape.cfdx.case.StartCase()¶
Empty template for starting a case
The function is empty but does not raise an error
- Call:
>>> cape.case.StartCase()
- See also:
- Versions:
2015-09-27
@ddalle: Skeleton
- cape.cfdx.case.StopCase()¶
Stop a case by deleting PBS job and removing
RUNNINGfile- Call:
>>> case.StopCase()
- Versions:
2014-12-27
@ddalle: Version 1.0
- cape.cfdx.case.WriteStartTimeProg(tic, rc, i, fname, prog)¶
Write the time to file at which a program or job started
- Call:
>>> WriteStartTimeProg(tic, rc, i, fname, prog)
- 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
- prog:
str Name of program to write in history
- tic:
- Versions:
2016-08-30
@ddalle: Version 1.0
- cape.cfdx.case.WriteUserTimeProg(tic, rc, i, fname, prog)¶
Write time usage since time tic to file
- Call:
>>> toc = WriteUserTime(tic, rc, i, fname, prog)
- 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
- prog:
str Name of program to write in history
- tic:
- Outputs:
- toc:
datetime.datetime Time at which time delta was measured
- toc:
- Versions:
2015-12-09
@ddalle: Version 1.02015-12-22
@ddalle: Copied fromcape.pycart.case
- cape.cfdx.case.init_timer()¶
Mark a case as
RUNNINGand initialize a timer- Call:
>>> tic = init_timer()
- Outputs:
- tic:
datetime.datetime Time at which case was started
- tic:
- Versions:
2021-10-21
@ddalle: Version 1.0; fromrun_fun3d()
- cape.cfdx.case.read_case_json(cls=<class 'cape.cfdx.options.runControl.RunControl'>)¶
Read RunControl settings from
case.json- Call:
>>> rc = read_case_json() >>> rc = read_case_json(cls)
- Inputs:
- cls: {
RunControl} |type Class to use for output file
- cls: {
- Outputs:
- rc: cls
Case run control settings
- Versions:
2021-10-21
@ddalle: Version 1.0