gruvoc.trifile: Tools for reading Cart3D tri files

One key functionality of this module is to determine the file type of .ugrid files or determine that they are not recognizable files of that format.

class cape.gruvoc.trifile.TriFileType(fmt, byteorder, filetype, precision, compIDs)
byteorder

Alias for field number 1

compIDs

Alias for field number 4

filetype

Alias for field number 2

fmt

Alias for field number 0

precision

Alias for field number 3

cape.gruvoc.trifile.get_tri_mode(fname_or_fp: IOBase | str, fmt: str | None = None) TriFileType | None

Identify TRI file format if possible

Call:
>>> mode = get_tri_mode(fname_or_fp, fmt=None)
Outputs:
mode: None | TriFileType

File type, big|little endian, stream|fortran, etc.

cape.gruvoc.trifile.get_triq_mode(fname_or_fp: IOBase | str, fmt: str | None = None) TriFileType | None

Identify TRI file format if possible

Call:
>>> mode = get_triq_mode(fname_or_fp, fmt=None)
Outputs:
mode: None | TriFileType

File type, big|little endian, stream|fortran, etc.

cape.gruvoc.trifile.read_tri(mesh: UmeshBase, fname_or_fp: str | IOBase, meta: bool = False, fmt: str | None = None)

Read data to a mesh object from .tri file

