cape.pyfun.case: FUN3D case control module

This module contains the important function case.run_fun3d(), which actually runs nodet or nodet_mpi, along with the utilities that support it.

It also contains FUN3D-specific versions of some of the generic methods from cape.case. For instance the function GetCurrentIter() determines how many FUN3D iterations have been run in the current folder, which is obviously a solver-specific task. It also contains the function LinkPLT(), which creates links to fixed Tecplot file names from the most recent output created by FUN3D.

All of the functions from cape.case are imported here. Thus they are available unless specifically overwritten by specific cape.pyfun versions.

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

Check for errors before continuing

Currently the following checks are performed.

  • Check for NaN residual in the output file

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

Controller to run one case of solver

Outputs:
ierr: int

Return code

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

  • 2023-06-02 @ddalle: v1.1; return bool; don’t raise

  • 2023-07-06 @ddalle: v1.2; instance method

copy_hist(j: int)

Copy all FM and residual histories

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

Controller to run one case of solver

j: int

Phase number to use for storing histories

Versions:
  • 2016-10-28 @ddalle: v1.0 (CopyHist)

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

finalize_files(j: int)

Clean up files 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-04-14 @ddalle: v1.0 (FinalizeFiles)

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

get_plt_file()

Get most recent boundary plt file and its metadata

Call:
>>> fplt, n, i0, i1 = runner.get_plt_file()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
fplt: str

Name of plt file

n: int

Number of iterations included

i0: int

First iteration in the averaging

i1: int

Last iteration in the averaging

Versions:
  • 2016-12-20 @ddalle: v1.0 (GetPltFile)

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

get_project_rootname(j=None)

Read namelist and return project namelist

