cape.plot3d: Python interface to Plot3D files

This module provides a generic Plot3D file interface for reading Plot3D grid files using the class cape.plot3d.X. This class automatically detects endianness of the grid and can handle IBLANKS in addition to single-grid or multiple-grid formats.

The cape.plot3d.Q interface to solution files also exists, but it is not reliable since Plot3D solution files are dependent on the solver used to create the solution file.

class cape.plot3d.X(fname=None)
GetBasicFileType(fname)

Determine if a file is ASCII, little-endian, or big-endian

Also determine if the file is single-zone or multiple-zone. The function does not check for single-precision or double-precision

Call:
>>> x.GetBasicFileType(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Attributes:
x.byteorder: "little" | "big" | {None}

Endianness of binary file

x.filetype: "record" | "stream" | {"ascii"}

Basic file type

x.p3dtype: {"multiple"} | "single"

Plot3D zone type

Versions:
  • 2016-10-14 @ddalle: Version 1.0

GetFileType(fname)

Get full file type of a Plot3D grid file

Call:
>>> ext = x.GetBasicFileType(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Outputs:
ext: {ascii} | lb8 | lb4 | b8 | b4 | lr4

File type in the form of a file extension code

Attributes:
x.byteorder: "little" | "big" | {None}

Endianness of binary file

x.filetype: "record" | "stream" | {"ascii"}

Basic file type

x.p3dtype: "multiple" | {"single"}

Plot3D zone type

Versions:
  • 2016-10-14 @ddalle: Version 1.0

MapOvfi(fi, fo, tri, **kw)

Edit a .ovfi file using a triangulation for family names

Call:
>>> x.MapOvfi(fi, fo, tri, **kw)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fi: str

Name of input OVFI file

fo: str

Name of output OVFI file

tri: caepe.tri.Tri

Triangulation with named components

Keyword Arguments:
v: True | {False}

Verbose

atol, AbsTol: {0.03} | float > 0

Absolute tolerance for nearest-tri search

rtol, RelTol: {0.0001} | float >= 0

Tolerance for nearest-tri relative to scale of triangulation

ctol, CompTol: {0.001} | float >= 0

Tolerance for nearest-tri relative to scale of component

antol, AbsProjTol: {0.02} | float > 0

Absolute projection tolerance for near nearest-tri search

rntol, RelProjTol: {0.0001} | float >= 0

Projection tolerance relative to scale of triangulation

cntol, CompProjTol: {0.001} | float >= 0

Projection tolerance relative to scale of component

aftol, AbsFamilyTol: {0.001} | float > 0

Absolute tolerance for secondary family search

rftol, RelFamilyTol: {1e-06} | float

Secondary family search tol relative to tri scale

cftol, CompFamilyTol: {_cftol_} | float

Secondary family search tol relative to component scale

nftol, ProjFamilyTol: {0.001} | float

Absolute projection tol for secondary family search

anftol, AbsProjFamilyTol: {nftol} | float

Absolute projection tol for secondary family search

rnftol, RelProjFamilyTol: {1e-06} | float

Secondary family search projection tol relative to tri scale

cnftol, CompProjFamilyTol: {0.001} | float

Secondary family search projection tol relative to comp scale

Versions:
  • 2017-02-09 @ddalle: Version 1.0

MapTriBCs(tri, n=1, **kw)

Find the BC blocks by projecting a mesh to a triangulation

Call:
>>> x.MapTriBCs(tri, n=1, **kw)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

tri: cape.tri.Tri

Triangulation; likely with named components

n: {1} | positive int

Grid number to process (1-based index)

Versions:
  • 2017-02-08 @ddalle: Version 1.0

MapTriCompID(tri, n=1, **kw)

Create a .ovfi file using family names from a tri surf

Call:
>>> C = x.MapTriOvfi(tri, n=1, **kw)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

tri: cape.tri.Tri

Triangulation; likely with named components

n: {1} | positive int

Grid number to process (1-based index)

Outputs:
C: np.ndarray[int]
  • shape: (nj, nk, 2)

Array of component IDs closest to each point in

Versions:
  • 2017-02-08 @ddalle: Version 1.0

Read(fname, **kw)

Read a Plot3D grid file of any format

Call:
>>> x.Read(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

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

Array of coordinates of all points in the grid

x.NG: int

Number of grids in the file

x.NJ: np.ndarray[int] shape: x.nG,

J-dimension of each grid

x.NK: np.ndarray[int] shape: x.nG,

K-dimension of each grid

x.NL: np.ndarray[int] shape: x.nG,

L-dimension of each grid

Versions:
  • 2016-10-15 @ddalle: Version 1.0

  • 2017-02-07 @ddalle: Version 1.1, updated doc

Read_ASCII(fname)

Read a Plot3D grid as an ASCII file

Call:
>>> x.Read_ASCII(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_b4(fname)

Read a Plot3D grid as a big-endian single-precision file

Call:
>>> x.Read_b4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_b8(fname)

Read Plot3D grid big-endian double-precision file (stream)

Call:
>>> x.Read_b8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lb4(fname)

Read a Plot3D grid as a little-endian single-precision file

Call:
>>> x.Read_lb4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lb8(fname)

Read a Plot3D grid as a little-endian double-precision file

Call:
>>> x.Read_lb8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lr4(fname)

Read a Plot3D grid as a little-endian single-precision file

Call:
>>> x.Read_lr4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lr8(fname)

Read a Plot3D grid as a little-endian double-precision file

Call:
>>> x.Read_lr8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_r4(fname)

Read a Plot3D grid as a big-endian single-precision file

Call:
>>> x.Read_r4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_r8(fname)

Read a Plot3D grid as a big-endian double-precision file

Call:
>>> x.Read_r8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Write_ASCII(fname, single=False)

Write a multiple-zone ASCII Plot3D file

Call:
>>> x.Write_ASCII(fname, single=False)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

single: True | {False}

If True, write a single-zone file

Versions:
  • 2016-10-16 @ddalle: Version 1.0

Write_b4(fname, single=False)

Write multi-zone little-endian, single-precision Plot3D file

Call:
>>> x.Write_b4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

single: True | {False}

If True, write a single-zone file

Versions:
  • 2016-10-16 @ddalle: Version 1.0

Write_b8(fname, single=False)

Write multi-zone little-endian, double-precision Plot3D file

Call:
>>> x.Write_b8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

single: True | {False}

If True, write a single-zone file

Versions:
  • 2016-10-16 @ddalle: Version 1.0

Write_lb4(fname, single=False)

Write multi-zone little-endian, single-precision Plot3D file

Call:
>>> x.Write_lb4(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

single: True | {False}

If True, write a single-zone file

Versions:
  • 2016-10-16 @ddalle: Version 1.0

Write_lb8(fname, single=False)

Write multi-zone little-endian, double-precision Plot3D file

Call:
>>> x.Write_lb8(fname)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

fname: str

Name of Plot3D file

single: True | {False}

If True, write a single-zone file

Versions:
  • 2016-10-16 @ddalle: Version 1.0

make_tri()

Divide a surface grid into a triangulation

Call:
>>> tri = x.make_tri()
Versions:
  • 2020-07-06 @ddalle: Version 1.0

cape.plot3d.MapTriMatchBCs(C)

Create a .ovfi file using family names from a triangulation

Call:
>>> BCs = MapTriMatchBCs(C)
Inputs:
x: cape.plot3d.X

Plot3D grid interface

tri: cape.tri.Tri

Triangulation; likely with named components

n: {1} | positive int

Grid number to process (1-based index)

Versions:
  • 2017-02-08 @ddalle: Version 1.0

class cape.plot3d.Q(fname=None)

Interface to OVERFLOW-like q solution files

Call:
>>> q = Q(fname=None)
Inputs:
fname: {None} | str

Name of OVERFLOW solution file to read

Outputs:
q: cape.plot3d.Q

Solution file interface

Versions:
  • 2016-10-11 @ddalle: Version 1.0

GetFileType(fname)

Get full file type of a Plot3D grid file

Call:
>>> ext = q.GetFileType(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Outputs:
ext: {"ascii"} | "l?[br][48]"

File type in the form of a file extension code

  • "lr4": little-endian single-precision records

  • "lr8": little-endian double-precision records

  • "r8": big-endian double-precision records

  • "lb8": little-endian double-precision stream

  • "b8": big-endian double-precision records

Attributes:
q.byteorder: "little" | "big" | {None}

Endianness of binary file

q.filetype: "record" | "stream" | {"ascii"}

Basic file type

q.p3dtype: "multiple" | {"single"}

Plot3D zone type

Versions:
  • 2016-10-14 @ddalle: Version 1.0

Read_ASCII(fname)

Read an ASCII solution file

Call:
>>> q.Read_ASCII(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_b4(fname)

Read a big-endian single-precision (stream) solution file

Call:
>>> q.Read_b4(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_b8(fname)

Read a big-endian double-precision (stream) solution file

Call:
>>> q.Read_b8(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lb4(fname)

Read a little-endian single-precision (stream) solution file

Call:
>>> q.Read_lb4(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lb8(fname)

Read a little-endian double-precision (stream) solution file

Call:
>>> q.Read_lb8(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lr4(fname)

Read a little-endian single-precision (stream) solution file

Call:
>>> q.Read_lr4(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_lr8(fname)

Read a little-endian double-precision (stream) solution file

Call:
>>> q.Read_lr8(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_r4(fname)

Read a big-endian single-precision solution file

Call:
>>> q.Read_r4(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0

Read_r8(fname)

Read a big-endian double-precision solution file

Call:
>>> q.Read_r8(fname)
Inputs:
q: cape.plot3d.Q

Solution file interface

fname: str

Name of Plot3D file

Versions:
  • 2016-10-15 @ddalle: Version 1.0