cape.pyover.dataBook: pyOver data book module

cape.pyover.dataBook: DataBook module for OVERFLOW

This module contains functions for reading and processing forces, moments, and other statistics from cases in a trajectory. Data books are usually created by using the cape.pyover.cntl.Cntl.ReadDataBook() function.

# Read OVERFLOW control instance
cntl = pyOver.Cntl("pyOver.json")
# Read the data book
cntl.ReadDataBook()
# Get a handle
DB = cntl.DataBook

# Read a line load component
DB.ReadLineLoad("CORE_LL")
DBL = DB.LineLoads["CORE_LL"]
# Read a target
DB.ReadTarget("t97")
DBT = DB.Targets["t97"]

Data books can be created without an overall control structure, but it requires creating a run matrix object using cape.pyover.runmatrix.RunMatrix, so it is a more involved process.

Data book modules are also invoked during update and reporting command-line calls.

$ pyfun --aero
$ pyfun --ll
$ pyfun --triqfm
$ pyfun --report

The available components mirror those described on the template data book modules, cape.cfdx.dataBook, cape.cfdx.lineLoad, and cape.cfdx.pointSensor. However, some data book types may not be implemented for all CFD solvers.

See Also:
class cape.pyover.dataBook.CaseFM(proj: str, comp: str, **kw)

Force and moment iterative histories

This class contains methods for reading data about an the history of an individual component for a single case. It reads the Tecplot file $proj_fm_$comp.dat where proj is the lower-case root project name and comp is the name of the component. From this file it determines which coefficients are recorded automatically.

Call:
>>> fm = CaseFM(proj, comp)
Inputs:
proj: str

Root name of the project

comp: str

Name of component to process

Outputs:
fm: CaseFM

Force and moment iterative history instance

get_filelist() list

Get ordered list of files to read to build iterative history

Call:
>>> filelist = h.get_filelist()
Inputs:
h: CaseData

Single-case iterative history instance

Outputs:
filelist: list[str]

List of files to read

Versions:
  • 2024-01-24 @ddalle: v1.0

read_fomoco_meta(fname: str, comp: str)

Get basic stats about an OVERFLOW fomoco file

Call:
>>> ic, nc, ni = fm.GetFomocoInfo(fname, comp)
Inputs:
fm: CaseFM

Force and moment iterative history

fname: str

Name of file to query

comp: str

Name of component to find

Outputs:
ic: int | None

Index of component in the list of components

nc: int | None

Number of components

ni: int

Number of iterations

Versions:
  • 2016-02-03 @ddalle: v1.0 (GetFomocoInfo)

  • 2024-01-24 @ddalle: v1.1

readfile(fname: str) dict

Read a FOMOCO output file for one component

Call:
>>> db = fm.readfile(fname)
Inputs:
fm: CaseFM

Single-case force & moment iterative history instance

fname: str

Name of file to read

Outputs:
db: basedata.BaseData

Data read from fname

Versions:
  • 2024-01-24 @ddalle: v1.0

class cape.pyover.dataBook.CaseResid(proj: str, **kw)

OVERFLOW iterative residual history class

This class provides an interface to residuals for a given case by reading the files resid.out, resid.tmp, run.resid, turb.out, species.out, etc.

Call:
>>> hist = CaseResid(proj)
Inputs:
proj: str

Project root name

Outputs:
hist: CaseResid

Instance of the residual histroy class

PlotL2(n=None, nFirst=None, nLast=None, **kw)

Plot the L2 residual

Call:
>>> h = hist.PlotL2(n=None, nFirst=None, nLast=None, **kw)
Inputs:
hist: cape.cfdx.dataBook.CaseResid

Instance of the DataBook residual history

n: int

Only show the last n iterations

nFirst: int

Plot starting at iteration nStart

nLast: int

Plot up to iteration nLast

FigWidth: float

Figure width

FigHeight: float

Figure height

Outputs:
h: dict

Dictionary of figure/plot handles

Versions:
  • 2014-11-12 @ddalle: v1.0

  • 2014-12-09 @ddalle: v1.1; move to AeroPlot

  • 2015-02-15 @ddalle: v1.2; move to dataBook.Aero

  • 2015-03-04 @ddalle: v1.3; add nStart and nLast

  • 2015-10-21 @ddalle: v1.4; use PlotResid()

