cape.pyfun.options: FUN3D and pyFun settings

This module provides tools to read, access, modify, and write settings for cape.pyfun. The class is based off of the built-in dict class, so its default behavior, such as opts['Namelist'] or opts.get('Namelist') are also present. In addition, many convenience methods, such as opts.get_project_rootname(), are also provided.

In addition, this module controls default values of each pyFun parameter in a two-step process. The precedence used to determine what the value of a given parameter should be is below.

  1. Values directly specified in the input file, pyFun.json

  2. Values specified in the default control file, $PYFUN/settings/pyFun.default.json

  3. Hard-coded defaults from this module

class cape.pyfun.options.Options(fname=None, **kw)

Options structure, subclass of dict

Call:
>>> opts = Options(fname=None, **kw)
Inputs:
fname: str

File to be read as a JSON file with comments

kw: dict

Dictionary to be transformed into pyCart.options.Options

Versions:
  • 2014.07.28 @ddalle: First version

get_AdaptCoeffs()

Get the adaptive output function coefficients

Call:
>>> coeffs = opts.get_AdaptCoeffs()
Inputs:
opts: pyFun.options.Options

Options interface

Ouutputs:
coeffs: list[str]

List of coefficients in the adaptive function

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

get_AdaptFuncs()

Get list of adaptation functions

Call:
>>> fns = opts.get_AdaptFuncs()
Inputs:
opts: cape.options.Options

Options interface

Outputs:
fns: list[str]

List of adaptive output functions

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

get_AdaptPhase(i=None)

Determine whether or not a phase is adaptive

