cape.pycart.case: Case Control Module

cape.pycart.case: Case Control Module

This module contains the important function case.run_flowCart(), which actually runs flowCart or aero.csh, along with the utilities that support it.

For instance, it contains function to determine how many iterations have been run, what the working folder is (e.g. ., adapt00, etc.), and what command-line options to run.

It also contains Cart3D-specific versions of some of the generic methods from cape.case. All of the functions in that module are also available here.

class cape.pycart.case.CaseRunner(fdir=None)
check_error()

Check iteration counts and residual change for most recent run

Call:
>>> runner.check_error()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
ierr: int

Return code

Versions:
  • 2016-03-04 @ddalle: v1.0 (CheckSuccess)

check_unsteady_history(fname='history.dat') bool

Check if the current history ends with an unsteady iteration

Call:
>>> q = runner.check_unsteady_history(fname='history.dat')
Inputs:
runner: CaseRunner

Controller to run one case of solver

fname: str

Name of file to read

Outputs:
q: True | False

Whether the last iteration of fname has a ‘.’ in it

Versions:
  • 2014-12-17 @ddalle: v1.0 (CheckUnsteadyHistory)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

finalize_files(j: int)

Clean up files names after running one cycle of phase j

Call:
>>> runner.finalize_files(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2016-03-04 @ddalle: v1.0 (FinalizeFiles)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_check_resub_iter()

Get total iteration number of most recent check file

This is the sum of the most recent steady iteration number and unsteady iteration number.

Call:
>>> n = self.get_check_resub_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
n: int

Index of most recent check file

Versions:
  • 2014-11-28 @ddalle: v1.0 (GetRestartIter)

  • 2014-11-29 @ddalle: v1.1 (GetCheckResubIter)

  • 2023-07-10 @ddalle: v1.2; rename, instance method

get_current_resid()

Get the most recent iteration including unsaved progress

Iteration numbers from time-accurate restarts are corrected to match the global iteration numbering.

Call:
>>> L1 = runner.get_current_resid()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
L1: float

Last L1 residual

Versions:
  • 2015-01-02 @ddalle: v1.0 (GetCurrentResid)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_first_resid()

Get the first iteration

Call:
>>> L1 = GetFirstResid()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
L1: float

First L1 residual

Versions:
  • 2015-07-22 @ddalle: v1.0 (GetFirstResid)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_history_iter(fname='history.dat') float

Read last iteration number from a history.dat file

Call:
>>> n = runner.get_history_iter(fname='history.dat')
Inputs:
runner: CaseRunner

Controller to run one case of solver

fname: {"history.dat"} | str

Name of file to read

Outputs:
n: float

Last iteration number

Versions:
  • 2014-11-24 @ddalle: v1.0 (GetHistoryIter)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_history_resid(fname='history.dat')

Get the last residual in a history.dat file

Call:
>>> L1 = runner.get_history_resid(fname='history.dat')
Inputs:
runner: CaseRunner

Controller to run one case of solver

fname: str

Name of file to read

Outputs:
L1: float

Last L1 residual

Versions:
  • 2015-01-02 @ddalle: v1.0 (GetHistoryResid)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_steady_iter()

Get iteration number of most recent steady check file

Call:
>>> n = runner.get_steady_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
n: int

Index of most recent check file

Versions:
  • 2014-10-02 @ddalle: v1.0 (GetRestartIter)

  • 2014-11-28 @ddalle: v1.1 (GetSteadyIter)

  • 2023-06-06 @ddalle: v1.2; support BEST/FLOW/

  • 2023-07-10 @ddalle: v2.3; rename, instance method

get_unsteady_iter()

Get iteration number of most recent unsteady check file

Call:
>>> n = runner.get_unsteady_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
n: int

Index of most recent check file

Versions:
  • 2014-11-28 @ddalle: v1.0 (GetUnsteadyIter)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

get_working_folder() str

Get working folder, ., adapt??/, or adapt??/FLOW/

This function must be called from the top level of a case.

Call:
>>> fdir = runner.get_working_folder()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
fdir: str

Most recently used working folder with a history file

Versions:
  • 2014-11-24 @ddalle: v1.0 (GetWorkingFolder)

  • 2023-06-05 @ddalle: v2.0; support adapt??/FLOW/

  • 2023-07-10 @ddalle: v2.1; rename, instance method

getx_iter()

Get the residual of the most recent iteration

Call:
>>> n = runner.getx_iter()
Outputs:
n: int

Most recent index written to history.dat

Versions:
  • 2014-11-28 @ddalle: v1.0 (GetCurrentIter)

  • 2023-06-06 @ddalle: v1.1; check adapt??/FLOW/

  • 2023-07-10 @ddalle: v1.2; rename, instance method

getx_restart_iter()

Get total iteration number of most recent check file

This is the sum of the most recent steady iteration and the most recent unsteady iteration.

Call:
>>> n = runner.getx_restart_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
n: int

Index of most recent check file

Versions:
  • 2014-11-28 @ddalle: v1.0 (GetRestartIter)

  • 2023-07-10 @ddalle: v1.1; rename, instance method

prepare_files(j: int)

Prepare file names appropriate to run phase i of Cart3D

Call:
>>> runner.prepare_files(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2016-03-04 @ddalle: v1.0 (PrepareFiles)

  • 2023-07-09 @ddalle: v1.1; rename, instance method

run_autoInputs(j: int)

Run autoInputs if necessary

Call:
>>> runner.run_autoInputs(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2016-04-06 @ddalle: v1.0 (CaseAutoInputs)

  • 2023-07-09 @ddalle: v2.0; rename, instance method

run_cubes(j: int)

Run cubes and mgPrep to create multigrid volume mesh

Call:
>>> runner.run_cubes(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2016-04-06 @ddalle: v1.0 (CaseCubes)

  • 2023-07-09 @ddalle: v2.0; rename, instance method

run_phase(j: int)

Run one phase using appropriate commands

Call:
>>> runner.run_phase(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2016-03-04 @ddalle: v1.0 (RunPhase)

  • 2023-06-02 @ddalle: v1.1

  • 2023-07-09 @ddalle: v1.2; rename, instance method

run_phase_adaptive(j: int) int

Run one phase using adaptive commands

Call:
>>> ierr = runner.run_phase_adaptive(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Outputs:
ierr: int

Return code

Versions:
  • 2016-03-04 @ddalle: v1.0 (RunAdaptive)

  • 2023-07-09 @ddalle: v1.1; rename; instance method

run_phase_fixed(j: int) int

Run flowCart the nominal way

Call:
>>> ierr = runner.run_phase_fixed(j)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Outputs:
ierr: int

Return code

Versions:
  • 2016-03-04 @ddalle: v1.0 (RunFixed)

  • 2023-07-09 @ddalle: v1.1; rename, instance method

run_phase_with_restarts(j)

Run flowCart a few iters at a time for averaging purposes

Call:
>>> RunWithRestarts(rc, i)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: int

Phase number

Outputs:
ierr: int

Return code

Versions:
  • 2016-03-04 @ddalle: v1.0

set_restart_iter(n=None, ntd=None)

Set a given check file as the restart point

Call:
>>> runner.set_restart_iter(n=None, ntd=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

n: {None} | int

Restart iteration number, defaults to most recent available

ntd: {None} | int

Unsteady iteration number

Versions:
  • 2014-10-02 @ddalle: v1.0 (SetRestartIter)

  • 2014-11-28 @ddalle: v1.1; support time-accurate

  • 2023-07-10 @ddalle: v1.2; rename, instance method

cape.pycart.case.GetTriqFile()

Get most recent triq file and its associated iterations

Call:
>>> ftriq, n, i0, i1 = GetTriqFile()
Outputs:
ftriq: str

Name of triq file

n: int

Number of iterations included

i0: int

First iteration in the averaging

i1: int

Last iteration in the averaging

Versions:
  • 2015-09-16 @ddalle: v1.0

  • 2021-12-09 @ddalle: v1.1
    • Check for adapt??/ folder w/o triq file

  • 2022-06-06 @ddalle: v1.2; check adapt??/FLOW/

cape.pycart.case.LinkFromGlob(fname, fglb, isplit=-2, csplit='.')

Link the most recent file to a basic unmarked file name

The function will attempt to map numbered or adapted file names using the most recent iteration or adaptation. The following gives examples of links that could be created using Components.i.plt for fname and Components.[0-9]*.plt for fglb.

  • Components.i.plt (no link)

  • Components.01000.plt –> Components.i.plt

  • adapt03/Components.i.plt –> Components.i.plt

Call:
>>> LinkFromGlob(fname, fglb, isplit=-2, csplit='.')
Inputs:
fname: str

Name of unmarked file, like Components.i.plt

fglb: str

Glob for marked file names

isplit: int

Which value of f.split() to use to get index number

csplit: str

Character on which to split to find indices, usually '.'

Versions:
  • 2015-11-20 @ddalle: v1.0

cape.pycart.case.LinkPLT()

Link the most recent Tecplot files to fixed file names

Uses file names Components.i.plt and cutPlanes.plt

Call:
>>> LinkPLT()
Versions:
  • 2015-03-10 @ddalle: v1.0

  • 2015-11-20 @ddalle: Delegate work and support *.dat files

cape.pycart.case.run_flowCart()

Setup and run flowCart, mpi_flowCart command

Call:
>>> run_flowCart()
Versions:
  • 2014-10-02 @ddalle: v1.0

  • 2014-12-18 @ddalle: v1.1; Added TarAdapt()

  • 2021-10-08 @ddalle: v1.2; removed args

  • 2023-07-08 @ddalle: v2.0; use CaseRunner