get_filelist() list

Get ordered list of files to read to build iterative history

Call:
>>> filelist = h.get_filelist()
Inputs:
h: CaseData

Single-case iterative history instance

Outputs:
filelist: list[str]

List of files to read

Versions:
  • 2024-01-24 @ddalle: v1.0

readfile(fname: str) dict

Read an OVERFLOW residual history file; create global resid

Call:
>>> db = fm.readfile(fname)
Inputs:
fm: CaseFM

Single-case force & moment iterative history instance

fname: str

Name of file to read

Outputs:
db: basedata.BaseData

Data read from fname

Versions:
  • 2024-01-24 @ddalle: v1.0

class cape.pyover.dataBook.DBComp(comp, cntl, targ=None, check=False, lock=False, **kw)

Individual component data book

This class is derived from cape.cfdx.dataBook.DBBase.

Call:
>>> DBc = DBComp(comp, x, opts)
Inputs:
comp: str

Name of the component

x: pyOver.runmatrix.RunMatrix

RunMatrix for processing variable types

opts: pyOver.options.Options

Global pyCart options instance

targ: {None} | str

If used, read a duplicate data book as a target named targ

Outputs:
DBc: DBComp

An individual component data book

Versions:
  • 2016-09-15 @ddalle: v1.0

class cape.pyover.dataBook.DBTarget(targ, x, opts, RootDir=None)
class cape.pyover.dataBook.DBTriqFM(x, opts, comp, **kw)

Force and moment component extracted from surface triangulation

Call:
>>> DBF = DBTriqFM(x, opts, comp, RootDir=None)
Inputs:
x: cape.runmatrix.RunMatrix

RunMatrix/run matrix interface

opts: cape.options.Options

Options interface

comp: str

Name of TriqFM component

RootDir: {None} | st

Root directory for the configuration

Outputs:
DBF: DBTriqFM

Instance of TriqFM data book

Versions:
  • 2017-03-28 @ddalle: v1.0

GetTriqFile()

Get most recent triq file and its associated iterations

Call:
>>> qpre, fq, n, i0, i1 = DBF.GetTriqFile()
Inputs:
DBL: DBTriqFM

Instance of TriqFM data book

Outputs:
qpre: {False}

Whether or not to convert file from other format

fq: str

Name of q file

n: int

Number of iterations included

i0: int

First iteration in the averaging

i1: int

Last iteration in the averaging

Versions:
  • 2016-12-19 @ddalle: Added to the module

PreprocessTriq(fq, **kw)

Perform any necessary preprocessing to create triq file

Call:
>>> ftriq = DBF.PreprocessTriq(fq, qpbs=False, f=None)
Inputs:
DBL: DBTriqFM

TriqFM data book

ftriq: str

Name of q file

qpbs: True | {False}

Whether or not to create a script and submit it

f: {None} | file

File handle if writing PBS script

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

  • 2016-12-21 @ddalle: Added PBS

ReadTriq(ftriq)

Read a triq annotated surface triangulation

Call:
>>> DBF.ReadTriq(ftriq)
Inputs:
DBF: DBTriqFM

Instance of TriqFM data book

ftriq: str

Name of triq file

Versions:
  • 2017-03-29 @ddalle: v1.0

class cape.pyover.dataBook.DataBook(cntl, RootDir=None, targ=None, **kw)

DataBook interface for OVERFLOW

Call:
>>> DB = DataBook(x, opts)
Inputs:
x: pyFun.runmatrix.RunMatrix

The current pyFun trajectory (i.e. run matrix)

opts: pyFun.options.Options

Global pyFun options instance

Outputs:
DB: DataBook

Instance of the pyFun data book class

GetCurrentIter()

Determine iteration number of current folder

Call:
>>> n = DB.GetCurrentIter()
Inputs:
DB: DataBook

Instance of data book class

Outputs:
n: int | None

Iteration number

Versions:
  • 2017-04-13 @ddalle: v1.0

