upsp.processing.grids

class StructGrid[source]

Bases: object

Manage plot3d-style structured grid and write formatted to file

sz

sizes of each grid [3xN]

Type

array_like

x

x-position [N]

Type

array_like

y

y-position [N]

Type

array_like,

z

z-position [N]

Type

array_like,

zones

vertices ordered by zones [N]

Type

numpy.ndarray

load_grid(grid_file)[source]

Read a formatted p3d file

Parameters

grid_file (str) – formatted plot3d file

num_faces(zone=None)[source]

Return the number of faces in a zone

Parameters

zone (int, optional) – zone number (0-based)

Returns

n_faces – Number of faces in the given zone (if provided), otherwise the total number of faces in the grid.

Return type

int

Raises

RuntimeError

num_zones()[source]

Return the number of grids (or zones)

size()[source]

Return the number of grid nodes

write_p3d(fileout)[source]

Write formatted p3d file

Parameters

fileout (str) – output file

write_zones_mapping(fileout)[source]

Write out the binary vertex zones mapping from a plot3d grid

Parameters

fileout (str) – output file

class UnstructGrid[source]

Bases: object

Manages triangulated unstructured grid

n_comps

number of components

Type

int

tris

node ids in each triangle [3,T]

Type

array_like

comps

component id for each node [N]

Type

array_like

x

x-position of each node [N]

Type

array_like

y

y-position of each node [N]

Type

array_like

z

z-position of each node [N]

Type

array_like

extract_comp(comp)[source]

Extract a sub-grid containing just the component of interest

Parameters

comp (int) – component id

Returns

  • g (UnstructGrid) – New unstructured grid with just the selected component

  • n2n (list) – mapping of old nodes to new nodes

get_area(t)[source]

Return the area of a triangle

Parameters

t (int) – triangle index

Returns

area of the triangle

Return type

float

:raises RuntimeError : The triangle index is invalid:

num_comps()[source]

Return the number of components

num_faces(comp=None)[source]

Return the number of faces in a component

Parameters

comp (int, optional) – component number (id)

Returns

n_faces – Number of faces in the given comp (if provided), otherwise the total number of faces in the grid.

Return type

int

num_nodes()[source]

Return the number of nodes