Call:
>>> qa = opts.get_AdaptPhase(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int | None

Phase number

Outputs:
qa: bool | list (bool)

Whether or not phase ends with an adaptation

Versions:
  • 2015-12-30 @ddalle: First version

get_AdaptationNumber(i)

Get the adaptation number for a given phase

Call:
>>> j = opts.get_AdaptationNumber(i)
Inputs:
opts: pyFun.options.Options

Options interface

i: int

Phase number

Outputs:
j: int | None

Number of adaptation prior to phase i

Versions:
  • 2015-12-31 @ddalle: First version

get_Adaptive(i=None)

Return whether or not to run adaptively

Call:
>>> ac = opts.get_Adaptive(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int | None

Phase number

Outputs:
ac: bool | list (bool)

Whether or not to use aero.csh

Versions:
  • 2015-12-30 @ddalle: First version

get_BoundaryPointGroups()

Get list of "boundary_point" geometries

If Config>BoundaryPointGroups does not exist, this reads the Config>BoundaryPoints option and sorts the keys alphabetically.

Call:
>>> BP = opts.get_BoundaryPointGroups()
Inputs:
opts: pyFun.options.Options

Options interface

Outputs:
BP: list[str]

List of boundary point groups

Versions:
  • 2017-09-01 @ddalle: First version

get_BoundaryPoints(name=None)

Get points for boundary_point sampling geometry name

This corresponds to the namelist parameter

  • sampling_parameters>type_of_geometry(k) = “boundary_points”

It snaps point sensors to the surface. It requires the namelist parameters number_of_points and points and is modified by snap_output_xyz and dist_tolerance

Call:
>>> PS = opts.get_BoundaryPoints(name=None)
Inputs:
opts: pyFun.options.Options

Options interface

name: {None} | str

Name of boundary point group (geometry) to process

Outputs:
PS: list (list) | dict

List of points in boundary point group

Versions:
  • 2017-09-01 @ddalle: First version

get_ConfigInput(comp)

Return the input for a particular component

Call:
>>> inp = opts.get_ConfigInput(comp)
Inputs:
opts: pyFun.options.Options

Options interface

Outputs:
inp: str | list[int]

List of BCs in this component

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

get_ConstraintFuncs()

Get list of adaptation functions

Call:
>>> fns = opts.get_ConstraintFuncs()
Inputs:
opts: cape.options.Options

Options interface

Outputs:
fns: list[str]

List of adaptive output functions

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

get_Dual(i=None)

Return whether or not to run in dual-mode with an adjoint

This applies to the whole case, not to individual phases

Call:
>>> d = opts.get_Dual(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int | None

Phase number

Outputs:
d: bool | list (bool)

Whether or not to run the case with dual mode

Versions:
  • 2015-12-30 @ddalle: First version

get_DualPhase(i=None)

Determine whether or not a phase is run with an adjoint

Call:
>>> qd = opts.get_DualPhase(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int | None

Phase number

Outputs:
qd: bool | list (bool)

Whether or not phase ends with an adjoint computation

Versions:
  • 2015-12-30 @ddalle: First version

get_FUN3DNamelist(j=None)

Return the name of the master fun3d.nml file

Call:
>>> fname = opts.get_FUN3DNamelist(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: int or None

Run sequence index

Outputs:
fname: str

Name of FUN3D namelist template file

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

get_Faux(comp=None)

Get the geometry information for faux_input for a component

Call:
>>> faux = opts.get_Faux(comp=None)
Inputs:
opts: pyFun.options.Options

Options interface

comp: {None} | str

Name or number of component to process (all if None)

Outputs:
faux: dict (float | list)

faux_input plane definition(s)

Versions:
  • 2017-02-23 @ddalle: First version

get_FauxFile(i=None)

Get the faux_input file if specified

This reads the "Mesh" > "FauxFile" option

Call:
>>> fname = opts.get_FauxFile(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: {None} | int

Phase number

Outputs:
fname: None | str

Faux geometry file

Versions:
  • 2017-02-23 @ddalle: First version

get_FreezeComponents()

Get the list of components to freeze during adaptation

This reads the "Mesh" > "FreezeComponents" option

Call:
>>> comps  = opts.get_FreezeComponents()
Inputs:
opts: pyFun.options.Options

Options interface

Outputs:
comps: list (int | str)

List of face numbers or face names (using mapbc lookup)

Versions:
  • 2017-02-23 @ddalle: First version

get_FreezeFile(i=None)

Get the file that lists component IDs to freeze during adaptation

This reads the "Mesh" > "FreezeFile" option

Call:
>>> fname = opts.get_FreezeFile(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: {None} | int

Phase number

Outputs:
fname: None | str

Faux geometry file

Versions:
  • 2017-02-23 @ddalle: First version

get_FuncCoeffCompID(coeff)

Get the component to apply functional term to

Call:
>>> compID = opts.get_FuncCoeffCompID(coeff, j=None)
Inputs:
opts: cape.options.Options

Options interface

coeff: str

Coefficient name

j: int

Phase number

Outputs:
compID: str | int | list

Component name or number

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

get_FuncCoeffPower(coeff)

Get exponent for a certain functional term

Call:
>>> p = opts.get_FuncCoeffPower(coeff, j=None)
Inputs:
opts: cape.options.Options

Options interface

coeff: str

Coefficient name

j: int

Phase number

Outputs:
p: float

Exponent, term is w*(v-t)**p

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

get_FuncCoeffTarget(coeff)

Get the target value for a named functional term

Call:
>>> t = opts.get_FuncCoeffTarget(coeff, j=None)
Inputs:
opts: cape.options.Options

Options interface

coeff: str

Coefficient name

j: int

Phase number

Outputs:
t: float

Target value, term is w*(v-t)**p

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

get_FuncCoeffWeight(coeff)

Get the weight of a named functional term

Call:
>>> w = opts.get_FuncCoeffWeight(coeff, j=None)
Inputs:
opts: cape.options.Options

Options interface

coeff: str

Coefficient name

j: int

Phase number

Outputs:
w: float

Function weight

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

get_FuncCoeffs(fn)

Get the list of terms in a function

Call:
>>> coeffs = opts.get_FuncCoeffs(fn)
Inputs:
opts: cape.options.Options

Options interface

fn: str

Function name

Outputs:
coeffs: list[str]

List of coefficients

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

get_FuncType(fn)

Get the functional type

Call:
>>> typ = opts.get_FuncType(fn)
Inputs:
opts: cape.options.Options

Options interface

fn: str

Function name

Outputs:
typ: {adapt} | objective | constraint

Function type

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

get_GroupMesh()

Determine whether or not groups have common meshes

Call:
>>> qGM = opts.get_GroupMesh()
Inputs:
opts pyFun.options.Options

Options interface

Outputs:
qGM: bool

True all cases in a group use the same (starting) mesh

Versions:
  • 2014-10-06 @ddalle: First version

get_KeepTemplateComponents()

Get the option to extend fun3d.nml component list

(instead of replacing it)

Call:
>>> qkeep = opts.get_KeepTemplateComponents()
Inputs:
opts: pyFun.options.Options

Options interface

Outputs:
qkeep: True | False

Whether to keep template components

Versions:
  • 2023-11-08 @ddalle: v1.0

get_KineticDataFile(j=None)

Get the kinetic_data file, if any

Call:
>>> fname = opts.get_KineticDataFile(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: {None} | int

Phase number

Outputs:
fname: str

Name of file template

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

get_MapBCFile(i=None)

Return the name of the boundary condition map file

Call:
>>> fname = opts.get_MapBCFile(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int

Phase index

Outputs:
fname: str

Boundary condition file name

Versions:
  • 2016-03-29 @ddalle: First version

get_MovingBodyInputFile(j=None)

Get the moving_body.input file name

Call:
>>> fname = opts.get_MovingBodyInputFile(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: {None} | int

Phase number

Outputs:
fname: str

Name of file template

Versions:
  • 2018-10-22 @ddalle: First version

get_OptFuncs()

Get list of objective functions

Call:
>>> fns = opts.get_OptFuncs()
Inputs:
opts: cape.options.Options

Options interface

Outputs:
fns: list[str]

List of objective functions

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

get_RubberDataFile(j=None)

Get the rubber.data file name

Call:
>>> fname = opts.get_RubberFile(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: {None} | int

Phase number

Outputs:
fname: str

Name of file template

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

  • 2018-04-11 @ddalle: Moved to Config section

get_SpeciesThermoDataFile(j=None)

Get the species_thermo_data file, if any

Call:
>>> fname = opts.get_SpeciesThermoDataFile(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: {None} | int

Phase number

Outputs:
fname: str

Name of file template

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

get_TDataFile(j=None)

Get the tdata file name

Call:
>>> fname = opts.get_TDataFile(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: {None} | int

Phase number

Outputs:
fname: str

Name of file template

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

get_dual_namelist_var(sec, key, i=None)

Get namelist variable from "DualFun3D" section

Call:
>>> v = opts.get_dual_namelist_var(sec, key, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

sec: str

Name of namelist section

key: str

Name of variable in namelist section

i: {None} | int

Phase number

Outputs:
v: any

Value of variable for phase i

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

get_grid_format(i=None)

Return the grid format

Call:
>>> fmat = opts.get_grid_format(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
fmat: str

Grid format

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

get_moving_body_var(sec, key, i=None)

Get namelist variable from "MovingBodyInput" section

Call:
>>> v = opts.get_moving_body_var(sec, key, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

sec: str

Name of namelist section

key: str

Name of variable in namelist section

i: {None} | int

Phase number

Outputs:
v: any

Value of variable for phase i

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

get_nIterAdjoint(j=None)

Get number of iterations for dual, the adjoint solver

Call:
>>> n = opts.get_nIterAdjoint(j=None)
Inputs:
opts: pyFun.options.Options

Options interface

j: int | None

Phase number

Outputs:
n: int

Number of iterations for dual

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

get_namelist_var(sec, key, i=None)

Select a namelist key from a specified section

Roughly, this returns opts[sec][key].

Call:
>>> val = opts.get_namelist_var(sec, key, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

sec: str

Section name

key: str

Variable name

i: int | None

Run sequence index

Outputs:
val: int | float | str | list

Value from JSON options

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

get_project(i=None)

Return the project namelist

Call:
>>> d = opts.get_project(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
d: pyFun.options.odict

Project namelist

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

get_project_rootname(i=None)

Return the project root name

Call:
>>> rname = opts.get_project_rootname(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
rname: str

Project root name

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

get_raw_grid(i=None)

Return the raw_grid namelist

Call:
>>> d = opts.get_raw_grid(i=None)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
d: pyFun.options.odict

Grid namelist

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

select_dual_namelist(i=None)

Reduce namelist options to a single instance (i.e. sample lists)

Call:
>>> d = opts.select_namelist(i)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
d: pyFun.options.odict

Project namelist

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

select_moving_body_input(i=None)

Reduce namelist options to a single instance (i.e. sample lists)

Call:
>>> d = opts.select_namelist(i)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
d: pyFun.options.odict

Project namelist

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

select_namelist(i=None)

Reduce namelist options to a single instance (i.e. sample lists)

Call:
>>> d = opts.select_namelist(i)
Inputs:
opts: pyFun.options.Options

Options interface

i: int or None

Run sequence index

Outputs:
d: pyFun.options.odict

Project namelist

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

set_AdaptPhase(qa=True, i=None)

Set whether or not a phase is adaptive

Call:
>>> opts.set_AdaptPhase(qa, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

qa: bool | list (bool)

Whether or not phase ends with an adaptation

i: int | None

Phase number

Versions:
  • 2015-12-30 @ddalle: First version

set_Adaptive(ac=False, i=None)

Return whether or not to run adaptively

Call:
>>> opts.set_Adaptive(ac, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

ac: bool | list (bool)

Whether or not to use aero.csh

i: int | None

Phase number

Versions:
  • 2015-12-30 @ddalle: First version

set_BoundaryPointGroups(BP)

Set list of "boundary_point" geometries

Call:
>>> pts.set_BoundaryPointGroups(BP=[])
Inputs:
opts: pyFun.options.Options

Options interface

BP: {[]} | list[str]

List of boundary point groups

Versions:
  • 2017-09-01 @ddalle: First version

set_BoundaryPoints(PS, name=None)

Set points for boundary_point sampling geometry name

Call:
>>> opts.set_BoundaryPoints(PS, name=None)
Inputs:
opts: pyFun.options.Options

Options interface

PS: list (list) | dict

List of points in boundary point group

name: {None} | str

Name of boundary point group (geometry) to process

Versions:
  • 2017-09-01 @ddalle: First version

set_ConfigInput(comp, inp)

Set the input for a particular component

Call:
>>> opts.set_ConfigInput(comp, nip)
Inputs:
opts: pyFun.options.Options

Options interface

inp: str | list[int]

List of BCs in this component

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

set_Dual(d=False, i=None)

Set whether or not to run in dual-mode with an adjoint

This applies to the whole case, not to individual phases

Call:
>>> opts.get_Dual(d=False, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

d: bool | list (bool)

Whether or not to run the case with dual mode

i: int | None

Phase number

Versions:
  • 2015-12-30 @ddalle: First version

set_DualPhase(qd=True, i=None)

Set whether or not a phase is run with an adjoint

Call:
>>> opts.set_DualPhase(qd, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

qd: bool | list (bool)

Whether or not phase ends with an adjoint computation

i: int | None

Phase number

Versions:
  • 2015-12-30 @ddalle: First version

set_FUN3DNamelist(fname)

Set the name of the master fun3d.nml file

Call:
>>> opts.set_FUN3DNamelist(fname)
Inputs:
opts: pyFun.options.Options

Options interface

fname: str

Name of FUN3D namelist template file

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

set_GroupMesh(qGM=False)

Specify that groups do or do not use common meshes

Call:
>>> opts.get_GroupMesh(qGM)
Inputs:
opts pyFun.options.Options

Options interface

qGM: bool

True all cases in a group use the same (starting) mesh

Versions:
  • 2014-10-06 @ddalle: First version

set_KeepTemplateComponents(qkeep)

Set the option to extend fun3d.nml component list

(instead of replacing it)

Call:
>>> opts.get_KeepTemplateComponents(qkeep)
Inputs:
opts: pyFun.options.Options

Options interface

qkeep: True | False

Whether to keep template components

Versions:
  • 2023-11-08 @ddalle: v1.0

set_nIterAdjoint(n=200, j=None)

Set number of iterations for dual, the adjoint solver

Call:
>>> n = opts.get_nIterAdjoint(n=200, j=None)
Inputs:
opts: pyFun.options.Options

Options interface

n: int

Number of iterations for dual

j: int | None

Phase number

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

set_namelist_var(sec, key, val, i=None)

Set a namelist key for a specified phase or phases

Roughly, this sets opts["Fun3D"][sec][key] or opts["Fun3D"][sec][key][i] equal to val

Call:
>>> opts.set_namelist_var(sec, key, val, i=None)
Inputs:
opts: pyFun.options.Options

Options interface

sec: str

Section name

key: str

Variable name

val: int | float | str | list

Value from JSON options

i: int | None

Run sequence index

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