ReadCaseFM(comp)

Read a CaseFM object

Call:
>>> fm = DB.ReadCaseFM(comp)
Inputs:
DB: cape.cfdx.dataBook.DataBook

Instance of data book class

comp: str

Name of component

Outputs:
fm: CaseFM

Residual history class

Versions:
  • 2017-04-13 @ddalle: v1.0

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

ReadCaseResid()

Read a CaseResid object

Call:
>>> hist = DB.ReadCaseResid()
Inputs:
DB: cape.cfdx.dataBook.DataBook

Instance of data book class

Outputs:
hist: CaseResid

Residual history class

Versions:
  • 2017-04-13 @ddalle: v1.0

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

ReadDBComp(comp, check=False, lock=False)

Initialize data book for one component

Call:
>>> DB.ReadDBComp(comp, check=False, lock=False)
Inputs:
DB: DataBook

Instance of the pyCart data book class

comp: str

Name of component

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

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

  • 2016-06-27 @ddalle: v1.1; add targ keyword

  • 2017-04-13 @ddalle: v1.2; self-contained

ReadPointSensor(name)

Read a point sensor group if it is not already present

Call:
>>> DB.ReadPointSensor(name)
Inputs:
DB: DataBook

Instance of the pycart data book class

name: str

Name of point sensor group

Versions:
  • 2015-12-04 @ddalle: (from cape.pycart)

ReadTriqFM(comp, check=False, lock=False)

Read a TriqFM data book if not already present

Call:
>>> DB.ReadTriqFM(comp)
Inputs:
DB: DataBook

Instance of pyOver data book class

comp: str

Name of TriqFM component

check: True | {False}

Whether or not to check LOCK status

lock: True | {False}

If True, wait if the LOCK file exists

Versions:
  • 2017-03-29 @ddalle: v1.0

cape.pyover.dataBook.ReadResidFirstIter(fname)

Read the first iteration number in an OVERFLOW residual file

Call:
>>> iIter = ReadResidFirstIter(fname)
>>> iIter = ReadResidFirstIter(f)
Inputs:
fname: str

Name of file to query

f: file

Already opened file handle to query

Outputs:
iIter: int

Iteration number from first line

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

  • 2023-01-14 @ddalle: v1.1; fix file type check for py3

cape.pyover.dataBook.ReadResidGrids(fname)

Get list of grids in an OVERFLOW residual file

Call:
>>> grids = ReadResidGrids(fname)
Inputs:
fname: str

Name of file to read

Outputs:
grids: list[str]

List of grids

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

cape.pyover.dataBook.ReadResidNGrids(fname)

Get number of grids from an OVERFLOW residual file

Call:
>>> nGrid = ReadResidNGrids(fname)
Inputs:
fname: str

Name of file to read

Outputs:
nGrid: int

Number of grids

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

  • 2024-01-24 @ddalle: v1.1; context manager

cape.pyover.dataBook.ReadResidNIter(fname)

Get number of iterations in an OVERFLOW residual file

Call:
>>> nIter = ReadResidNIter(fname)
Inputs:
fname: str

Name of file to query

Outputs:
nIter: int

Number of iterations

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

  • 2022-01-09 @ddalle: v1.1; Python 3 int division

cape.pyover.dataBook.read_fomoco_comps(fname: str)

Get list of components in an OVERFLOW fomoco file

Call:
>>> comps = read_fomoco_comps(fp)
Inputs:
fname: str

Name of the file to read

Outputs:
comps: list[str]

List of components

Versions:
  • 2016-02-03 @ddalle: v1.0 (ReadFomocoCOmps)

  • 2024-01-24 @ddalle: v1.1; handle instead of file name

cape.pyover.dataBook.read_fomoco_niter(fname, ncomp: int)

Get number of iterations in an OVERFLOW fomoco file

Call:
>>> nIter = read_fomoco_niter(fname)
>>> nIter = read_fomoco_niter(fname, nComp)
Inputs:
fname: str

Name of file to read

nComp: int | None

Number of components in each record

Outputs:
nIter: int

Number of iterations in the file

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

  • 2024-01-24 @ddalle: v1.1; require ncomp