Call:
>>> read_tri(mesh, fname, meta=False, fmt=None)
>>> read_tri(mesh, fp, meta=False, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

meta: True | {False}

Read only metadata (number of nodes, tris, etc.)

fmt: {None} | str

Manual data format, "l?[br][48]l?"

cape.gruvoc.trifile.read_triq(mesh: UmeshBase, fname_or_fp: str | IOBase, meta: bool = False, fmt: str | None = None)

Read data to a mesh object from .triq file

Call:
>>> read_triq(mesh, fname, meta=False, fmt=None)
>>> read_triq(mesh, fp, meta=False, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

meta: True | {False}

Read only metadata (number of nodes, tris, etc.)

fmt: {None} | str

Manual data format, "l?[br][48]l?"

cape.gruvoc.trifile.triq_get_skin_friction(triq, comp=None, **kw)

Get components of skin friction coeffs

Call:
>>> cf_x, cf_y, cf_z = triq.GetSkinFriction(comp=None, **kw)
Inputs:
triq: class:Umesh

Unstructured mesh object

comp: {None} | str | int

Subset component ID or name or list thereof

incm, momentum: True | {False}

Include momentum (flow-through) forces in total

gauge: {True} | False

Calculate gauge forces (True) or absolute (False)

save: True | {False}

Store vectors of forces for each triangle as attributes

xMRP: {0.0} | float

x-coordinate of moment reference point

yMRP: {0.0} | float

y-coordinate of moment reference point

zMRP: {0.0} | float

z-coordinate of moment reference point

MRP: {[xMRP, yMRP, zMRP]} | list (len=3)

Moment reference point

m, mach: {1.0} | float

Freestream Mach number

RefArea, Aref: {1.0} | float

Reference area

RefLength, Lref: {1.0} | float

Reference length (longitudinal)

RefSpan, bref: {Lref} | float

Reference span (for rolling and yawing moments)

Re, Rey: {1.0} | float

Reynolds number per grid unit

gam, gamma: {1.4} | float > 1

Freestream ratio of specific heats

Utilized Attributes:
triq.nnode: int

Number of nodes

triq.q: np.ndarray[float]

shape: (nnode,*nq*))

Vector of 5, 9, or 13 states on each node

Outputs:
cf_x: np.ndarray

x-component of skin friction coefficient

cf_y: np.ndarray

y-component of skin friction coefficient

cf_z: np.ndarray

z-component of skin friction coefficient

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

cape.gruvoc.trifile.triq_get_tri_forces(mesh, comp=None, **kw)

Calculate forces on tris

Call:
>>> C = triq.GetTriForces(comp=None, **kw)
Inputs:
triq: class:Umesh

Unstructured mesh object

comp: {None} | str | int

Subset component ID or name or list thereof

incm, momentum: True | {False}

Include momentum (flow-through) forces in total

gauge: {True} | False

Calculate gauge forces (True) or absolute (False)

save: True | {False}

Store vectors of forces for each triangle as attributes

xMRP: {0.0} | float

x-coordinate of moment reference point

yMRP: {0.0} | float

y-coordinate of moment reference point

zMRP: {0.0} | float

z-coordinate of moment reference point

MRP: {[xMRP, yMRP, zMRP]} | list (len=3)

Moment reference point

m, mach: {1.0} | float

Freestream Mach number

RefArea, Aref: {1.0} | float

Reference area

RefLength, Lref: {1.0} | float

Reference length (longitudinal)

RefSpan, bref: {Lref} | float

Reference span (for rolling and yawing moments)

Re, Rey: {1.0} | float

Reynolds number per grid unit

gam, gamma: {1.4} | float > 1

Freestream ratio of specific heats

Utilized Attributes:
triq.nNode: int

Number of nodes

triq.q: np.ndarray[float]

shape: (nNode,*nq*)

Vector of 5, 9, or 13 states on each node

Output Attributes:
triq.Fp: np.ndarray shape=(nTri,3)

Vector of pressure forces on each triangle

triq.Fm: np.ndarray shape=(nTri,3)

Vector of momentum (flow-through) forces on each triangle

triq.Fv: np.ndarray shape=(nTri,3)

Vector of viscous forces on each triangle

Outputs:
C: dict (float)

Dictionary of requested force/moment coefficients

C[“CA”]: float

Overall axial force coefficient

Versions:
  • 2017-02-15 @ddalle: v1.0

cape.gruvoc.trifile.triq_interp_surf_pt(triq, x, **kw)

Interpolate triq.q to the nearest point on the surface

Call:
>>> x0, q = triq_interp_surf_pt(triq, x, **kw)
Inputs:
triq: class:Umesh

Unstructured mesh object

x: np.ndarray (float, shape=(3,))

Array of x, y, and z coordinates of test point

k: {None} | int

Pre-specified index of nearest triangle (0-based)

k1: {None} | int

Pre-specified index of nearest triangle (1-based)

z: {None} | float

Pre-specified projection distance of x to tri k1

kw: dict

Keyword arguments passed to Tri.GetNearestTri()

Outputs:
x0: np.ndarray shape=(3,)

Point projected onto the surface

q: np.ndarray shape=(triq.nq,)

Interpolated state from triq.q

Versions:
  • 2017-10-10 @ddalle: v1.0

  • 2018-10-12 @serogers: v2.0; subtriangles

  • 2022-03-10 @ddalle: v2.1; skip GetNearestTri()

cape.gruvoc.trifile.triq_weighted_avg(triq1, triq2)

Calculate weighted average with a second triangulation

Call:
>>> triq_weighted_avg(triq1, triq2)
Inputs:
triq: class:Umesh

Unstructured mesh object

triq2: class:Umesh

Second unstructured mesh object

Versions:
  • 2015-09-14 @ddalle: v1.0

cape.gruvoc.trifile.write_tri(mesh: UmeshBase, fname_or_fp: str | IOBase, fmt: str | None = None)

Write data from a mesh object to .tri file

Call:
>>> write_tri(mesh, fname, fmt=None)
>>> write_tri(mesh, fp, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

fmt: {None} | str

Manual data format, "l?[br][48]l?"

cape.gruvoc.trifile.write_triq(mesh: UmeshBase, fname_or_fp: str | IOBase, fmt: str | None = None)

Write data from a mesh object to .tri file

Call:
>>> write_triq(mesh, fname, fmt=None)
>>> write_triq(mesh, fp, fmt=None)
Inputs:
mesh: Umesh

Unstructured mesh object

fname: str

Name of file

fp: IOBase

File object

fmt: {None} | str

Manual data format, "l?[br][48]l?"