Call:
>>> rname = runner.get_project_rootname(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase number

nml: cape.pyfun.namelist.Namelist

Namelist interface; overrides rc and i if used

Outputs:
rname: str

Project rootname

Versions:
  • 2015-10-19 @ddalle: v1.0

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

getx_iter()

Calculate most recent FUN3D iteration

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

Controller to run one case of solver

Outputs:
n: int

Iteration number

Versions:
  • 2015-10-19 @ddalle: v1.0

  • 2016-04-28 @ddalle: v1.1; Flow/ folder

  • 2023-06-27 @ddalle: v2.0; instance method

getx_iter_histfile(fname: str)

Get the most recent iteration number from a history file

Call:
>>> n = runner.getx_iter_histfile(fname)
Inputs:
fname: {"pyfun_hist.dat"} | str

Name of file to read

Outputs:
n: int | None

Most recent iteration number

Versions:
  • 2016-05-04 @ddalle: v1.0; from GetHistoryIter()

  • 2023-06-27 @ddalle: v2.0; rename GetHistoryIterFile

getx_iter_history()

Get the most recent iteration number for a history file

Call:
>>> nh, n = runner.getx_history_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
nh: int

Iterations from previous cases before Fun3D deleted history

n: int | None

Most recent iteration number

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

  • 2016-04-28 @ddalle: v1.1; for Flow/ folder

  • 2016-10-29 @ddalle: v1.2; handle Fun3D iteration reset

  • 2017-02-23 @ddalle: v1.3; handle adapt project shift

  • 2023-06-27 @ddalle: v2.0; instance method

getx_iter_running()

Get the most recent iteration number for a running file

Call:
>>> n = case.GetRunningIter()
Outputs:
n: int | None

Most recent iteration number

Versions:
  • 2015-10-19 @ddalle: v1.0

  • 2016-04-28 @ddalle: v1.1; handle Flow/ folder

  • 2023-05-27 @ddalle; v2.0; instance method

getx_phase(n: int)

Determine the phase number based on files in folder

Call:
>>> i = case.GetPhaseNumber(rc)
Inputs:
rc: RunControlOpts

Options interface for run control

Outputs:
i: int

Most appropriate phase number for a restart

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

  • 2015-10-19 @ddalle: v1.0 (GetPhaseNumber)

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

getx_restart_iter()

Calculate number of iteration if case should restart

Call:
>>> nr = runner.gets_restart_iter()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
nr: int

Restart iteration number

Versions:
  • 2015-10-19 @ddalle: v1.0

  • 2016-04-19 @ddalle: v1.1; check STDIO

  • 2020-01-15 @ddalle: v1.2; sort globs better

  • 2023-07-05 @ddalle: v1.3; moved to instance method

init_post()

Custom initialization for pyfun

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

Controller to run one case of solver

Versions:
  • 2023-06-28 @ddalle: v1.0

Link the most recent Tecplot files to fixed file names

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

Controller to run one case of solver

Versions:
  • 2016-10-24 @ddalle: v1.0 (LinkPLT)

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

prepare_files(j: int)

Prepare file names appropriate to run phase i of FUN3D

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

Controller to run one case of solver

j: int

Phase number

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

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

prepare_warmstart()

Process WarmStart settings and copy files if appropriate

Call:
>>> warmstart = runner.prepare_warmstart()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
warmstart: True | False

Whether or not case is a valid warm-start

Versions:
  • 2023-03-14 @ddalle: v1.0 (PrepareWarmStart)

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

read_namelist(j=None)

Read case namelist file

Call:
>>> nml = runner.read_namelist(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase number

Outputs:
nml: cape.pyfun.namelist.Namelist

Namelist interface

Versions:
  • 2015-10-19 @ddalle: v1.0

  • 2023-06-27 @ddalle: v2.0; instance method

run_nodet_adapt(j: int)

Run Fun3D nodet with adaptation for refine/one

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2023-07-12 @jmeeroff: v1.0; from run_phase

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-04-13 @ddalle: v1.0 (RunPhase())

  • 2023-06-02 @ddalle: v2.0

  • 2023-06-27 @ddalle: v3.0, instance method

run_refine_translate(j: int)

Run refine transalte to create input meshb file for adaptation

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2023-07-17 @jmeeroff: v1.0; from run_phase

set_restart_iter(n=None)

Set a given check file as the restart point

Call:
>>> runner.set_restart_iter(n=None)
Inputs:
rc: RunControlOpts

Run control options

n: {None} int

Restart iteration number, defaults to latest available

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

  • 2023-03-14 @ddalle: v1.1; add WarmStart

  • 2023-07-06 @ddalle: v1.2; instance method

cape.pyfun.case.GetFromGlob(fglb, fname=None)

Find the most recently edited file matching a glob

Call:
>>> fname = case.GetFromGlob(fglb, fname=None)
>>> fname = case.GetFromGlob(fglbs, fname=None)
Inputs:
fglb: str

Glob for targeted file names

fglbs: list[str]

Multiple glob file name patterns

fname: {None} | str

Optional alternate file name to consider

Outputs:
fbest: str

Name of file matching glob that was most recently modified

Versions:
  • 2016-12-19 @ddalle: v1.0

  • 2023-02-03 @ddalle: v1.1; add fname input

  • 2023-03-26 @ddalle: v1.2; multiple fglbs

cape.pyfun.case.GetPltFile()

Get most recent boundary plt file and its metadata

Call:
>>> fplt, n, i0, i1 = GetPltFile()
Outputs:
fplt: str

Name of plt file

n: int

Number of iterations included

i0: int

First iteration in the averaging

i1: int

Last iteration in the averaging

Versions:
  • 2016-12-20 @ddalle: v1.0 (GetPltFile)

  • 2023-07-06 @ddalle: v1.1; use CaseRunner

cape.pyfun.case.LinkFromGlob(fname, fglb)

Link the most recent file to a generic Tecplot file name

Call:
>>> case.LinkFromGlob(fname, fglb)
>>> case.LinkFromGlob(fname, fglbs)
Inputs:
fname: str

Name of unmarked file, like Components.i.plt

fglb: str

Glob for marked file names

fglbs: list[str]

Multiple glob file name patterns

Versions:
  • 2016-10-24 @ddalle: v1.0

  • 2023-03-26 @ddalle: v1.1; multiple fglbs

cape.pyfun.case.LinkPLT()

Link the most recent Tecplot files to fixed file names

Call:
>>> LinkPLT()
Versions:
  • 2016-10-24 @ddalle: v1.0

  • 2023-07-06 @ddalle: v1.1; use CaseRunner

cape.pyfun.case.run_fun3d()

Setup and run the appropriate FUN3D command

Call:
>>> run_fun3d()
Versions:
  • 2015-10-19 @ddalle: v1.0

  • 2016-04-05 @ddalle: v1.1; add AFLR3 hook

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