cape.pylava.casecntl: LAVA case control module

This module contains LAVACURV-specific versions of some of the generic methods from cape.cfdx.case.

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

class cape.pylava.casecntl.CaseRunner(fdir: str | None = None)
check_alt_exit(j: int | None = None) → bool

Check for solver-selected exit, e.g. convergence target hit

Call:
>>> q = runner.check_alt_exit(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase index

Outputs:
q: bool

True if no listed files have been modified recently

Versions:
  • 2025-08-14 @ddalle: v1.0

check_complete() → bool

Check if a case is complete (DONE)

In addition to the standard CAPE checks, this version checks residuals convergence udner certain conditions.

Call:
>>> q = runner.check_complete()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Versions:
  • 2024-09-16 @sneuhoff: v1.0

  • 2024-10-11 @ddalle: v2.0; use parent method directly

collect_cutplane(nsurf: int = 1, nbatch: int | None = None, mode: str | int = 'adaptive', clean: bool = False, nmax: int | None = None, nproc: int | None = None)

Combine data from LAVA cut-plane VTK files into batches

Call:
>>> runner.collect_cutplane(nsurf, nbatch, **kw)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: {1} | int

LAVA surface number

nbatch: {None} | int

Number of snapshots to collect; default value is BatchSize from case.json

clean: True | {False}

Option to delete .vtk files after processing

nmax: {None} | int

Maximum number of snapshots to collect

mode: {“adaptive”} | “constant” | “raw” | “fixed”

Mode of how to save data, raw data, triangulated, and interpolated to a common mesh. If the data has no mesh adaptation, "constant" is recommended

nproc: {None} | int

Number of parallel processes to process cut planes

Versions:
  • 2026-04-10 @ddalle: v1.0

  • 2026-07-07 @ddalle: v1.1; add “constant” mode

collect_cutplanes(nsurf: list | int | None = None, nbatch: int | None = None, clean: bool = False, nmax: int | None = None, mode: str | int = 'adaptive', nproc: int | None = None)

Collect VTK cut-plane data from oner or more isosurfaces

Call:
>>> runner.collect_cutplanes(nsurf=1, nbatch=None, **kw)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: None} | int | list

Isosurface index(es) (0-based) or all if None

nbatch: {None} | int

Number of snapshots to collect; default value is BatchSize from case.json

clean: True | {False}

Option to delete .vtk files after processing

nmax: {None} | int

Maximum number of snapshots to collect

mode: "raw" | {"adaptive"} | "fixed"

Mode of how to save data, raw data, triangulated, and interpolated to a common mesh. If the data has no mesh adaptation, "fixed" is recommended

nproc: {None} | int

Number of parallel processes to process cut planes

Versions:
  • 2026-04-10 @ddalle: v1.0

collect_surfdata(nsurf: int = 1, nbatch: int | None = None, clean: bool = False, nmax: int | None = None, nproc: int | None = None)

Combine data from LAVA surface VTK files into batches

