cape.pyfun.cntl: FUN3D control module¶
This module provides tools to quickly setup basic or complex FUN3D run matrices and serve as an executive for pre-processing, running, post-processing, and managing the solutions. A collection of cases combined into a run matrix can be loaded using the following commands.
>>> import cape.pyfun.cntl >>> cntl = cape.pyfun.cntl.Cntl("pyFun.json") >>> cntl <cape.pyfun.Cntl(nCase=892)> >>> cntl.x.GetFullFolderNames(0) 'poweroff/m1.5a0.0b0.0'
An instance of this cape.pyfun.cntl.Cntl class has many
attributes, which include the run matrix (cntl.x), the options
interface (cntl.opts), and optionally the data book
(cntl.DataBook), the appropriate input files (such as
cntl.Namelist), and possibly others.
Attribute
Class
cntl.x
cape.pyfun.runmatrix.RunMatrixcntl.opts
cntl.tri
cape.pyfun.trifile.Tricntl.DataBook
cntl.Namelist
Finally, the cape.pyfun.cntl.Cntl class is subclassed from the
cape.cfdx.cntl.Cntl class, so any methods available to the CAPE
class are also available here.
- class cape.pyfun.cntl.Cntl(fname=None)¶
Class for handling global options and setup for FUN3D
This class is intended to handle all settings used to describe a group of FUN3D cases. For situations where it is not sufficiently customized, it can be used partially, e.g., to set up a Mach/alpha sweep for each single control variable setting.
The settings are read from a JSON file, which is robust and simple to read, but has the disadvantage that there is no support for comments. Hopefully the various names are descriptive enough not to require explanation.
Defaults are read from the file
options/pyFun.default.json.- Call:
>>> cntl = pyFun.Cntl(fname="pyFun.json")
- Inputs:
- fname:
str Name of pyFun input file
- fname:
- Outputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the pyFun control class
- cntl:
- Data members:
- Versions:
2015-10-16
@ddalle: v1.0
- ApplyCase(i: int, nPhase=None, **kw)¶
Apply settings from cntl.opts to an individual case
This rewrites each run namelist file and the
case.jsonfile in the specified directories.- Call:
>>> cntl.ApplyCase(i, nPhase=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D control interface
- i:
int Case number
- nPhase: {
None} | positiveint Last phase number (default determined by PhaseSequence)
- cntl:
- Versions:
2016-03-31
@ddalle: v1.0
- CheckError(i)¶
Check if a case has a failure
- Call:
>>> q = cntl.CheckError(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D control interface
- i:
int Run index
- cntl:
- Outputs:
- q:
bool If
True, case hasFAILfile in it
- q:
- Versions:
2015-01-02
@ddalle: v1.0- 2017-04-06
@ddalle: Checking for nan_locations*.dat
- 2017-04-06
- CheckMesh(i)¶
Check if the mesh for case i is prepared
- Call:
>>> q = cntl.CheckMesh(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Index of the case to check
- cntl:
- Outputs:
- q:
bool Whether or not the mesh for case i is prepared
- q:
- Versions:
2015-10-19
@ddalle: v1.0
- CheckMeshFiles(v=False)¶
Check for the mesh files in the present folder
- Call:
>>> q = cntl.CheckMeshFiles(v=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- v:
True| {False} Verbose flag
- cntl:
- Outputs:
- q:
bool Whether or not the present folder has the required mesh files
- q:
- Versions:
2016-04-11
@ddalle: v1.02017-02-22
@ddalle: Added verbose option
- CheckNone(v=False)¶
Check if the current folder has the necessary files to run
- Call:
>>> q = cntl.CheckNone(v=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- v:
True| {False} Verbosity option
- cntl:
- Outputs:
- q:
True|False Whether or not the case is not set up to run
- q:
- Versions:
2015-10-19
@ddalle: v1.0- 2016-04-11
@ddalle: Checking for AFLR3 input files, too
- 2016-04-11
- 2016-04-29
@ddalle: Simpler version that handles Flow/
- 2016-04-29
2017-02-22
@ddalle: Added verbose option
- CompID2SurfID(compID)¶
Convert triangulation component ID to surface index
This relies on an XML configuration file and a FUN3D
mapbcfile- Call:
>>> surfID = cntl.CompID2SurfID(compID) >>> surfID = cntl.CompID2SurfID(face) >>> surfID = cntl.CompID2SurfID(comps)
- Inputs:
- Outputs:
- Versions:
2016-04-27
@ddalle: v1.0
- EvalSurfID(comp)¶
Convert a component name to a MapBC surface index (1-based)
This function also works if the input, comp, is an integer (returns the same integer) or an integer string such as
"1". Before looking up an index by name, the function attempts to returnint(comp).- Call:
>>> surfID = cntl.EvalSurfID(comp)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- comp:
str|int Component name or surface index (1-based)
- cntl:
- Outputs:
- surfID:
int Surface index (1-based) according to cntl.MapBC
- surfID:
- Versions:
2017-02-23
@ddalle: v1.0
- GetConfigInput(comp, warn=False)¶
Determine which component indices are in a named component based on the MapBC file, which is always numbered 1,2,…,N. Output the format as a nice string, such as
"4-10,13,15-18".If possible, this is read from the
"Inputs"subsection of the"Config"section of the master JSON file. Otherwise, it is read from the"mapbc"and configuration files.- Call:
>>> cntl.GetConfigInput(comp, warn=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- comp:
str Name of component to process
- warn:
True| {False} Whether or not to print warnings if not raising errors
- cntl:
- Outputs:
- inp:
str String describing list of integers included
- inp:
- Versions:
2016-10-21
@ddalle: v1.0
- GetGridFormat(j=0)¶
Get the grid format
The JSON file overrides the value from the namelist file
- Call:
>>> fmt = cntl.GetGridFormat(j=0)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- j:
int Run sequence index
- cntl:
- Outputs:
- fmt:
str Project root name
- fmt:
- Versions:
2015-10-18
@ddalle: v1.0
- GetNamelistVar(sec, key, j=0)¶
Get a namelist variable’s value
The JSON file overrides the value from the namelist file
- Call:
>>> val = cntl.GetNamelistVar(sec, key, j=0)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- sec:
str Name of namelist section
- key:
str Variable to read
- j:
int Run sequence index
- cntl:
- Outputs:
- val:
int`|:class:`float`|:class:`str`|:class:`list Value
- val:
- Versions:
2015-10-19
@ddalle: v1.0
- GetProjectRootName(j: int = 0) str¶
Get the project root name
The JSON file overrides the value from the namelist file if appropriate
- Call:
>>> name = cntl.GetProjectName(j=0)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- j:
int Phase number
- cntl:
- Outputs:
- name:
str Project root name
- name:
- Versions:
2015-10-18
@ddalle: v1.02023-06-15
@ddalle: v1.1; cleaner logic
- GetSurfBCFlowInitState(key, i, CT=False, comp=None)¶
Get nondimensional state for flow initialization volumes
- Call:
>>> rho, U, c = cntl.GetSurfBCFlowInitState(key, i, CT=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- key:
str Name of SurfBC key to process
- i:
int Case index
- CT:
True| {False} Whether this key has thrust as input (else p0, T0 directly)
- comp: {
None} |str Name of component for which to get BCs
- cntl:
- Outputs:
- Versions:
2016-03-29
@ddalle: v1.02016-04-13
@ddalle: Added CT/BC capability
- GetSurfBCState(key, i, comp=None)¶
Get stagnation pressure and temperature ratios
- Call:
>>> p0, T0 = cntl.GetSurfBCState(key, i, comp=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- key:
str Name of key to process
- i:
int Case index
- comp: {
None} |str Name of component for which to get BCs
- cntl:
- Outputs:
- Versions:
2016-03-29
@ddalle: v1.0
- GetSurfBCVolume(key, compID)¶
Get coordinates for flow initialization box
- Call:
>>> x1, x2, r = cntl.GetSurfBCVolume(key, compID)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- key:
str Name of SurfBC key to process
- compID:
int Component ID for which to calculate flow volume
- cntl:
- Outputs:
- x1:
np.ndarray[float] First point of cylinder center line
- x2:
np.ndarray[float] End point of cylinder center line
- r:
float Radius of cylinder
- x1:
- Versions:
2016-03-29
@ddalle: v1.0
- GetSurfCTState(key, i, comp=None)¶
Get stagnation pressure and temperature ratios for SurfCT key
- Call:
>>> p0, T0 = cntl.GetSurfCTState(key, i, comp=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- key:
str Name of key to process
- i:
int Case index
- comp: {
None} |str Name of component for which to get BCs
- cntl:
- Outputs:
- Versions:
2016-04-13
@ddalle: v1.0
- NamelistFunction(i)¶
Apply a function at the end of
PrepareNamelist(i)()This is allows the user to modify settings at a later point than is done using
CaseFunction()This calls the function(s) in the global
"NamelistFunction"option from the JSON file. These functions must take cntl as an input and the case number i. The function(s) are usually from a module imported via the"Modules"option. See the following example:"Modules": ["testmod"], "NamelistFunction": ["testmod.nmlfunc"]
This leads pyFun to call
testmod.nmlfunc(cntl, i)near the end ofPrepareNamelist()for each case i in the run matrix.- Call:
>>> cntl.NamelistFunction(i)
- Inputs:
- Versions:
2017-06-07
@ddalle: v1.02022-04-13
@ddalle: v2.0; exec_modfunction()
- See also:
- PrepareCase(i: int)¶
Prepare a case for running if it is not already prepared
- Call:
>>> cntl.PrepareCase(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Index of case to prepare/analyze
- cntl:
- Versions:
2015-10-19
@ddalle: v1.0
- PrepareFAUXGeom(i)¶
Prepare/edit a FAUXGeom input file for a case
- Call:
>>> cntl.PrepareFAUXGeom(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2017-02-23
@ddalle: v1.0
- PrepareFreezeSurfs(i: int)¶
Prepare adaption file for list of surfaces to freeze during adapts
- Call:
>>> cntl.PrepareFreezeSurfs(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2017-02-23
@ddalle: v1.0
- PrepareKineticData(i)¶
Prepare/edit a
kineticdatainput file for a case- Call:
>>> cntl.PrepareKineticData(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2018-04-19
@ddalle: v1.0
- PrepareMesh(i: int)¶
Prepare the mesh for case i if necessary
- Call:
>>> cntl.PrepareMesh(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2015-10-19
@ddalle: v1.02022-04-13
@ddalle: v1.1; exec_modfunction()2024-11-01
@ddalle: v1.2; exfiltrate AFLR3 prep2024-11-04
@ddalle: v1.3; exfiltrate WarmStart prep
- PrepareNamelist(i: int)¶
Prepare and write
fun3d.nmlfor case i- Call:
>>> cntl.PrepareNamelist(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of FUN3D control class
- i:
int Run index
- cntl:
- Versions:
2014-06-04
@ddalle: v1.02014-06-06
@ddalle: v1.1; low-level grid folder funcs2014-09-30
@ddalle: v1.2; single case at a time2018-04-19
@ddalle: v1.3; separate flight conditions
- PrepareNamelistAdiabaticWalls()¶
Prepare any boundary condition flags if needed
- Call:
>>> cntl.PrepareNamelistAdiabiticWalls()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D settings interface
- cntl:
- Versions:
2021-03-22
@jmeeroff: v1.0
- PrepareNamelistBoundaryConditions()¶
Prepare any boundary condition flags if needed
- Call:
>>> cntl.PrepareNamelistBoundaryConditions()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D settings interface
- cntl:
- Versions:
2018-10-24
@ddalle: v1.02019-??-??
@jmeeroff: v1.1; auto wall2022-07-13
@ddalle: v1.2; “auto” flag
- PrepareNamelistBoundaryList()¶
Write the correct boundary list in namelist
- Call:
>>> cntl.SetBoundaryList()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D settings interface
- cntl:
- Versions:
2021-03-18
@jmeeroff: v1.0- 2023-05-17
@ddalle: v1.1 check for ‘boundary_output_variables’ namelist
- 2023-05-17
- PrepareNamelistBoundaryPoints()¶
Write the lines of the boundary point sensors in the namelist
- Call:
>>> cntl.PrepareNamelistBoundaryPoints()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl FUN3D settings interface
- cntl:
- Versions:
2017-09-01
@ddalle: v1.02023-06-15
@ddalle: v1.1;filecntl->nmlfile
- PrepareNamelistConfig()¶
Write the lines for the force/moment output in a namelist
- Call:
>>> cntl.PrepareNamelistConfig()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- cntl:
- Versions:
2015-10-20
@ddalle: v1.02023-06-15
@ddalle: v2.0;filecntl->nmlfile
- PrepareNamelistFlightConditions(i)¶
Set namelist flight conditions
- Call:
>>> cntl.PrepareNamelistFligntConditions(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of FUN3D control class
- i:
int Run index
- cntl:
- Versions:
2018-04-19
@ddalle: v1.0
- PrepareRubberData(i)¶
Prepare
rubber.datafile if appropriate- Call:
>>> cntl.PrepareRubberData(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of FUN3D control class
- i:
int Run index
- cntl:
- Versions:
2016-04-27
@ddalle: v1.0
- PrepareSpeciesThermoData(i)¶
Prepare/edit a
speciesthermodatainput file for a case- Call:
>>> cntl.PrepareSpeciesThermoData(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2018-04-19
@ddalle: v1.0
- PrepareTData(i)¶
Prepare/edit a
tdatainput file for a case- Call:
>>> cntl.PrepareTData(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2018-04-19
@ddalle: v1.0
- ReadCaseNamelist(i: int, j=None)¶
Read namelist from case i, phase j if possible
- Call:
>>> nml = cntl.ReadCaseNamelist(i, rc=None, j=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of FUN3D control class
- i:
int Run index
- j: {
None} | nonnegativeint Phase number
- cntl:
- Outputs:
- nml:
None|pyOver.overnmlfile.OverNamelist Namelist interface is possible
- nml:
- Versions:
2016-12-12
@ddalle: v1.02023-09-18
@ddalle: v2.0; useCaseRunner
- ReadDataBookPost()¶
Do
pyfunspecific init actions after reading DataBook- Call:
>>> cntl.ReadDataBookPost()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE run matrix control instance
- cntl:
- Versions:
2023-05-31
@ddalle: v1.0
- ReadFAUXGeom()¶
Read any FAUXGeom input file template
- Call:
>>> cntl.ReadFAUXGeom()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- cntl:
- Versions:
2017-02-23
@ddalle: v1.0
- ReadFreezeSurfs()¶
Read list of surfaces to freeze
- Call:
>>> cntl.ReadFreezeSurfs()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- cntl:
- Versions:
2017-02-23
@ddalle: v1.0
- ReadMapBC(j=0, q=True)¶
Read the FUN3D boundary condition map
- Call:
>>> cntl.ReadMapBC(q=True)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the pyFun control class
- q: {
True} |False Whether or not to read to MapBC, else MapBC0
- cntl:
- Versions:
2016-03-30
@ddalle: v1.0
- ReadMovingBodyInputFile(j=0, q=True)¶
Read the
moving_body.inputtemplate- Call:
>>> cntl.ReadMovingBodyInputFile(j=0, q=True)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the pyFun control class
- j:
int Phase number
- q:
bool Whether or not to read to Namelist, else Namelist0
- cntl:
- Versions:
2015-10-16
@ddalle: v1.0 (ReadNamelist)2018-10-22
@ddalle: v1.02023-06-15
@ddalle: v1.1; check for file
- ReadNamelist(j=0, q=True)¶
Read the
fun3d.nmlfile- Call:
>>> cntl.ReadNamelist(j=0, q=True)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the pyFun control class
- j:
int Phase number
- q:
bool Whether or not to read to Namelist, else Namelist0
- cntl:
- Versions:
2015-10-16
@ddalle: v1.02015-12-31
@ddalle: Added Namelist0
- ReadRubberData(j=0, q=True)¶
Read the
rubber.datafile- Call:
>>> cntl.ReadRubberData(j=0, q=True)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the pyFun control class
- j:
int Phase number
- q:
bool Whether or not read RubberData, else RubberData0
- cntl:
- Versions:
2016-04-27
@ddalle: v1.0
- SetSurfBC(key, i, CT=False)¶
Set all surface BCs and flow initialization for one key
This uses the 7011 boundary condition and sets the values of BC stagnation pressure to freestream pressure and stagnation temperature to freestream temperature. Further, it creates a flow initialization volume to help with solution startup
- Call:
>>> cntl.SetSurfBC(key, i, CT=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of global pyFun settings object
- key:
str Name of SurfBC key to process
- i:
int Case index
- CT:
True| {False} Whether this key has thrust as input (else p0, T0 directly)
- cntl:
- Versions:
2016-03-29
@ddalle: v1.02016-04-13
@ddalle: v1.1; SurfCT compatibility2022-06-08
@ddalle: v1.2; check auto flow init
- WriteFreezeSurfs(fname)¶
Write a
pyfun.freezefile that lists surfaces to freezeThis is about the simplest file format in history, which is simply a list of surface indices.
- Call:
>>> cntl.WriteFreezeSurfs(fname)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Control interface
- fname:
str Name of file to write
- cntl:
- Versions:
2017-02-23
@ddalle: v1.0
- cli(*a, **kw)¶
Command-line interface
- Call:
>>> cntl.cli(*a, **kw)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- kw:
dict(True|False|str) Unprocessed keyword arguments
- cntl:
- Outputs:
- cmd:
None|str Name of command that was processed, if any
- cmd:
- Versions:
2018-10-19
@ddalle: Content frombin/executables
- init_post()¶
Do
__init__()actions specific topyfun- Call:
>>> cntl.init_post()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- cntl:
- Versions:
2023-05-31
@ddalle: v1.0