cape.cfdx.cntlbase: Abstract base module for run matrix control¶
This module provides an abstract base class CntlBase, which
contains much of the functionality for controlling a full CFD run matrix
in CAPE.
- See also:
- class cape.cfdx.cntlbase.CntlBase(fname: str | None = None)¶
Bases:
ABCBase class for
cape.cfdx.cntl.Cntl- abstractmethod ApplyCase(i: int, **kw)¶
Rewrite CAPE inputs for case i
- Call:
>>> cntl.ApplyCase(i, n=1, j=None, imax=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Run index
- qsub:
True| {False} Option to submit case after applying settings
- nPhase:
int Phase to apply settings to
- cntl:
- abstractmethod ApplyCases(**kw)¶
Reapply settings to one or more cases
- Call:
>>> cntl.ApplyCases(cons=[], j=None, extend=1, **kw)
- Inputs:
- Versions:
2016-12-12
@ddalle: v1.0
- abstractmethod ArchiveCase(i: int, test: bool = False)¶
Perform
--archivearchiving on one caseThere are no restrictions on the status of the case for this action.
- Call:
>>> cntl.CleanCase(i, test=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control interface
- i:
int Case index
- test:
True| {False} Log file/folder actions but don’t actually delete/copy
- cntl:
- Versions:
2024-09-18
@ddalle: v1.0
- abstractmethod ArchiveCases(**kw)¶
Archive completed cases and clean them up if specified
- Call:
>>> cntl.ArchiveCases() >>> cntl.ArchiveCases(cons=[], **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of overall control interface
- cons:
list[str] List of constraints
- I:
list[int] List of indices
- cntl:
- Versions:
2016-12-09
@ddalle: v1.02024-09-19
@ddalle: v2.0
- abstractmethod CaseFunction(i: int)¶
Run one or more functions at “prepare-case” hook
This function is executed at the beginning of
PrepareCase(i)().This is meant to serve as a filter if a user wants to change the settings for some subset of the cases. Using this function can change any setting, which can be dependent on the case i.
This calls the function(s) in the global
"CaseFunction"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"], "CaseFunction": ["testmod.testfunc"]
This leads CAPE to call
testmod.testfunc(cntl, i)at the beginning ofPrepareCase()for each case i in the run matrix. The function is also called at the beginning ofApplyCase()ifpyfun --applyor similar is issued.- Call:
>>> cntl.CaseFunction(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- i:
int Case number
- cntl:
- Versions:
2017-04-05
@ddalle: v1.0
- See also:
- abstractmethod CaseGetCurrentPhase()¶
Get the current phase number from the appropriate module
This function utilizes the
cape.cfdx.casemodule, and so it must be copied to the definition for each solver’s control class.- Call:
>>> j = cntl.CaseGetCurrentPhase()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- cntl:
- Outputs:
- j:
int|None Phase number
- j:
- Versions:
2017-06-29
@ddalle: v1.02023-07-06
@ddalle: v1.1; useCaseRunner
- abstractmethod CheckBatch() int¶
Check to see if we are running inside a batch job
This looks for environment variables to see if this is running inside a batch job. Currently supports slurm and PBS.
- Call:
>>> q = cntl.CheckBatch()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- cntl:
- Outputs:
- jobid:
int 0if no batch environment was detected
- jobid:
- Versions:
2023-12-13
@dvicker: v1.02023-12-18
@ddalle: v1.1; debug
- abstractmethod CheckCase(i: int, force: bool = False, v: bool = False) int | None¶
Check current status of case i
Because the file structure is different for each solver, some of this method may need customization. This customization, however, can be kept to the functions
cape.cfdx.casecntl.GetCurrentIter()andcape.cfdx.cntl.Cntl.CheckNone().- Call:
>>> n = cntl.CheckCase(i, v=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- v:
True| {False} Verbose flag; prints messages if n is
None
- cntl:
- Outputs:
- n:
int|None Number of completed iterations or
Noneif not set up
- n:
- Versions:
2014-09-27
@ddalle: v1.02015-09-27
@ddalle: v2.0; generic2015-10-14
@ddalle: v2.1; nocasereq2017-02-22
@ddalle: v2.2; add verbose flag2023-11-06
@ddalle: v2.3; callsetx_i(i)
- abstractmethod CheckError(i: int) bool¶
Check if a case has a failure
- Call:
>>> q = cntl.CheckError(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Run index
- cntl:
- Outputs:
- q:
bool If
True, case hasFAILfile in it
- q:
- abstractmethod CheckNone(v: bool = False) bool¶
Check if the current directory has the needed files to run
This function needs to be customized for each CFD solver so that it checks for the appropriate files.
- Call:
>>> q = cntl.CheckNone(v=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- v:
True| {False} Verbose flag; prints message if q is
True
- cntl:
- Outputs:
- q:
`True| False` Whether or not case is missing files
- q:
- Versions:
2015-09-27
@ddalle: v1.02017-02-22
@ddalle: v1.1, verbosity option
- abstractmethod CheckPhase(i: int, v: bool = False) int | None¶
Check current phase number of run i
- Call:
>>> n = cntl.CheckPhase(i, v=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- 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
- j:
- Versions:
2017-06-29
@ddalle: v1.0
- abstractmethod CheckRunning(i: int) bool¶
Check if a case is currently running
- Call:
>>> q = cntl.CheckRunning(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Run index
- cntl:
- Outputs:
- q:
bool If
True, case hasRUNNINGfile in it
- q:
- abstractmethod CheckUsedPhase(i: int, v: bool = False)¶
Check maximum phase number run at least once
- Call:
>>> j, n = cntl.CheckUsedPhase(i, v=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- v:
True| {False} Verbose flag; prints messages if n is
None
- cntl:
- Outputs:
- Versions:
2017-06-29
@ddalle: v1.02017-07-11
@ddalle: v1.1; verbosity option2025-03-02
@ddalle: v2.0; use CaseRunner
- abstractmethod CheckZombie(i)¶
Check a case for
ZOMBIEstatusA running case is declared a zombie if none of the listed files (by default
*.out) have been modified in the last 30 minutes. However, a case cannot be a zombie unless it contains aRUNNINGfile and returnsTruefromCheckRunning().- Call:
>>> q = cntl.CheckZombie(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Run index
- cntl:
- Outputs:
- q:
bool Trueif no listed files have been modified recently
- q:
- Versions:
2017-04-04
@ddalle: v1.02021-01-25
@ddalle: v1.1; use cls._zombie_files
- abstractmethod CleanCase(i: int, test: bool = False)¶
Perform
--cleanarchiving on one caseThere are no restrictions on the status of the case for this action.
- Call:
>>> cntl.CleanCase(i, test=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control interface
- i:
int Case index
- test:
True| {False} Log file/folder actions but don’t actually delete/copy
- cntl:
- abstractmethod CleanCases(**kw)¶
Clean a list of cases using Progress archive options only
- Call:
>>> cntl.CleanCases(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control interface
- cntl:
- Versions:
2017-03-13
@ddalle: v1.02024-09-18
@ddalle: v2.0
- abstractmethod CountQueuedCases(I: list | None = None, u: str | None = None, **kw) int¶
Count cases that have currently active PBS/Slurm jobs
- Call:
>>> n = cntl.CountQueuedCases(I=None, u=None, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- I: {
None} |list[int] List of indices
- u:
str User name (defaults to process username)
- kw:
dict Other kwargs used to subset the run matrix
- cntl:
- Outputs:
- n:
int Number of running or queued jobs (not counting the job from which function is called, if applicable)
- n:
- Versions:
2024-01-12
@ddalle: v1.02024-01-17
@ddalle: v1.1; check for this_job2025-05-01
@ddalle: v1.2; remove jobs kwarg
- abstractmethod CountRunningCases(I: list, jobs: dict | None = None, u: str | None = None) int¶
Count number of running cases via the batch system
Also print a status of the running jobs.
- Call:
>>> n = cntl.CountRunningCases(I, jobs=None, u=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- I:
list[int] List of indices
- jobs:
dict Information on each job by ID number
- u:
str User name (defaults to process username)
- cntl:
- Outputs:
- n:
int Number of running or queued jobs
- n:
- Versions:
2023-12-08
@dvicker: v1.0
- abstractmethod Defail(**kw)¶
Clean up any FAIL cases
- Call:
>>> cntl.Defail(**kw)
- Inputs:
- Versions:
2026-07-23
@ddalle: v1.0
- abstractmethod DeleteCase(i: int, **kw)¶
Delete a case
This function deletes a case’s PBS job and removes the entire directory. By default, the method prompts for user’s confirmation before deleting; set prompt to
Falseto delete without prompt.- Call:
>>> n = cntl.DeleteCase(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- i:
int Index of the case to check (0-based)
- prompt: {
True} |False Whether or not to prompt user before deleting case
- cntl:
- Outputs:
- n:
0|1 Number of folders deleted
- n:
- Versions:
2018-11-20
@ddalle: v1.0
- abstractmethod Dezombie(**kw)¶
Clean up any ZOMBIE cases
- Call:
>>> cntl.Dezombie(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of overall control interface
- extend: {
True} | positiveint Extend phase j by extend nominal runs
- j: {
None} |int>= 0 Phase number
- imax: {
None} |int Do not increase iteration number beyond imax
- cons:
list[str] List of constraints
- I:
list[int] List of indices
- early:
True| {False} Reduce iteration count to current iter
- cntl:
- Versions:
2021-10-14
@ddalle: v1.02026-02-25
@ddalle: v1.1; add early option
- abstractmethod DisplayStatus(**kw)¶
Display current status for all cases
This prints case names, current iteration numbers, and so on. This is the function that is called when the user issues a system command like
cape -c.- Call:
>>> cntl.DisplayStatus(j=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- j:
bool Whether or not to display job ID numbers
- cons:
list[str] List of constraints like
'Mach<=0.5'
- cntl:
- Versions:
2014-10-04
@ddalle: v1.02014-12-09
@ddalle: v2.0;--cons2025-06-20
@ddalle: v3.0; use caseloop_verbose()
- abstractmethod ExecScript(**kw) int¶
Execute a script in a given case folder
This function is the interface to command-line calls using the
-eflag, such aspycart -e 'ls -lh'.- Call:
>>> ierr = cntl.ExecScript(i, cmd)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Case index (0-based)
- cntl:
- Outputs:
- ierr:
None|int Exit status from the command
- ierr:
- Versions:
2016-08-26
@ddalle: v1.02024-12-09
@jfdiaz3:v1.1
- abstractmethod ExtendCase(i: int, n: int = 1, j: int | None = None, imax: int | None = None)¶
Add iterations to case i by repeating the last phase
- Call:
>>> cntl.ExtendCase(i, n=1, j=None, imax=None)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Case index
- n: {
1} | positiveint Add n times steps to the total iteration count
- j: {
None} |int Optional phase to extend
- imax: {
None} | nonnegativeint Use imax as the maximum iteration count
- cntl:
- abstractmethod ExtendCases(**kw)¶
Extend one or more case by a number of iterations
By default, this applies to the final phase, but the phase number j can also be specified as input. The number of additional iterations is generally the nominal number of iterations that phase j would normally run.
- Call:
>>> cntl.ExtendCases(cons=[], extend=1, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of overall control interface
- extend: {
True} | positiveint Extend phase j by extend nominal runs
- imax: {
None} |int Do not increase iteration number beyond imax
- j, phase: {
None} |int Optional index of phase to extend
- cons:
list[str] List of constraints
- I:
list[int] List of indices
- cntl:
- Versions:
2016-12-12
@ddalle: v1.0
- abstractmethod FilterUser(i: int, **kw) bool¶
Determine if case i is assigned to current user
- Call:
>>> q = cntl.FilterUser(i, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- u, user:
str User name (default: executing process’s username) for comparing to run matrix
- cntl:
- Outputs:
- q:
bool Whether user is owner of case i
- q:
- Versions:
2017-07-10
@ddalle: v1.0
- abstractmethod GetCPUTime(i: int)¶
Read a CAPE-style core-hour file from a case
This function needs to be customized for each solver because it needs to know the name of the file in which timing data is saved. It defaults to
cape_time.dat. Modifying this command is a one-line fix with a call tocape.cfdx.cntl.Cntl.GetCPUTimeFromFile()with the correct file name.- Call:
>>> CPUt = cntl.GetCPUTime(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE control interface
- i:
int Case index
- cntl:
- Outputs:
- CPUt:
float|None Total core hours used in this job
- CPUt:
- Versions:
2015-12-22
@ddalle: v1.02016-08-30
@ddalle: v1.1; check forRUNNING2016-08-31
@ddalle: v1.2; useGetCPUTimeBoth2023-07-09
@ddalle: v2.0; useCaseRunner
- abstractmethod GetCaseIndex(frun: str) int | None¶
Get index of a case in the current run matrix
- Call:
>>> i = cntl.GetCaseIndex(frun)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- frun:
str Name of case, must match exactly
- cntl:
- Outputs:
- i:
int|None Index of case with name frun in run matrix, if present
- i:
- Versions:
2024-08-15
@ddalle: v1.02024-10-16
@ddalle: v1.1; move toRunMatrix
- abstractmethod GetCaseMeshFolder(i: int) str¶
Get relative path to folder where mesh should be copied
- abstractmethod GetCurrentIter(i: int, force: bool = False) int¶
Get the current iteration number (using
case)This function utilizes the
cape.cfdx.casemodule, and so it must be copied to the definition for each solver’s control class.- Call:
>>> n = cntl.GetCurrentIter(i, force=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- force:
True| {False} Option to ignore cache
- cntl:
- Outputs:
- n:
int Number of completed iterations
- n:
- Versions:
2015-10-14
@ddalle: v1.02023-07-07
@ddalle: v2.0; useCaseRunner2025-03-01
@ddalle: v3.0; add caching
- abstractmethod GetIndices(**kw) ndarray¶
Find cases using multiple conditions
- Call:
>>> inds = cntl.GetIndices(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- status: {
None} |"DONE"|str Status filter
- cntl:
- Outputs:
- inds: :np.ndarray`[
int] List of case indices that meet all conditions
- inds: :np.ndarray`[
- Versions:
2026-08-13
@ddalle: v1.0 (was part of cntl.x
- abstractmethod GetLastIter(i: int) int¶
Get minimum required iteration for a given case
- Call:
>>> nIter = cntl.GetLastIter(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- i:
int Run index
- cntl:
- Outputs:
- nIter:
int Number of iterations required for case i
- nIter:
- Versions:
2014-10-03
@ddalle: v1.0
- abstractmethod GetPBSJobID(i: int) str | None¶
Get PBS job number if one exists
- Call:
>>> jobID = cntl.GetPBSJobID(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Run index
- cntl:
- Outputs:
- jobID:
None|str Most recent PBS/Slurm job name, if able
- jobID:
- Versions:
2014-10-06
@ddalle: v1.02024-01-12
@ddalle: v1.1; remove CheckCase() for speed
- abstractmethod GetPBSName(i: int) str¶
Get PBS name for a given case
- Call:
>>> lbl = cntl.GetPBSName(i, pre=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Run index
- pre: {
None} |str Prefix for PBS job name
- cntl:
- Outputs:
- lbl:
str Short name for the PBS job, visile via
qstat
- lbl:
- Versions:
2014-09-30
@ddalle: v1.02016-12-20
@ddalle: v1.1, moved to x
- abstractmethod GetPhaseBreaks() list¶
Get expected iteration numbers at phase breaks
This fills in
0entries in RunControl PhaseIters and returns the filled-out list.- Call:
>>> PI = cntl.GetPhaseBreaks()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- cntl:
- Outputs:
- Versions:
2017-04-12
@ddalle: v1.0
- abstractmethod 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:
Cntl CAPE run matrix control instance
- j: {
0} |int Phase number
- cntl:
- Outputs:
- name:
str Project root name
- name:
- Versions:
2015-10-18
@ddalle: v1.0 (pyfun)2023-06-15
@ddalle: v1.1; cleaner logic2024-10-22
@ddalle: v2.0; moved tocfdx2025-07-15
@ddalle: v2.1; move intoCntlBase
- abstractmethod GetSurfCT_ExitArea(key: str, i: int, comp: str | None = None) float¶
Get exit area for a CT trajectory key
This can use either the area ratio (if available) or calculate from the exit Mach number. The input area is determined from the component ID. If using the exit Mach number M2, the input Mach number M1 is also needed. The relationship between area ratio and exit Mach is given below.
\[\begin{split}\\frac{A_2}{A_1} = \\frac{M_1}{M_2}\\left( \\frac{1+\\frac{\\gamma-1}{2}M_2^2}{ 1+\\frac{\\gamma-1}{2}M_1^2} \\right) ^ {\\frac{1}{2}\\frac{\\gamma+1}{\\gamma-1}}\end{split}\]- Call:
>>> A2 = cntl.GetSurfCT_ExitArea(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of trajectory key to check
- i:
int Case number
- comp: {
None} |str Name of component for which to get BCs
- cntl:
- Outputs:
- Versions:
2016-04-13
@ddalle: v1.0
- abstractmethod GetSurfCT_ExitMach(key: str, i: int, comp: str | None = None) float¶
Get exit Mach number for a CT trajectory key
This can use either the
"ExitMach"parameter (if available) or calculate from the area ratio. If using the area ratio, the input Mach number is also needed. The relationship between area ratio and exit Mach is given below.\[\frac{A_2}{A_1} = \frac{M_1}{M_2}\left( \frac{1+\frac{\gamma-1}{2}M_2^2}{ 1+\frac{\gamma-1}{2}M_1^2} \right) ^ {\frac{1}{2}\frac{\gamma+1}{\gamma-1}}\]- Call:
>>> M2 = cntl.GetSurfCT_ExitMach(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of trajectory key to check
- i:
int Case number
- comp: {
None} |str Name of component for which to get BCs
- cntl:
- Outputs:
- M2:
float Exit Mach number
- M2:
- Versions:
2016-04-13
@ddalle: v1.0
- abstractmethod GetSurfCT_RefArea(key: str, i: int) float¶
Get reference area for surface CT trajectory key
This references the
"RefArea"parameter of the definition for the run matrix variable key. The user should set this parameter to1.0if thrust inputs are given as dimensional values.If this is
None, it returns the global reference area; if it is a string the reference area comes from the reference area for that component usingcntl.opts.get_RefArea(comp).- Call:
>>> Aref = cntl.GetSurfCT_RefArea(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of trajectory key to check
- i:
int Case number
- cntl:
- Outputs:
- Aref:
float Reference area for normalizing thrust coefficients
- Aref:
- Versions:
2016-04-13
@ddalle: v1.0
- abstractmethod ImportModules()¶
Import user-defined modules if specified in the options
All modules from the
"Modules"global option of the JSON file (cntl.opts["Modules"]) will be imported and saved as attributes of cntl. For example, if the user wants to use a module calleddac3, it will be imported as cntl.dac3. A noncomprehensive list of disallowed module names is below.DataBook, RootDir, jobs, opts, tri, x
The name of any method of this class is also disallowed. However, if the user wishes to import a module whose name is disallowed, he/she can use a dictionary to specify a different name to import the module as. For example, the user may import a module called
triasmytriusing the following JSON syntax."Modules": [{"tri": "mytri"}]
- Call:
>>> cntl.ImportModules()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of Cape control interface
- cntl:
- Versions:
2014-10-08
@ddalle: v1.0 (pycart)2015-09-20
@ddalle: v1.02022-04-12
@ddalle: v2.0; use self.modules
- abstractmethod InitFunction()¶
Run one or more functions a “initialization” hook
This calls the function(s) in the global
"InitFunction"option from the JSON file. These functions must take cntl as an input, and they are usually from a module imported via the"Modules"option. See the following example:"Modules": ["testmod"], "InitFunction": ["testmod.testfunc"]
This leads CAPE to call
testmod.testfunc(cntl).- Call:
>>> cntl.InitFunction()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- cntl:
- Versions:
2017-04-04
@ddalle: v1.02022-04-12
@ddalle: v2.0; use _exec_funclist()
- abstractmethod MarkERROR(**kw)¶
Mark one or more cases as ERROR and rewrite matrix
- Call:
>>> cntl.MarkERROR(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- I:
list[int] List of indices
- cons:
list[str] List of constraints like
'Mach<=0.5'- flag: {
"E"} |"e"|"ERROR"|"$E" Marker to use to denote status
- cntl:
- Versions:
2019-06-14
@ddalle: v1.0
- abstractmethod MarkPASS(**kw)¶
Mark one or more cases as PASS and rewrite matrix
- Call:
>>> cntl.MarkPASS(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- I:
list[int] List of indices
- cons:
list[str] List of constraints like
'Mach<=0.5'- flag: {
"p"} |"P"|"PASS"|"$p" Marker to use to denote status
- cntl:
- Versions:
2019-06-14
@ddalle: v1.0
- abstractmethod PrepareCase(i: int)¶
Prepare case for running if necessary
This function creates the folder, copies mesh files, and saves settings and input files. All of these tasks are completed only if they have not already been completed, and it needs to be customized for each CFD solver.
- Call:
>>> cntl.PrepareCase(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of case to analyze
- cntl:
- Versions:
2014-09-30
@ddalle: v1.02015-09-27
@ddalle: v2.0, convert to template
- abstractmethod PrepareConfig(i: int)¶
Apply rotations, translations, etc. to
Config.xml- Call:
>>> cntl.PrepareConfig(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Case index
- cntl:
- Versions:
2016-08-23
@ddalle: v1.0
- abstractmethod PrepareConfigFunction(key: str, i: int)¶
Apply special configuration modification function for a case
- Call:
>>> cntl.PrepareConfigFunction(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of key
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2016-08-23
@ddalle: v1.02022-04-13
@ddalle: v2.0; exec_modfunction()
- abstractmethod PrepareConfigRotation(key: str, i: int)¶
Apply a rotation to a component or components
- Call:
>>> cntl.PrepareConfigRotation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of the trajectory key
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2016-08-23
@ddalle: v1.0
- abstractmethod PrepareConfigTranslation(key: str, i: int)¶
Apply a translation to a component or components
- Call:
>>> cntl.PrepareConfigTranslation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of variable from which to get value
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2016-08-23
@ddalle: v1.0
- abstractmethod 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.0 (pyfun)2024-11-04
@ddalle: v1.3 (pyfun)2024-11-07
@ddalle: v1.0
- abstractmethod PrepareMeshTri(i: int)¶
Prepare surface triangulation for AFLR3, if appropriate
- Call:
>>> cntl.PrepareMeshTri(i)
- Inputs:
- cntl:
Cntl CAPE run matrix control instance
- i:
int Case index
- cntl:
- Versions:
2024-11-01
@ddalle: v1.0 (from pyfun’s PrepareMesh())
- abstractmethod PrepareMeshUnstructured(i: int)¶
Prepare the mesh for case i if necessary
- Call:
>>> cntl.PrepareMeshUnstructured(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Versions:
2015-10-19
@ddalle: v1.0 (pyfun)2024-11-04
@ddalle: v1.3 (pyfun)2024-11-07
@ddalle: v1.02025-07-15
@ddalle: v1.1; name change
- abstractmethod PreparePoints(i: int)¶
Calculate the value of each named
"Point"for case i- Call:
>>> x = cntl.PreparePoints(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Case index
- cntl:
- Versions:
2022-03-07
@ddalle: v1.0
- abstractmethod PreparePointsRotation(key: str, i: int)¶
Apply a rotation to named config points for one col
- Call:
>>> cntl.PreparePointsRotation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of the trajectory key
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2022-03-07
@ddalle: v1.0
- abstractmethod PreparePointsTranslation(key: str, i: int)¶
Apply a translation to named config points for one col
- Call:
>>> cntl.PreparePointsTranslation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of the trajectory key
- i:
int Case index
- cntl:
- Versions:
2022-03-07
@ddalle: v1.0
- abstractmethod PrepareTri(i: int)¶
Rotate/translate/etc. triangulation for given case
- Call:
>>> cntl.PrepareTri(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2014-12-01
@ddalle: v1.02016-04-05
@ddalle: v1.1, pycart -> cape
- abstractmethod PrepareTriFunction(key: str, i: int)¶
Apply special surf modification function for a case
- Call:
>>> cntl.PrepareTriFunction(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Name of key
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2015-09-11
@ddalle: v1.02016-04-05
@ddalle: v1.1, pycart -> cape2022-04-13
@ddalle: v2.0; exec_modfunction()
- abstractmethod PrepareTriRotation(key: str, i: int)¶
Apply a rotation to a component or components
- Call:
>>> cntl.PrepareTriRotation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Run matrix for rotation defn’
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2015-09-11
@ddalle: v1.02016-04-05
@ddalle: v1.1, pycart -> cape
- abstractmethod PrepareTriTranslation(key: str, i: int)¶
Apply a translation to a component or components
- Call:
>>> cntl.PrepareTriTranslation(key, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- key:
str Run matrix key for translation def’n
- i:
int Index of the case to check (0-based)
- cntl:
- Versions:
2015-09-11
@ddalle: v1.02016-04-05
@ddalle: v1.1, pycart -> cape
- abstractmethod ReadCaseRunner(i: int) CaseRunnerBase¶
Read CaseRunner into slot
- Call:
>>> runner = cntl.ReadCaseRunner(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- cntl:
- Outputs:
- runner:
CaseRunner Controller to run one case of solver
- runner:
- abstractmethod ReadConfig(f=False) ConfigXML | ConfigJSON¶
Read
Config.xmlor other surf configuration format- Call:
>>> cntl.ReadConfig(f=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- f:
True| {False} Option to reread existing cntl.config
- cntl:
- Versions:
2016-06-10
@ddalle: v1.02016-10-21
@ddalle: v2.0, addedConfig.json2020-09-01
@ddalle: v2.1, add f kwarg
- abstractmethod ReadFolderCaseRunner(fdir: str) CaseRunnerBase¶
Read a
CaseRunnerfrom a folder by name- Call:
>>> runner = cntl.ReadFolderCaseRunner(fdir)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- fdir:
str Folder of case to read from
- cntl:
- Outputs:
- runner:
CaseRunner Controller to run one case of solver
- runner:
- abstractmethod ReadMapBC(j: int = 0, q: bool = True) MapBCFile | None¶
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
- abstractmethod ReadReport(rep: str)¶
Read a report interface
- Call:
>>> rep = cntl.ReadReport(rep)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE main control instance
- rep:
str Name of report
- cntl:
- Outputs:
- rep:
cape.cfdx.report.Report Report interface
- rep:
- Versions:
2018-10-19
@ddalle: Version 1.0
- abstractmethod ReadTri()¶
Read initial triangulation file(s)
- Call:
>>> cntl.ReadTri()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- cntl:
- Versions:
2014-08-30
@ddalle: v1.02026-05-22
@ddalle: v1.1; check which files were read
- abstractmethod RevertOptions()¶
Revert to cntl.opts0 as working options
- Call:
>>> cntl.ResetOptions()
- Inputs:
- cntl:
Cntl CAPE solver control interface
- cntl:
- Versions:
2021-07-31
@ddalle: v1.0
- abstractmethod SaveOptions()¶
Copy cntl.opts and store it as cntl.opts0
- Call:
>>> cntl.SaveOptions()
- Inputs:
- cntl:
Cntl CAPE solver control interface
- cntl:
- Versions:
2021-07-31
@ddalle: v1.0
- abstractmethod SkeletonCase(i: int, test: bool = False)¶
Perform
--skeletonarchiving on one caseThere are no restrictions on the status of the case for this action.
- Call:
>>> cntl.SkeletonCase(i, test=False)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control interface
- i:
int Case index
- test:
True| {False} Log file/folder actions but don’t actually delete/copy
- cntl:
- Versions:
2024-09-18
@ddalle: v1.0
- abstractmethod SkeletonCases(**kw)¶
Archive completed cases and delete all but a few files
- Call:
>>> cntl.SkeletonCases() >>> cntl.SkeletonCases(cons=[], **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of overall control interface
- cons:
list[str] List of constraints
- I:
list[int] List of indices
- cntl:
- Versions:
2016-12-14
@ddalle: v1.02024-09-19
@ddalle: v2.0
- abstractmethod StartCase(i: int)¶
Start a case by either submitting it or running it
This function checks whether or not a case is submittable. If so, the case is submitted via
cape.cfdx.queue.pqsub(), and otherwise the case is started using a system call.Before starting case, this function checks the folder using
cape.cfdx.cntl.CheckCase(); if this function returnsNone, the case is not started. Actual starting of the case is done usingCaseStartCase(), which has a specific version for each CFD solver.- Call:
>>> pbs = cntl.StartCase(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of the case to check (0-based)
- cntl:
- Outputs:
- pbs:
int|None PBS job ID if submitted successfully
- pbs:
- abstractmethod StopCase(i: int)¶
Stop a case if running
This function deletes a case’s PBS job and removes the
RUNNINGfile if it exists.- Call:
>>> cntl.StopCase(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- i:
int Index of the case to check (0-based)
- cntl:
- SubmitJobs(**kw)¶
Check jobs and prepare or submit jobs if necessary
- Call:
>>> cntl.SubmitJobs(**kw)
- Inputs:
- Versions:
2014-10-05
@ddalle: v1.02014-12-09
@ddalle: v2.0,--cons2021-08-01
@ddalle: v2.1, save/revert options2023-05-17
@ddalle: v2.2,opts.setx_i()
- abstractmethod UnarchiveCases(**kw)¶
Unarchive a list of cases
- Call:
>>> cntl.UnarchiveCases(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control interface
- cntl:
- Versions:
2017-03-13
@ddalle: v1.02023-10-20
@ddalle: v1.1; arbitrary-depth frun2024-09-20
@ddalle: v2.0; use CaseArchivist
- abstractmethod UnmarkCase(**kw)¶
Remove PASS or ERROR marking from one or more cases
- Call:
>>> cntl.UnmarkCase(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- I:
list[int] List of indices
- cons:
list[str] List of constraints like
'Mach<=0.5'
- cntl:
- Versions:
2019-06-14
@ddalle: v1.0
- abstractmethod UpdateReport(**kw)¶
Update a report
- Call:
>>> cntl.UpdateReport(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE main control instance
- report: {
True} |str Name of report (or first report)
- I: {
None} |np.ndarray[int] Indices to report
- cntl:
- Versions:
2025-08-25
@ddalle: v1.0
- abstractmethod WriteCaseJSON(i: int, rc: dict | None = None)¶
Write JSON file with run control settings for case i
- Call:
>>> cntl.WriteCaseJSON(i, rc=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Generic control class
- i:
int Run index
- rc: {
None} |dict If specified, write specified “RunControl” options
- cntl:
- Versions:
2015-10-19
@ddalle: v1.02023-03-31
@ddalle: v2.0; manual options input2023-08-29
@ddalle: v2.1; call sample_dict()2024-08-24
@ddalle: v2.2; use CaseRunner2025-01-23
@ddalle: v2.3; eliminate Arvhive settings
- abstractmethod WriteConditionsJSON(i: int)¶
Write JSON file with run matrix settings for case i
- Call:
>>> cntl.WriteConditionsJSON(i, rc=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Generic control class
- i:
int Run index
- rc: {
None} |dict If specified, write specified “RunControl” options
- cntl:
- Versions:
2021-09-08
@ddalle: v1.0
- abstractmethod WritePBS(i: int)¶
Write the PBS script(s) for a given case
- Call:
>>> cntl.WritePBS(i)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Run index
- cntl:
- Versions:
2014-10-19
@ddalle: v1.02023-10-20
@ddalle: v1.1; arbitrary frun depth2024-08-01
@ddalle: v2.0; solver-agnostic
- abstractmethod WritePBSHeader(fp: IOBase, i: int | None = None, j: int = 0, typ: str | None = None, wd: str | None = None)¶
Write common part of PBS or Slurm script
- Call:
>>> cntl.WritePBSHeader(fp, i=None, j=0, typ=None, wd=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- fp:
IOBase Open file handle
- i: {
None} |int Case index (ignore if
None); used for PBS job name- j:
int Phase number
- typ: {
None} |"batch"|"post" Group of PBS options to use
- wd: {
None} |str Folder to enter when starting the job
- cntl:
- Versions:
2015-09-30
@ddalle: v1.0, fork WritePBS()2016-09-25
@ddalle: v1.1, “BatchPBS”- 2016-12-20
@ddalle: v1.2 Consolidated to opts
Added prefix
- 2016-12-20
- 2024-08-15
@ddalle: v1.3 Use cntl.opts.name as prefix
User-controlled job name length, longer default
- 2024-08-15
- abstractmethod apply_setter(opt: str, v: Any)¶
Change an option by name of setter method
- Call:
>>> cntl.apply_setter(opt, v)
- Inputs:
- cntl:
Cntl CAPE solver control interface
- opt:
str Name of option, e.g.
"PBS_q"will cause the function to look forcntl.opts.set_PBS_q()- v: any
Value to set the option to
- cntl:
- Versions:
2026-05-23
@ddalle: v1.0
- abstractmethod caseloop(casefunc: Callable, **kw) list¶
Loop through cases and execute function for each case
- Call:
>>> cases = cntl.caseloop(casefun, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- indent: {
0} |int Number of spaces to indent each case name
- cntl:
- Outputs:
- Versions:
2025-02-12
@ddalle: v1.02026-08-07
@ddalle: v1.1; add output
- abstractmethod caseloop_verbose(casefunc: Callable | None = None, **kw) int¶
Loop through cases and produce verbose table
- Call:
>>> n = cntl.caseloop_verbose(casefunc, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- casefunc: {
None} |Callable Optional function to run in each case folder
- I: {
None} |np.ndarray[int] Case indices
- cntl:
- Outputs:
- n:
int Number of cases started/submitted
- n:
- Versions:
2025-06-19
@ddalle: v1.0
- abstractmethod check_case_job(i: int, active: bool = True) str¶
Get queue status of the PBS/Slurm job from case i
- Call:
>>> s = cntl.check_case_job(i, active=True)
- Inputs:
- cntl:
Cntl Controller for one CAPE run matrix
- i:
int Case index
- active: {
True} |False Whether or not to allow new calls to
qstat
- cntl:
- Outputs:
- s:
str Job queue status
-: not in queueQ: job queued (not running)R: job runningH: job heldE: job error status
- s:
- Versions:
2025-05-04
@ddalle: v1.0
- abstractmethod check_case_status(i: int, active: bool = True, force: bool = False) str¶
Get queue status of the PBS/Slurm job from case i
- Call:
>>> sts = cntl.check_case_job(i, active=True)
- Inputs:
- cntl:
Cntl Controller for one CAPE run matrix
- i:
int Case index
- active: {
True} |False Whether or not to allow new calls to
qstat- force:
True| {False} Option to override cache and reevaluate
- cntl:
- Outputs:
- sts:
str Case status
---: folder does not existINCOMP: case incomplete but [partially] set upQUEUE: case waiting in PBS/Slurm queueRUNNING: case currently runningDONE: all phases and iterations completePASS: DONE and marked by user as passedZOMBIE: seems running; but no recent file updatesPASS*: case marked by user but not DONEERROR: case marked as errorFAIL: case failed but not marked by user
- sts:
- Versions:
2025-05-04
@ddalle: v1.02026-08-13
@ddalle: v1.1; use cache
- abstractmethod copy_files(i: int)¶
Copy files from Mesh section
This applies to both CopyFiles and CopyAsFiles in the Mesh section. The former will copy a given file into the run folder for case i using the base name of the original (source) file. Using
"Mesh": { "CopyAsFiles": { "inputs/mesh-config02.ugrid": "mesh.ugrid" } }
will copy the file
inputs/mesh-config02.ugridinto the run folder but name itmesh.ugridthere.- Call:
>>> cntl.copy_files(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Case index
- cntl:
- Versions:
2025-03-26
@ddalle: v1.02025-09-19
@ddalle: v1.1; CopyAsFiles
- abstractmethod declare_early_exit_case(i: int)¶
Change PhaseIters to current iteration for one case
- Call:
>>> cntl.declare_early_exit_case(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of overall control interface
- i:
int Case index
- cntl:
- Versions:
2026-02-25
@ddalle: v1.0
- abstractmethod edit_json(txt: str | None = None, opts: dict | None = None, fjson: str | None = None)¶
Edit JSON settings based on CLI
- Call:
>>> cntl.edit_json(txt=None, opts=None, fjson=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- txt: {
None} |str JSON-encoded text to apply
- opts: {
None} |dict Python object to apply to cntl.opts
- fjson: {
None} |str Name of JSON file to apply to cntl.opts
- cntl:
- Versions:
2026-06-08
@ddalle: v1.0
- abstractmethod exec_cntl_function_dict(funcspec: dict)¶
Execute a Cntl function, accessing user-specified modules
- Call:
>>> v = cntl.exec_cntl_function_dict(funcspec)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- funcspec:
dict Function opts parsed by
UserFuncOpts
- cntl:
- Outputs:
- v: any
Output from execution of function
- Versions:
2025-03-28
@ddalle: v1.0
- abstractmethod exec_cntlfunction(funcspec: str | dict) Any¶
Execute a Cntl function, accessing user-specified modules
- Call:
>>> v = cntl.exec_cntlfunction(funcname) >>> v = cntl.exec_cntlfunction(funcspec)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- funcname:
str Name of function to execute, e.g.
"mymod.myfunc"- funcspec:
dict Function opts parsed by
UserFuncOpts
- cntl:
- Outputs:
- v: any
Output from execution of function
- Versions:
2025-03-28
@ddalle: v1.0
- abstractmethod exec_cntlfunction_str(funcname: str) Any¶
Execute a function from cntl.modules
- Call:
>>> v = cntl.exec_modfunction(funcname, a, kw, name=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- funcname:
str Name of function to execute, e.g.
"mymod.myfunc"
- cntl:
- Outputs:
- v: any
Output from execution of function
- Versions:
2025-03-28
@ddalle: v1.0
- abstractmethod exec_modfunction(funcname: str, a: tuple | list | None = None, kw: dict | None = None, name: str | None = None) Any¶
Execute a function from cntl.modules
- Call:
>>> v = cntl.exec_modfunction(funcname, a, kw, name=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- funcname:
str Name of function to execute, e.g.
"mymod.myfunc"- a: {
None} |tuple Positional arguments to called function
- kw: {
None} |dict Keyworkd arguments to called function
- name: {
None} |str Hook name to use in status update
- cntl:
- Outputs:
- v: any
Output from execution of function
- Versions:
2022-04-12
@ddalle: v1.02025-03-28
@ddalle: v1.1; improve error messages
- abstractmethod genr8_opts_hash() str¶
Generate hash from current options dictionary
- Call:
>>> h = cntl.genr8_opts_hash()
- Outputs:
- h:
str Hash generated from options dictionary
- h:
- Versions:
2026-06-10
@ddalle: v1.0
- abstractmethod genr8_opts_jsonl() str¶
Generate single-line JSON string from current options
- Call:
>>> jsonl = cntl.genr8_opts_jsonl()
- Outputs:
- jsonl:
str Canonical single-line JSON representation of options
- jsonl:
- Versions:
2026-06-10
@ddalle: v1.0
- abstractmethod get_databook_comp_nmin(comp: str) int¶
Calculate the min iterations required for a DataBook comp
- Call:
>>> n = cntl.get_databook_comp_nmin(comp)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- comp:
str Name of DataBook component
- cntl:
- Outputs:
- n:
int Iteration number
- n:
- Versions:
2025-07-29
@ddalle: v1.0
- abstractmethod get_funcname(frame: int = 1) str¶
Get name of calling function, mostly for log messages
- abstractmethod get_log_level() int¶
Get the current logging level
- Call:
>>> loglvl = cntl.get_log_level()
- Outputs:
- loglvl:
int Logging level (e.g., 10 for DEBUG, 20 for INFO)
- loglvl:
- Versions:
2026-06-10
@ddalle: v1.0
- abstractmethod get_logger() CntlLogger¶
Get current logger and/or initialize one
- Call:
>>> logger = cntl.get_logger()
- Inputs:
- cntl:
Cntl CAPE run matrix control instance
- cntl:
- Outputs:
- logger:
CntlLogger Run matrix logger instance
- logger:
- Versions:
2025-04-30
@ddalle: v1.0
- abstractmethod get_opts_hash(f: bool = False) str¶
Get hash of current options, with optional recalculation
- Call:
>>> h = cntl.get_opts_hash(f=False)
- Inputs:
- f:
True| {False} Option to force recalculation
- f:
- Outputs:
- h:
str Hash of current options
- h:
- Versions:
2026-06-10
@ddalle: v1.0
- abstractmethod get_opts_jsonl(f: bool = False) str¶
Get current options as a single-line JSON string
- Call:
>>> jsonl = cntl.get_opts_jsonl(f=False)
- Inputs:
- f:
True| {False} Option to force recalculation
- f:
- Outputs:
- jsonl:
str Single-line JSON representation of options
- jsonl:
- Versions:
2026-06-10
@ddalle: v1.0
- abstractmethod get_pbs_jobs(force: bool = False, u: str | None = None, server: str | None = None, qstat: bool = True) dict¶
Get dictionary of current jobs active by one user
- Call:
>>> jobs = cntl.get_pbs_jobs(force=False, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- force:
True| {False} Query current queue even if cntl.jobs exists
- u: {
None} |str User name (defaults to process username)
- server: {
None} |str Name of non-default PBS/Slurm server
- cntl:
- Outputs:
- jobs:
dict Information on each job by ID number
- jobs:
- Versions:
2024-01-12
@ddalle: v1.02024-08-22
@ddalle: v1.1; add qstat option2025-05-01
@ddalle: v1.2; simplify flow
- abstractmethod get_phase_niter(i: int, j: int) int¶
Get number of steps for one call of phase j in case i
- Call:
>>> niter = cntl.get_Phase_inter(i, j)
- Inputs:
- cntl:
cape.pyfun.cntl.Cntl CAPE main control instance
- i:
int Case index
- j:
int Phase number
- cntl:
- Outputs:
- niter:
int Number of iterations for phase j; may be specific to case i
- niter:
- Versions:
2025-08-11
@ddalle: v1.0
- abstractmethod get_report_comps(rep: str | None = None) list¶
Get list of components and coefficients in given report
- Call:
>>> comps = cntl.get_report_comps(rep=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE main control instance
- rep: {
None} |str Name of report
- cntl:
- Outputs:
- abstractmethod get_runmatrix_keys(keyname: str | None = None) dict¶
Get main properties of some run matrix keys
- Call:
>>> props = cntl.get_runmatrix_keys(keyname=None)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- keyname: {
None} |str Wild-card pattern that keys must match
- cntl:
- Outputs:
- props:
dict Type and DType for matching run matrix keys
- props:
- abstractmethod get_transformation_matrix(topts: dict, i: int) ndarray | None¶
Calculate rotation matrix for a databook transformation
- Call:
>>> mat = cntl.get_transformation_matrix(topts, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- topts:
dict Definitions for transformation
- i:
int Case number
- cntl:
- Outputs:
- mat:
None|np.ndarray[float] Rotation matrix if topts is a rotation
- mat:
- Versions:
2025-01-30
@ddalle: v1.0
- abstractmethod getval(opt: str, i: int) Any¶
Get run matrix or case status value for one case
- Call:
>>> v = cntl.getval(opt, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- opt:
str Name of option or run matrix key
- i:
int Case index
- cntl:
- Outputs:
- v:
Any Value of option opt for case i
- v:
- Versions:
2025-06-16
@ddalle: v1.0
- abstractmethod getvalstr(opt: str, i: int) str¶
Get value of run matrix variable as string
- Call:
>>> txt = cntl.getvalstr(opt, i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- opt:
str Name of option or run matrix key
- i:
int Case index
- cntl:
- Outputs:
- txt:
str Text of value of option opt for case i
- txt:
- Versions:
2025-06-16
@ddalle: v1.0
- abstractmethod import_module(modname: str)¶
Import a module by name, if possible
- Call:
>>> mod = cntl.import_module(modname)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall control interface
- modname:
str Name of module to import
- cntl:
- Outputs:
- mod: module
Python module
- Versions:
2025-03-28
@ddalle: v1.0
- abstractmethod init_post()¶
Do
py{x}specific initialization actions- Call:
>>> cntl.init_post()
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- cntl:
- Versions:
2023-05-31
@ddalle: v1.0
- abstractmethod inspect_json(jq: str = '.', maxdepth: int | None = None) Any¶
Inspect an item or subset of the expanded options
This uses a simple subset of the path syntax used by the common system utility
jq -r; supported syntax is:.: the entire options.KEY: one key from a dict."KEY": dict key containing spaces or other specials.["KEY"]: dict key using string syntax.[I]or.KEY[I]: index into a list.KEY[I1:I2]: slice of a list
If maxdepth is given, any dicts deeper than maxdepth levels (relative to the selected item) are replaced by
{}in the output.- Call:
>>> v = cntl.inspect_json(jq=".", maxdepth=None)
- Inputs:
- Outputs:
- v: any
Selected item or subset of cntl.opts
- Examples:
>>> cntl.inspect_json(".PBS.select") 10 >>> cntl.inspect_json(".PBS", maxdepth=0) {}
- Versions:
2026-08-30: v1.0
- abstractmethod link_files(i: int)¶
Link files from Mesh section
This applies to both LinkFiles and LinkAsFiles in the Mesh section. The former will copy a given file into the run folder for case i using the base name of the original (source) file. Using
"Mesh": { "LinkAsFiles": { "inputs/mesh-config02.ugrid": "mesh.ugrid" } }
will create a link (using the absolute path) from
inputs/mesh-config02.ugridtomesh.ugridin the case run folder.- Call:
>>> cntl.link_files(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Case index
- cntl:
- Versions:
2025-03-26
@ddalle: v1.02025-09-19
@ddalle: v1.1; LinkAsFiles
- abstractmethod log_cmd(msg: str, title: str | None = None, parent: int = 0)¶
Write a message to CLI log
- Call:
>>> runner.log_cmd(msg, title, parent=0)
- Inputs:
- Versions:
2025-04-30
@ddalle: v1.0
- abstractmethod log_cntl(f: bool = False)¶
Record the current JSON settings and document any changes
- Call:
>>> cntl.log_cntl(f=True)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- f: :
True| {False} Force recalculation of hash of current options
- cntl:
- abstractmethod log_main(msg: str, title: str | None = None, parent: int = 0)¶
Write a message to primary log
- Call:
>>> runner.log_main(msg, title, parent=0)
- Inputs:
- Versions:
2025-04-30
@ddalle: v1.0
- log_parser(parser: ArgReader)¶
Log a CLI command based on parser
- Call:
>>> cntl.log_parser(parser)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- parser:
cape.argread.ArgReader CLI parser based on
cape.cfdx.cli
- cntl:
- Versions:
2026-01-05
@ddalle: v1.0
- abstractmethod make_case_folder(i: int)¶
Create folder(s) if needed for case i
- Call:
>>> cntl.make_case_folder(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- i:
int Index of case to analyze
- cntl:
- Versions:
2023-08-25
@ddalle: v1.0 (CreateFolder)2023-10-20
@ddalle: v2.0; support arbitrary depth
- abstractmethod prep_aflr3(i: int)¶
Prepare the AFLR3 surface file (
.surf) for a caseWrites
<proj>.surfto the case folder when theaflr3option is enabled. Does nothing otherwise.- Call:
>>> cntl.prep_aflr3(i)
- Inputs:
- cntl:
Cntl CAPE run matrix control instance
- i:
int Case index
- cntl:
- Versions:
2026-05-02
@ddalle: v1.0
- abstractmethod prep_intersect(i: int)¶
Prepare triangulation input files for
intersectWrites the volume, component-ID, and farfield triangulation files needed by the Cart3D
intersecttool, or writes a plain.i.triwhen onlyverifyis requested. Does nothing if neither option is set.- Call:
>>> cntl.prep_intersect(i)
- Inputs:
- cntl:
Cntl CAPE run matrix control instance
- i:
int Case index
- cntl:
- Versions:
2026-05-02
@ddalle: v1.0
- abstractmethod prep_tri_write(i: int)¶
Write the surface triangulation file to a case folder
Writes
<proj>.<ext>(typically.trior.fro) whenWriteTriis set and neitheraflr3norintersectis active (those options handle their own triangulation output).- Call:
>>> cntl.prep_tri_write(i)
- Inputs:
- cntl:
Cntl CAPE run matrix control instance
- i:
int Case index
- cntl:
- Versions:
2026-05-02
@ddalle: v1.0
- abstractmethod prepare_mesh_overset(i: int)¶
Copy/link mesh files from config folder into case folder
- Call:
>>> cntl.prepare_mesh_overset(i)
- Inputs:
- cntl:
Cntl CAPE run matrix controller instance
- i:
int Case index
- cntl:
- Versions:
2024-10-10
@ddalle: v1.0
- abstractmethod preprocess_kwargs(kw: dict)¶
Preprocess command-line arguments and flags/keywords
This will effect the following CLI options:
- --cons CONS
Comma-separated constraints split into a list
- -x FPY
Each
-xargument is executed (can be repeated)- -I INDS
Convert INDS like
3-6,8to[3, 4, 5, 8]
- Call:
>>> opts = cntl.cli_preprocess(*a, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Overall CAPE control instance
- kw:
dict[True|False|str] CLI keyword arguments and flags, modified in-place
- cntl:
- Versions:
2024-12-19
@ddalle: v1.0
- abstractmethod process_mesh_filename(fname: str, fproj: str | None = None) str¶
Return a mesh file name using the project root name
- Call:
>>> fout = cntl.process_mesh_filename(fname, fproj=None)
- Inputs:
- cntl:
Cntl Run matrix control instance for unstructured-mesh solver
- fname:
str Raw file name to be converted to case-folder file name
- fproj: {
None} | :class;`str` Project root name
- cntl:
- Outputs:
- fout:
str Name of file name using project name as prefix
- fout:
- Versions:
2016-04-05
@ddalle: v1.0 (pyfun)2023-03-15
@ddalle: v1.1; add fproj2024-10-22
@ddalle: v2.0; move tocfdx
- abstractmethod qdel_cases(**kw)¶
Kill/stop PBS job of cases
This function deletes a case’s PBS/Slurm jobbut not delete the foder for a case.
- Call:
>>> cntl.qdel_cases(**kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- I: {
None} |list[int] List of cases to delete
- kw:
dict Other subset parameters, e.g. re, cons
- cntl:
- Versions:
2025-06-22
@ddalle: v1.0
- abstractmethod read_case_json(i: int) RunControlOpts¶
Read
case.jsonfile from case i if possible- Call:
>>> rc = cntl.read_case_json(i)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Instance of control class
- i:
int Case index
- cntl:
- Outputs:
- rc:
None|dict Run control interface read from
case.jsonfile
- rc:
- Versions:
2016-12-12
@ddalle: v1.02017-04-12
@ddalle: v1.1; add tocape.cfdx2023-06-29
@ddalle: v2.0; use _case_mod2023-07-07
@ddalle: v2.1; use CaseRunner
- abstractmethod read_dex(comp: str, force: bool = False)¶
Read a DataBook component using
DataExchanger- Call:
>>> db = cntl.read_dex(comp, force=False)
- Inputs:
- cntl:
Cntl CAPE run matrix controller instance
- comp:
str Name of component to read
- force:
True| {False} Option to re-read even if present in database
- cntl:
- Outputs:
- db:
cape.cfdx.dex.DataExchanger Data extracted from run matrix for comp comp
- db:
- Versions:
2025-07-25
@ddalle: v1.0
- abstractmethod read_options(fjson: str)¶
Read options using appropriate class
This allows users to set warning mode via an environment variable.
- Call:
>>> cntl.read_options(fjson)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- fjson:
str Name of JSON file to read
- cntl:
- Versions:
2023-05-26
@ddalle: v1.0; forked from __init__()2023-12-13
@ddalle: v1.1; add RootDir and JSONFile
- abstractmethod rm_cases(prompt: bool = True, **kw) int¶
Delete one or more cases
This function deletes a case’s PBS job and removes the entire directory. By default, the method prompts for confirmation before deleting; set prompt to
Falseto delete without prompt, but only cases with 0 iterations can be deleted this way.- Call:
>>> n = cntl.rm_cases(prompt=True, **kw)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl Cape control interface
- prompt: {
True} |False Whether or not to prompt user before deleting case
- I: {
None} |list[int] List of cases to delete
- kw:
dict Other subset parameters, e.g. re, cons
- cntl:
- Outputs:
- n:
int Number of folders deleted
- n:
- Versions:
2025-06-20
@ddalle: v1.0
- abstractmethod run_batch(argv: list) str¶
Write and submit PBS/Slurm script for a CLI
- Call:
>>> jobid = cntl.run_batch(argv)
- Inputs:
- cntl:
cape.cfdx.cntl.Cntl CAPE run matrix control instance
- argv:
list[str] List of command-line inputs
- cntl:
- Outputs:
- jobid:
str PBS/Slurm job number/ID
- jobid:
- Versions:
2024-12-20
@ddalle: v1.02026-04-28
@ddalle: v1.1; update file name
- abstractmethod update_dex(**kw)¶
Extract one or more DataBook components
- abstractmethod update_dex_comp(comp: str, **kw)¶
Update a DataBook component
- Call:
>>> n = cntl.update_dex_comp(comp, **kw)
- Inputs:
- cntl:
Cntl CAPE run matrix controller instance
- comp:
str Name of component to read
- I: {
None} |np.ndarray[int] Indices of cases to process
- cntl:
- Versions:
2025-07-29
@ddalle: v1.0