cape.pyus.us3d: US3D control module

This module provides tools to quickly setup basic or complex US3D run matrices and serve as an executive for pre-processing, running, post-processing, and managing the solutions. A collection of cases combined into a run matrix can be loaded using the following commands.

>>> import cape.pyus.us3d
>>> cntl = cape.pyus.us3d.US3D("pyUS.json")
>>> cntl
<cape.pyus.US3D(nCase=892)>
>>> cntl.x.GetFullFolderNames(0)
'poweroff/m1.5a0.0b0.0'

An instance of this cape.pyus.cntl.Cntl class has many attributes, which include the run matrix (cntl.x), the options interface (cntl.opts), and optionally the data book (cntl.DataBook), the appropriate input files (such as cntl.InputInp), and possibly others.

Attribute

Class

cntl.x

cape.pyus.RunMatrix

cntl.opts

cape.pyus.options.Options

cntl.InputInp

cape.pyus.inputinpfile.InputInp

Finally, the cape.pyus.cntl.Cntl class is subclassed from the cape.cfdx.cntl.Cntl class, so any methods available to the CAPE class are also available here.

class cape.pyus.cntl.Cntl(fname='pyUS.json')

Bases: Cntl

Class for handling global options and setup for US3D.

This class is intended to handle all settings used to describe a group of US3D cases. For situations where it is not sufficiently customized, it can be used partially, e.g., to set up a Mach/alpha sweep for each single control variable setting.

The settings are read from a JSON file, which is robust and simple to read. The settings can be extended using Python modules if desired.

Defaults are read from the file $CAPE/settings/pyUS.default.json.

Call:
>>> cntl = cape.pyus.Cntl(fname="pyUS.json")
Inputs:
fname: {"pyUS.json"} | str

Name of pyUS JSON control file

Outputs:
cntl: cape.pyfun.cntl.Cntl

Instance of control class

Data members:
cntl.opts: dict

Dictionary of options for this case (directly from fname)

cntl.x: cape.pyus.runmatrix.RunMatrix

Values and definitions for variables in the run matrix

cntl.RootDir: str

Absolute path to the root directory

Versions:
  • 2019-06-04 @ddalle: Started

CaseStartCase()

Start a case by either submitting it or running it

This function relies on cape.pyus.case, and so it is customized for the US3D solver only in that it calls the correct case module.

Call:
>>> pbs = cntl.CaseStartCase()
Inputs:
cntl: cape.pyus.us3d.US3D

US3D control interface

Outputs:
pbs: int or None

PBS job ID if submitted successfully

Versions:
  • 2015-10-14 @ddalle: First version

  • 2019-06-27 @ddalle: US3D version

CheckMesh(i)

Check if the mesh for case i is prepared

Call:
>>> q = cntl.CheckMesh(i)
Inputs:
fun3d: cape.pyus.cntl.Cntl

Instance of control class

i: int

Index of the case to check

Outputs:
q: bool

Whether or not the mesh for case i is prepared

Versions:
  • 2015-10-19 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun

CheckMeshFiles(v=False)

Check for the mesh files in the present folder

Call:
>>> q = cntl.CheckMeshFiles(v=False)
Inputs:
fun3d: cape.pyfun.cntl.Cntl

Instance of control class containing relevant parameters

v: True | {False}

Verbose flag

Outputs:
q: True | False

Whether current folder has the required mesh files

Versions:
  • 2016-04-11 @ddalle: First version

  • 2017-02-22 @ddalle: Added verbose option

  • 2020-04-13 @ddalle: Forked from cape.pyfun

GetInflowBC()

Find name(s) of freestream BC faces

Call:
>>> compIDs = cntl.GetInflowBC()
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of US3D control class

Outputs:
compIDs: list[str]

List of 1 or more BC names

Versions:
  • 2020-04-28 @ddalle: First version

GetInputInpVar(sec, key, j=0)

Get a input.inp variable’s value

The JSON file overrides the value from the template file

