cape.pyover.cntl: OVERFLOW control module¶
This module provides tools to quickly setup basic or complex OVERFLOW 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.pyover.fun3d >>> cntl = cape.pyover.cntl.Cntl("pyOver.json") >>> cntl <cape.pyover.Cntl(nCase=907)> >>> cntl.x.GetFullFolderNames(0) 'poweroff/m1.5a0.0b0.0'
An instance of this cape.pyover.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
cntl.opts
cntl.DataBook
cntl.Namelist
cape.pyover.namelist.Namelist
Finally, the Cntl class is subclassed from the
cape.cntl.Cntl class, so any methods available to the CAPE class are
also available here.
- class cape.pyover.cntl.Cntl(fname='pyOver.json')¶
Class for handling global options and setup for OVERFLOW
This class is intended to handle all settings used to describe a group of OVERFLOW 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.
- Call:
>>> cntl = cape.pyover.Cntl(fname="pyOver.json")
- Inputs:
- fname:
str Name of cape.pyover input file
- fname:
- Outputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of the cape.pyover control class
- cntl:
- Data members:
- cntl.opts:
dict Dictionary of options for this case (directly from fname)
- cntl.x:
cape.pyover.runmatrix.RunMatrix Values and definitions for variables in the run matrix
- cntl.Namelist:
cape.pyover.overNamelist.OverNamelist Interface to
over.namelistOVERFLOW input file- cntl.RootDir:
str Absolute path to the root directory
- cntl.opts:
- Versions:
2015-10-16
@ddalle: Started2016-02-02
@ddalle: Version 1.0
- ApplyCase(i, nPhase=None, **kw)¶
Apply settings from cntl.opts to a set of cases
This rewrites each run namelist file and the
case.jsonfile in the specified directories.- Call:
>>> cntl.ApplyCase(i, nPhase=None)
- Inputs:
- cntl:
Cntl Overflow control interface
- i:
int Case number
- nPhase: {
None} | positiveint Last phase number (default determined by PhaseSequence)
- cntl:
- Versions:
2014-12-13
@ddalle: Version 1.0
- ArchivePWD(phantom=False)¶
Archive a single case in the current folder
- Call:
>>> cntl.ArchivePWD(phantom=False)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control interface
- phantom:
True| {False} Write actions to
archive.log; only delete ifFalse
- cntl:
- Versions:
2016-12-09
@ddalle: Version 1.02017-12-15
@ddalle: Added phantom option
- CaseGetCurrentIter()¶
Get the current iteration number from the appropriate module
This function utilizes the
cape.casemodule, and so it must be copied to the definition for each solver’s control class- Call:
>>> n = cntl.CaseGetCurrentIter()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class containing relevant parameters
- i:
int Index of the case to check (0-based)
- cntl:
- Outputs:
- n:
intorNone Number of completed iterations or
Noneif not set up
- n:
- Versions:
2015-10-14
@ddalle: Version 1.0
- CaseGetCurrentPhase()¶
Get the current phase number from the appropriate module
This function utilizes the
cape.casemodule, and so it must be copied to the definition for each solver’s control class- Call:
>>> j = cntl.CaseGetCurrentPhase()
- Inputs:
- cntl:
cape.cntl.Cntl Instance of control class containing relevant parameters
- i:
int Index of the case to check (0-based)
- cntl:
- Outputs:
- j:
int|None Phase number
- j:
- Versions:
2017-06-29
@ddalle: Version 1.0
- CheckError(i)¶
Check if a case has a failure
- Call:
>>> q = cntl.CheckError(i)
- Inputs:
- cntl:
Cntl OVERFLOW control interface
- i:
int Run index
- cntl:
- Outputs:
- q:
bool If
True, case hasFAILfile in it
- q:
- Versions:
2015-01-02
@ddalle: Version 1.02017-04-06
@ddalle: Checking forq.bomb
- CheckMesh(i)¶
Check if the mesh for case i is prepared
- Call:
>>> q = cntl.CheckMesh(i)
- Inputs:
- cntl:
Cntl Instance of OVERFLOW run control class
- i:
int Index of the case to check
- cntl:
- Outputs:
- q:
bool Whether or not the mesh for case i is prepared
- q:
- Versions:
2016-02-01
@ddalle: Version 1.0
- 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 Instance of control class containing relevant parameters
- v:
True| {False} Verbose flag
- cntl:
- Outputs:
q:
True|False- Versions:
2015-10-19
@ddalle: Version 1.02017-02-22
@ddalle: Version 1.1; add v
- CheckUsedPhase(i, v=False)¶
Check maximum phase number run at least once
- Call:
>>> j, n = cntl.CheckUsedPhase(i, v=False)
- Inputs:
- cntl:
cape.cntl.Cntl Instance of control class containing relevant parameters
- i:
int Index of the case to check (0-based)
- v:
True| {False} Verbose flag; prints messages if n is
None
- cntl:
- Outputs:
- j:
int|None Phase number
- n:
int Max phase number
- j:
- Versions:
2017-06-29
@ddalle: Version 1.02017-07-11
@ddalle: Version 1.1; add v
- CleanPWD(phantom=False)¶
Archive a single case in the current folder
- Call:
>>> cntl.CleanPWD(phantom=False)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control interface
- phantom:
True| {False} Write actions to
archive.log; only delete ifFalse
- cntl:
- Versions:
2017-03-10
@ddalle: Version 1.02017-12-15
@ddalle: Added phantom option
- ExtendCase(i, n=1, j=None, imax=None)¶
Run the final phase of case i again
- Call:
>>> cntl.ExtendCase(i, n=1, j=None, imax=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Run index
- n: {
1} | positiveint Add n times NSTEPS to the total iteration count
- j: {
None} | nonnegativeint Apply to phase j, by default use the last phase
- imax: {
None} | nonnegativeint Use imax as the maximum iteration count
- cntl:
- Versions:
2016-12-12
@ddalle: Version 1.0
- GetCPUTime(i, running=False)¶
Read a CAPE-style core-hour file from a case
- Call:
>>> CPUt = cntl.GetCPUTime(i, running=False)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl OVERFLOW control interface
- i:
int Case index
- running:
True| {False} Whether or not the case is running
- cntl:
- Outputs:
- CPUt:
float|None Total core hours used in this job
- CPUt:
- Versions:
2015-12-22
@ddalle: Version 1.02016-08-31
@ddalle: Version 1.1; start times
- GetConfig(i)¶
Get the configuration (if any) for case i
If there is no config or similar run matrix variable, return the name of the group folder
- Call:
>>> config = cntl.GetConfig(i)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Case index
- cntl:
- Outputs:
- config:
str Case configuration
- config:
- Versions:
2016-02-02
@ddalle: Version 1.0
- GetConfigDir(i)¶
Return absolute path to configuration folder
- Call:
>>> fcfg = cntl.GetConfigDir(i)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Case index
- cntl:
- Outputs:
- fcfg:
str Full path to configuration folder
- fcfg:
- Versions:
2016-02-02
@ddalle: Version 1.0
- GetMeshFileNames(i=0)¶
Return the list of mesh files
- Call:
>>> fname = cntl.GetMeshFileNames()
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class containing relevant parameters
- cntl:
- Outputs:
- fname:
list[str] List of file names read from root directory
- fname:
- Versions:
2016-02-01
@ddalle: Version 1.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:
Cntl Instance of cape.pyover control class
- sec:
str Name of namelist section/group
- key:
str Variable to read
- j:
int Run sequence index
- cntl:
- Outputs:
- val:
int|float|str|list Value
- val:
- Versions:
2016-02-01
@ddalle: Version 1.0
- GetPrefix(j=0)¶
Get the project root name or OVERFLOW file prefix
- Call:
>>> name = cntl.GetPrefix(j=0)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- j:
int Phase number
- cntl:
- Outputs:
- name:
str Project root name
- name:
- Versions:
2016-02-01
@ddalle: Version 1.0
- GetSurfBCState(key, i, grid=None)¶
Get stagnation pressure and temperature ratios
- Call:
>>> p0, T0 = cntl.GetSurfBC(key, i, grid=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- key:
str Name of SurfBC key to process
- i:
int Case index
- grid: {
None} |str Name of grid for which to extract settings
- cntl:
- Outputs:
- p0:
float Ratio of BC total pressure to freestream total pressure
- T0:
float Ratio of BC total temperature to freestream total temperature
- p0:
- Versions:
2016-08-29
@ddalle: Version 1.0
- GetSurfCTState(key, i, grid=None)¶
Get stagnation pressure and temp. ratios for SurfCT key
- Call:
>>> p0, T0 = cntl.GetSurfCTState(key, i, grid=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- key:
str Name of SurfBC key to process
- i:
int Case index
- grid: {
None} |str Name of grid for which to extract settings
- cntl:
- Outputs:
- p0:
float Ratio of BC total pressure to freestream total pressure
- T0:
float Ratio of BC total temperature to freestream total temperature
- p0:
- Versions:
2016-08-29
@ddalle: Version 1.0
- PrepareCase(i)¶
Prepare a case for running if it is not already prepared
- Call:
>>> cntl.PrepareCase(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class containing relevant parameters
- i:
int Index of case to prepare/analyze
- cntl:
- Versions:
2015-10-19
@ddalle: Version 1.0
- PrepareMesh(i)¶
Prepare the mesh for case i if necessary
- Call:
>>> cntl.PrepareMesh(i)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Case index
- cntl:
- Versions:
2016-02-01
@ddalle: Version 1.0
- PrepareNamelist(i, nPhase=None)¶
Write
over.namelistfor run case iThe optional input nPhase can be used to right additional phases that are not part of the default PhaseSequence, which can be useful when only a subset of cases in the run matrix will require additional phases.
- Call:
>>> cntl.PrepareNamelist(i, nPhase=None)
- Inputs:
- cntl:
Cntl Instance of OVERFLOW control class
- i:
int Run index
- nPhase: {
None} | positiveint Last phase number (default determined by PhaseSequence)
- cntl:
- Versions:
2016-02-01
@ddalle: Version 1.02016-12-13
@ddalle: Version 1.1; add second input2022-01-25
@ddalle: Version 1.2; reread nml each call
- ReadCaseJSON(i)¶
Read
case.jsonfile from case i if possible- Call:
>>> rc = cntl.ReadCaseJSON(i)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Run index
- cntl:
- Outputs:
- rc:
None|RunControl Run control interface read from
case.jsonfile
- rc:
- Versions:
2016-12-12
@ddalle: Version 1.0
- ReadCaseNamelist(i, rc=None, j=None)¶
Read namelist from case i, phase j if possible
- Call:
>>> nml = cntl.ReadCaseNamelist(i, rc=None, j=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Run index
- rc:
None|RunControl Run control interface read from
case.jsonfile- j: {
None} | nonnegativeint Phase number
- cntl:
- Outputs:
- nml:
None|OverNamelist Namelist interface is possible
- nml:
- Versions:
2016-12-12
@ddalle: Version 1.0
- ReadDataBook(comp=None)¶
Read the current data book
- Call:
>>> cntl.ReadDataBook(comp=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- comp: {
None} |str|list List of components, or read all if
None
- cntl:
- Versions:
2016-02-17
@ddalle: Version 1.02017-04-27
@ddalle: Version 1l1; add comp option
- ReadNamelist(j=0, q=True)¶
Read the OVERFLOW namelist template
- Call:
>>> cntl.ReadNamelist(j=0, q=True)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- j:
int Phase number
- q:
bool Whether or not to read to Namelist, else Namelist0
- cntl:
- Versions:
2016-02-01
@ddalle: Version 1.0
- ReadReport(rep)¶
Read a report interface
- Call:
>>> R = cntl.ReadReport(rep)
- Inputs:
- cntl:
Cntl Instance of control class containing relevant parameters
- rep:
str Name of report
- cntl:
- Outputs:
- R:
cape.pyover.report.Report Report interface
- R:
- Versions:
2018-10-19
@ddalle: Version 1.0
- SetSurfBC(key, i, CT=False)¶
Set a surface BC for one key using IBTYP 153
- Call:
>>> cntl.SetSurfBC(key, i, CT=False)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- 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-08-29
@ddalle: Version 1.0
- SkeletonPWD(phantom=False)¶
Delete most files in current folder, leaving only a skeleton
- Call:
>>> cntl.SkeletonPWD(phantom=False)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control interface
- phantom:
True| {False} Write actions to
archive.log; only delete ifFalse
- cntl:
- Versions:
2017-12-14
@ddalle: Version 1.0
- StopCases(n=0, **kw)¶
Stop one or more cases by writing a
STOPfile- Call:
>>> cntl.StopCases(n=0, cons=[], I=None, **kw)
- Inputs:
- n:
None| {0} | positiveint Iteration at which to stop
- cons:
list[str] List of trajectory constraints
- I:
list[int] List of case indices
- n:
- See also:
- Versions:
2017-03-07
@ddalle: Version 1.0
- WriteConfig(i, fname='Config.xml')¶
Write configuration file
- Call:
>>> cntl.WriteConfig(i, fname='Config.xml')
- Inputs:
- cntl:
Cntl Overflow control interface
- i:
int Case index
- fname: {
'Config.xml'} |str Name of file to write within run folder
- cntl:
- Versions:
2016-08-24
@ddalle: Version 1.0
- WritePBS(i, nPhase=None)¶
Write the PBS script(s) for a given case
- Call:
>>> cntl.WritePBS(i, nPhase=None)
- Inputs:
- cntl:
Cntl Instance of cape.pyover control class
- i:
int Run index
- nPhase: {
None} |int Optional maximum phase number
- cntl:
- Versions:
2014-10-19
@ddalle: Version 1.02016-12-14
@ddalle: Version 1.1; add nPhase input
- cli(*a, **kw)¶
Command-line interface
- Call:
>>> cntl.cli(*a, **kw)
- Inputs:
- cntl:
Cntl Instance of control class containing relevant parameters
- 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