Call:
>>> runner.collect_surfdata(nsurf, nbatch, clean, nmax=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: {1} | int

LAVA surface number (1-based)

nbatch: {None} | int

Number of snapshots to collect; default value is BatchSize from case.json

clean: True | {False}

Option to delete .vtk files after processing

nmax: {None} | int

Maximum number of snapshots to collect

nproc: {None} | int

Number of parallel processes to process surface data

Versions:
  • 2026-04-06 @ddalle: v1.0

  • 2026-06-05 @ddalle: v2.0; parallel fork architecture

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:
  • 2024-10-11 @ddalle: v1.0

  • 2026-06-26 @ddalle: v2.0; save old copies

finalize_lout(j: int)

Move the lout.0 file to lout.{j}.{n}

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2026-07-14 @ddalle: v1.0

find_cutplane_iters(nsurf: int, mode: str = 'adaptive') → ndarray

Find the iterations available of a cut-plane

Call:
>>> ns = runner.find_cutplane_iters(nsurf, mode="adaptive")
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

mode: {"adaptive"} | "raw" | "fixed"

Mode to use when checking batch file

Outputs:
ns: np.ndarray[int]

List of iteration numbers

find_surfdata_iters(nsurf: int) → ndarray

Find the iterations available of a surface data set

Call:
>>> ns = runner.find_surfdata_iters(nsurf)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

Outputs:
ns: np.ndarray[int]

List of iteration numbers

genr8_restart_regex() → str

Return a regular expression that matches all restart files

Call:
>>> pat = runner.genr8_restart_regex()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
pat: str

Regular expression pattern

Versions:
  • 2025-08-14 @ddalle: v1.0

get_ctu() → float

Get the most recent iteration Char. Time Unit value

Call:
>>> t = runner.get_ctu()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
t: float

Last time step (characteristic units)

Versions:
  • 2025-08-14 @sneuhoff: v1.0

get_ctu_max(j: int | None = None) → float

Get the characteristic time units cutoff for phase j

Call:
>>> t = runner.get_ctu_max()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
t: float

Last time step (characteristic units)

Versions:
  • 2025-08-15 @sneuhoff: v1.0

get_cutplanes() → list

Get list of cut-plane isosurface indices (1-based)

Call:
>>> surfs = runner.get_cutplanes()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
surfs: list[int]

List of isosurfaces that are cut planes

Versions:
  • 2026-04-10 @ddalle: v1.0

get_dex_args_post_pointprobe() → tuple

Get list of args prior to component name in CaseFM

Call:
>>> args = runner.get_dex_args_post_iterfm()
Inputs:
runner: CaseRunner

Controller to run one case of solver

Outputs:
args: tuple[str]

Tuple of one arg, runner

Versions:
  • 2025-09-25 @ddalle: v1.0

get_dex_iter_pointprobe(comp: str) → int

Get number of iterations available for a LAVA point probe

Call:
>>> n = runner.get_dex_iter_pointprobe(comp)
Inputs:
runner: CaseRunner

Controller to run one case of solver

comp: str

Name of DataBook component

Outputs:
n: int

Iteration count

Versions:
  • 2026-03-20 @ddalle: v1.0

get_ref_iter(nref: int | None = None) → int

Get reference iteration for flow viz, deferring to user val

Call:
>>> iref = runner.get_ref_iter(nref=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nref: {None} | int

Optional manual override

Ouptuts:
iref: int

Reference iteration option from case.json or nref

Versions:
  • 2026-04-10 @ddalle: v1.0

get_restart_file(j: int | None = None) → str | None

Get the most recent restart file for phase j

Call:
>>> restartfile = runner.get_restart_file(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase number

Versions:
  • 2024-11-05 @ddalle: v1.0

getx_iter(f: bool = True)

Get the most recent iteration number for a LAVA case

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

Controller to run one case of solver

Outputs:
n: int | None

Last iteration number

Versions:
  • 2024-08-02 @sneuhoff: v1.0

  • 2024-10-11 @ddalle: v2.0; use DataIterFile(meta=True)

getx_restart_iter() → int

Get total iteration number of most recent flow file

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:
  • 2024-09-16 @sneuhoff: v1.0

infer_cutplane_n(nsurf: int, n: int | None = None, mode: str = 'adaptive') → int

Infer iteration of latest available cut-plane data file

Returns n if an integer input is given.

Call:
>>> i = runner.infer_cutplane_n(nsurf, n=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

n: {None} | int

Optional iteration number

mode: {"adaptive"} | "raw" | "fixed"

Mode to use when checking batch file

Outputs:
i: int

Latest iter if n is None, otherwise n

infer_surfdata_n(nsurf: int, n: int | None = None) → int

Infer iteration of latest available surface data file

Returns n if an integer input is given.

Call:
>>> i = runner.infer_surfdata_n(nsurf, n=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

n: {None} | int

Optional iteration number

Outputs:
i: int

Latest iter if n is None, otherwise n

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 visualization files

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

Controller to run one case of solver

Versions:
  • 2025-07-25 @jmeeroff: v1.0

  • 2025-07-28 @ddalle: v1.1; bug for subfolder links

prepare_files(j: int)

Prepare files for phase j, LAVA-specific

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

Controller to run one case of solver

j: int

Phase index

Versions:
  • 2025-07-28 @ddalle: v1.0

prepare_restart(j: int)

Automatically configure a case to restart if appropriate

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2025-08-14 @ddalle: v1.0

prepare_restart_cartesian(j: int)

Automatically configure LAVA-Cartesian for restart

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2025-08-14 @ddalle: v1.0

read_cutplane(nsurf: int, n: int | None = None, mode: str = 'raw') → Umesh

Read a cut plane using best available method

Call:
>>> mesh = runner.read_cutplane(nsurf, n=None, mode="raw")
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

LAVA surface number (1-based)

n: int

Iteration number

mode: "raw" | {"adaptive"} | "fixed"

Mode of how to save data, raw data, triangulated, and interpolated to a common mesh. If the data has no mesh adaptation, "fixed" is recommended

Versions:
  • 2026-07-07 @ddalle: v1.0

read_cutplane_defn(surf: int) → dict | None

Read definition for a cut plane isosurface

Call:
>>> defn = runner.read_cutplane_defn(surf)
Inputs:
runner: CaseRunner

Controller to run one case of solver

surf: int

Isosurface number (1-based)

Outputs:
defn: dict

Definition of cutplane surf

Versions:
  • 2026-04-08 @ddalle: v1.0

read_cutplane_fixed(nsurf: int, n: int, nref: int | None = None) → Umesh | None

Read cut-plane data interpolated onto a fixed mesh

Call:
>>> mesh = runner.read_cutplane_fixed(nsurf, n)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index

n: int

Iteration number

nref: {None} | int

Pre-determined iteration to use as reference mesh

Outputs:
mesh: None | cape.gruvoc.umesh.Umesh

Triangulated cut plane instance

Versions:
  • 2026-04-09 @ddalle: v1.0

read_cutplane_meta(nsurf: int, mode: str) → DataKit

Read database of metadata for collected cutplane data

Call:
>>> db = runner.read_cutplane_meta(nsurf, mode)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

mode: str

Cutplane data storage mode

Outputs:
db: cape.dkit.rdb.DataKit

DataKit of which batch each iteration is located in

Versions:
  • 2026-04-05 @ddalle: v1.0

read_cutplane_raw(nsurf: int, n: int) → Umesh | None

Read raw cut-plane file exported by LAVA

Call:
>>> mesh = runner.read_cutplane_raw(nsurf, n)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index

n: int

Iteration number

Outputs:
mesh: None | cape.gruvoc.umesh.Umesh

Cut plane instance

Versions:
  • 2026-05-28 @ddalle: v1.0

  • 2026-07-07 @ddalle: v1.1; fallback to cutplane DB

read_cutplane_tri(nsurf: int, n: int) → Umesh | None

Read triangulated cut-plane file

Call:
>>> mesh = runner.read_cutplane_tri(nsurf, n)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index

n: int

Iteration number

Outputs:
mesh: None | cape.gruvoc.umesh.Umesh

Triangulated cut plane instance

Versions:
  • 2026-04-09 @ddalle: v1.0

  • 2026-07-07 @ddalle: v1.1; fallback to cutplane DB

read_data_iter(fname: str = 'data.iter', meta: bool = False, force: bool = False) → DataIterFile

Read data.iter, if present

Call:
>>> db = runner.read_data_iter(fname, meta=False)
Inputs:
runner: CaseRunner

Controller to run one case of solver

fname: {"data.iter"} | str

Name of file to read

meta: {True} | False

Option to only read basic info such as last iter

force: True | {False}

Reread even if cached

Versions:
  • 2024-08-02 @sneuhoff; v1.0

  • 2024-10-11 @ddalle: v2.0

  • 2025-08-14 @ddalle: v2.1; cache, force

read_runinputs(j: int | None = None) → CartInputFile

Read case’s LAVA-Cartesian input file

Call:
>>> yamlfile = runner.read_runinputs(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase number

Outputs:
yamlfile: CartInputFile

LAVA YAML input file interface

Versions:
  • 2025-08-14 @ddalle: v1.0

  • 2025-09-03 @ddalle: v1.1; check for file

read_runyaml(j: int | None = None) → RunYAMLFile

Read case’s LAVA-Curvilinear input file

Call:
>>> yamlfile = runner.read_runyaml(j=None)
Inputs:
runner: CaseRunner

Controller to run one case of solver

j: {None} | int

Phase number

Outputs:
yamlfile: RunYAMLFile

LAVA YAML input file interface

Versions:
  • 2024-10-11 @ddalle: v1.0

read_surfdata_meta(nsurf: int = 1) → DataKit

Read database of metadata for collected surface data

Call:
>>> db = runner.read_surfdata_meta(nsurf=0)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: {0} | int

Surface index (0-based)

Outputs:
db: cape.dkit.rdb.DataKit

DataKit of which batch each iteration is located in

Versions:
  • 2026-04-05 @ddalle: v1.0

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:
  • 2024-08-02 @sneuhoff: v1.0

  • 2024-10-11 @ddalle: v1.1; split run_superlava()

run_superlava(j: int)

Run one phase of the superlava executable

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

Controller to run one case of solver

j: int

Phase number

Versions:
  • 2024-10-11 @ddalle: v1.0

search_cutplane_iters(nsurf: int, mode: str | int = 'raw') → ndarray

Find iterations available for cut-planes

Call:
>>> iters = runner.search_cutplane_iters(nsurf, mode="raw")
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

LAVA surface number (1-based)

Outputs:
iters: np.ndarray[int]

Iterations

Versions:
  • 2026-07-07 @ddalle: v1.0

triangulate_cutplane(nsurf: int | None = None, clean: bool = False, nproc: int | None = None)
nproc: {None} | int

Override MaxWorkers

triangulate_cutplane_iter(surf: int, n: int, clean: bool = False) → bool

Create a triangulation so that each point is in a unique tri

This will convert a file such as

surf00_cutplane_Colorfullq_Cart.000045000.vtk

and create from it

surf00_cutplane_Colorfullq_Cart.000045000.tri.vtk

Call:
>>> q = runner.triangulate_cutplane_iter(surf, n, clean)
Inputs:
runner: CaseRunner

Controller to run one case of solver

surf: int

Surface index

n: int

Iteration number

clean: True | {False}

Option to delete original cut plane file

Outputs:
q: bool

Whether a new file was created

Versions:
  • 2026-04-08 @ddalle: v1.0

triangulate_cutplane_surf(nsurf: int, clean: bool = False, nproc: int | None = None)

Convert cut plane VTK files to triangulated cut planes

Call:
>>> runner.triangulate_cutplane(nsurf, clean=False)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index

clean: True | {False}

Option to delete original cut plane file

nproc: {None} | int

Override MaxWorkers

write_cutplane_meta(nsurf: int, db: DataKit, mode: str)

Write updated cut-plane data collection metadata

Call:
>>> db.write_cutplane_meta(nsurf, db, mode)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: {0} | int

Surface index (1-based)

db: cape.dkit.rdb.DataKit

DataKit of which batch each iteration is located in

mode: str

Cutplane data storage mode

Verions:
  • 2026-04-10 @ddalle: v1.0

write_surfdata_meta(nsurf: int, db: DataKit)

Write updated surface data collection metadata

Call:
>>> db.write_surfdata_meta(nsurf, db)
Inputs:
runner: CaseRunner

Controller to run one case of solver

nsurf: int

Surface index (1-based)

db: cape.dkit.rdb.DataKit

DataKit of which batch each iteration is located in

Verions:
  • 2026-04-05 @ddalle: v1.0

cape.pylava.casecntl.LinkViz()

Link the most recent viz files to fixed file names

Call:
>>> LinkPLT()
Versions:
  • 2025-07-28 @jmeeroff: v1.0

cape.pylava.casecntl.run_lavacurv()

Setup and run the appropriate LAVACURV command

Call:
>>> run_lavacurv()
Versions:
  • 2024-09-30 @sneuhoff: v1.0;

cape.pylava.casecntl.triangulate_mesh(mesh: Umesh, n: ndarray, p: ndarray)

Map a mesh onto a unique triangulation on a plane

That is, each point on that plane will be in exactly one triangle or on the edge of two triangles or on a vertex.

Call:
>>> triangulate_mesh(mesh, n, p)
Inputs:
mesh: cape.gruvoc.umesh.Umesh

Mesh instance

n: np.ndarray[float]

Vector normal to the plane

p: np.ndarray[float]

Point in the plane