Call:
>>> val = cntl.getInputVar(sec, key, j=0)
Inputs:
cntl: cape.pyus.us3d.US3D

US3D control interface

sec: str

Name of namelist section

key: str

Variable to read

j: int

Run sequence index

Outputs:
val: any

Value

Versions:
  • 2015-10-19 @ddalle: First version

  • 2019-06-27 @ddalle: From GetNamelistVar()

GetInputMeshFileNames()

Return the list of mesh files from file

Call:
>>> fname = cntl.GetInputMeshFileNames()
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of control class

Outputs:
fname: list[str]

List of file names read from root directory

Versions:
  • 2015-10-19 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun

GetProcessedMeshFileNames()

Return the list of mesh files that are written

Call:
>>> fname = cntl.GetProcessedMeshFileNames()
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of control class

Outputs:
fname: list[str]

List of file names written to case folders

Versions:
  • 2015-10-19 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun

GetProjectRootName(j=0)

Get the project root name

Right now this is just hard-coded

Call:
>>> name = cntl.GetProjectName(j=0)
Inputs:
fun3d: cape.pyfun.cntl.Cntl

Instance of global pyFun settings object

j: int

Phase number

Outputs:
name: str

Project root name

Versions:
  • 2020-04-13 @ddalle: First version

PrepareCase(i)

Prepare a case for running if it is not already prepared

Call:
>>> cntl.PrepareCase(i)
Inputs:
fun3d: cape.pyus.cntl.Cntl

Instance of control class

i: int

Index of case to prepare/analyze

Versions:
  • 2015-10-19 @ddalle: Version 1.0 (pyfun)

  • 2020-04-13 @ddalle: Version 1.0

  • 2022-04-13 @ddalle: Version 1.1; exec_modfunction()

PrepareInputInp(i)

Prep and write input.inp with case-specific settings

Call:
>>> cntl.PrepareNamelist(i)
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of control class

i: int

Run index

Versions:
  • 2020-04-13 @ddalle: First version

PrepareInputInpFlightConditions(i)

Set flight conditions in input.inp

Call:
>>> cntl.PrepareInputInpFlightConditions(i)
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of US3D control class

i: int

Run index

Versions:
  • 2018-04-19 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun

PrepareMesh(i)

Prepare the mesh for case i if necessary

Call:
>>> cntl.PrepareMesh(i)
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of control class

i: int

Case index

Versions:
  • 2015-10-19 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun

ReadCaseInputInp(i, rc=None, j=None)

Read input.inp from case i, phase j if possible

Call:
>>> inp = cntl.ReadCaseInputInp(i, rc=None, j=None)
Inputs:
cntl: cape.pyus.us3d.US3D

US3D control interface

i: int

Case index

rc: None | cape.pyus.options.runControl.RunControl

Run control interface read from case.json file

j: {None} | nonnegative int

Phase number

Outputs:
inp: None | cape.pyus.inputinpfile.InputInp

US3D input interface if possible

Versions:
  • 2016-12-12 @ddalle: First version

  • 2019-06-27 @ddalle: From cape.pyus

ReadInputInp(j=0, q=True)

Read the input.inp template file

Call:
>>> cntl.InputInp(j=0, q=True)
Inputs:
cntl: cape.pyus.us3d.US3D

US3D control interface

j: int

Phase number

q: {True} | False

Whether or not to read to Namelist, else Namelist0

Versions:
  • 2015-10-16 @ddalle: First version

  • 2015-12-31 @ddalle: Added Namelist0

  • 2019-06-27 @ddalle: Forked from ReadNamelist()

process_mesh_filename(fname)

Return a mesh file name using the project root name

Call:
>>> fout = cntl.process_mesh_filename(fname)
Inputs:
cntl: cape.pyus.cntl.Cntl

Instance of control class

fname: str

Raw file name to be converted to case-folder file name

Outputs:
fout: str

Name of file name using project name as prefix

Versions:
  • 2016-04-05 @ddalle: First version

  • 2020-04-13 @ddalle: Forked from cape.pyfun