Node inspection

To avoid redoing several times the most commun operations, maia.pytree provide several functions extracting usefull data from a specific kind of CGNSNode.

All these functions are CGNS/SIDS aware, meaning that they are garanteed to succeed only if the input tree is respecting the standard.

They are also read only; i.e. input tree will not be modified by any of these calls.

Overview

Here is a summary of the available functions, depending of the input node:

Tree These functions apply to CGNSTree_t node

find_connected_zones

Gather the zones of the tree into groups connected by 1to1 connectivities

find_periodic_jns

Gather the periodic joins of the tree according to their periodicity values

Base These functions apply to CGNSBase_t node

CellDimension

Return the CellDimension of a CGNSBase_t node

PhysicalDimension

Return the PhysicalDimension of a CGNSBase_t node

Zone These functions apply to Zone_t node

Type

Return the kind of a Zone_t node

IndexDimension

Return the IndexDimension of a Zone_t node

VertexSize

Return the number of vertices per direction of a Zone_t node

FaceSize

Return the number of faces per direction of a Zone_t node

CellSize

Return the number of cells per direction of a Zone_t node

VertexBoundarySize

Return the number of boundary vertices per direction of a Zone_t node

IFaceSize

Return the number of I normal faces in each direction for a structured Zone_t node

JFaceSize

Return the number of J normal faces in each direction for a structured Zone_t node

KFaceSize

Return the number of K normal faces in each direction for a structured Zone_t node

NGonNode

Return the Element_t node of kind NGON_n of a Zone_t node

NFaceNode

Return the Element_t node of kind NFACE_n of a Zone_t node

CellDimension

Return the CellDimension of a Zone_t node

PhysicalDimension

Return the PhysicalDimension of a Zone_t node

n_cell

Return the total number of cells of a Zone_t node

n_face

Return the total number of faces of a Zone_t node

n_vtx

Return the total number of vertices of a Zone_t node

n_vtx_bnd

Return the total number of boundary vertices of a Zone_t node

has_ngon_elements

Return True if some Element_t node of kind NGON_n exists in the Zone_t node

has_nface_elements

Return True if some Element_t node of kind NFACE_n exists in the Zone_t node

coordinates

Return the coordinate arrays of the Zone_t node

get_ordered_elements

Return the Elements under a Zone_t node, sorted according to their ElementRange

get_ordered_elements_per_dim

Return the Elements under a Zone_t node, gathered according to their dimension

get_elt_range_per_dim

Return the min & max element number of each dimension found in a Zone_t node

elt_ordering_by_dim

Return a flag indicating if elements belonging to a Zone_t node are sorted

Element These functions apply to Element_t node

Type

Return the generic name of an Element_t node

Dimension

Return the dimension of an Element_t node

NVtx

Return the number of vertices of an Element_t node

Range

Return the value of the ElementRange of an Element_t node

Size

Return the size (number of elements) of an Element_t node

GridConnectivity These functions apply to GridConnectivity_t and GridConnectivity1to1_t nodes

Type

Return the type of a GridConnectivity node

Transform

Return the Transform specification of a GridConnectivity1to1 node.

is1to1

Return True if the GridConnectivity node is of type 'Abutting1to1'

isperiodic

Return True if the GridConnectivity node is periodic

ZoneDonorPath

Return the path of the opposite zone of a GridConnectivity node

periodic_values

Return the periodic transformation of a GridConnectivity node

Subset These functions apply to nodes having a PointList or a PointRange

getPatch

Return the PointList or PointRange node defining the Subset node

GridLocation

Return the GridLocation value of a Subset node

n_elem

Return the number of mesh elements included in a Subset node

normal_axis

Return the normal direction of a structured subset.

Container These functions apply to nodes storing data on mesh entities

GridLocation

Return the GridLocation value of a container node

fields

Return the value of fields found under the container node.

SubsetNode

Return the subset node related to the input container node.

Note

Functions are displayed below as static methods, gathered into classes. This is an implementation detail to put functions into namespaces : they should be used as usual, with their name prefixed by the label name:

>>> PT.Zone.Type(zone_node) # Apply on a Zone_t node
>>> PT.GridConnectivity.Type(gc_node) #Apply on a GC_t or GC1to1_t node

Methods detail

class Tree

The following functions apply to the top level CGNSTree_t

static find_connected_zones(tree)

Gather the zones of the tree into groups connected by 1to1 connectivities

Only non periodic joins are considered. Output paths start at tree level (Basename/Zonename).

Parameters

tree (CGNSTree) – Input CGNSTree_t node

Returns

List[List[str]] – grouped paths of zones

Example

>>> tree = PT.yaml.parse_yaml_cgns.to_cgns_tree('''
... Base CGNSBase_t:
...   Zone1 Zone_t:
...     ZoneGridConnectivity ZoneGridConnectivity_t:
...       match GridConnectivity1to1_t "Zone3":
...   Zone2 Zone_t:
...   Zone3 Zone_t:
...     ZoneGridConnectivity ZoneGridConnectivity_t:
...       match GridConnectivity1to1_t "Zone1":
... ''')
>>> PT.Tree.find_connected_zones(tree)
[['Base/Zone2'], ['Base/Zone1', 'Base/Zone3']]
static find_periodic_jns(tree, rtol=1e-05, atol=0.0)

Gather the periodic joins of the tree according to their periodicity values

Returned paths starts at tree level.

Parameters
  • tree (CGNSTree) – Input CGNSTree_t node

  • rtol (float, optional) – relative tolerance for periodicity comparaison

  • atol (float, optional) – absolute tolerance for periodicity comparaison

Returns

Pair of lists – at each indice,

  • first list contains the periodic arrays for the group of joins

  • second list contains the paths of joins related to this value

class Base
static CellDimension(base_node)

Return the CellDimension of a CGNSBase_t node

CellDimension is the dimensionality of the cell in the mesh

Parameters

base_node (CGNSTree) – Input CGNSBase_t node

Returns

int – CellDimension (1,2 or 3)

Example

>>> base = PT.new_CGNSBase(cell_dim=2, phy_dim=3)
>>> PT.Base.CellDimension(base)
2
static PhysicalDimension(base_node)

Return the PhysicalDimension of a CGNSBase_t node

PhysicalDimension is the number of coordinates required to define a node position.

Parameters

base_node (CGNSTree) – Input CGNSBase_t node

Returns

int – PhysicalDimension (1,2 or 3)

Example

>>> base = PT.new_CGNSBase(cell_dim=2, phy_dim=3)
>>> PT.Base.PhysicalDimension(base)
3
class Zone

The following functions apply to any Zone_t node

static CellDimension(zone_node)

Return the CellDimension of a Zone_t node

CellDimension is the dimensionality of the cell in the mesh, and should be equal to the first element of related CGNSBase_t value.

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – CellDimension (1,2 or 3)

Raises

ValueError – if zone has no elements

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_Elements('PYRA', 'PYRA_5', erange=[1,10],  parent=zone)
>>> PT.Zone.CellDimension(zone)
3
static CellSize(zone_node)

Return the number of cells per direction of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

tuple of IndexDimension() int – number of cells in each direction

Example

>>> zone = PT.new_Zone(type='Unstructured', size=[[11,10,0]])
>>> PT.Zone.CellSize(zone)
(10,)
static FaceSize(zone_node)

Return the number of faces per direction of a Zone_t node

Note that for structured meshes, this is the total number of faces having their normal aligned with I, J and K axis.

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

tuple of IndexDimension() int – number of faces in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.FaceSize(zone)
(55, 60)

Warning

Unstructured zones are supported only if they have a NGon connectivity

static IFaceSize(zone_node)

Return the number of I normal faces in each direction for a structured Zone_t node

Parameters

zone_node (CGNSTree) – Input structured Zone_t node

Returns

tuple of IndexDimension() int – number of faces in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.IFaceSize(zone)
(11, 5)
static IndexDimension(zone_node)

Return the IndexDimension of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – IndexDimension (1,2 or 3)

Example

>>> zone = PT.new_Zone(type='Unstructured', size=[[11,10,0]])
>>> PT.Zone.IndexDimension(zone)
1
static JFaceSize(zone_node)

Return the number of J normal faces in each direction for a structured Zone_t node

Parameters

zone_node (CGNSTree) – Input structured Zone_t node

Returns

tuple of IndexDimension() int – number of faces in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.JFaceSize(zone)
(10, 6)
static KFaceSize(zone_node)

Return the number of K normal faces in each direction for a structured Zone_t node

Parameters

zone_node (CGNSTree) – Input structured Zone_t node

Returns

tuple of IndexDimension() int – number of faces in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0], [4,3,0]])
>>> PT.Zone.KFaceSize(zone)
(10, 5, 4)
static NFaceNode(zone_node)

Return the Element_t node of kind NFACE_n of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

CGNSTree – NFace node

Raises

RuntimeError – if not exactly one NFACE_n element node exists in zone

static NGonNode(zone_node)

Return the Element_t node of kind NGON_n of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

CGNSTree – NGon node

Raises

RuntimeError – if not exactly one NGON_n element node exists in zone

static PhysicalDimension(zone_node)

Return the PhysicalDimension of a Zone_t node

PhysicalDimension is the number of coordinates required to define a node position, and should be equal to the second element of related CGNSBase_t value.

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – PhysicalDimension (1,2 or 3)

Raises

ValueError – if zone has no coordinates

Example

>>> zone = PT.new_Zone(type='Unstructured', size=[[5,4,0]])
>>> PT.new_GridCoordinates(fields={'CoordinateX' : [0.,0.25,0.5,0.75,1]}, parent=zone)
>>> PT.Zone.PhysicalDimension(zone)
1
static Type(zone_node)

Return the kind of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

str – One of ‘Structured’, ‘Unstructured’, ‘UserDefined’ or ‘Null’

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.Zone.Type(zone)
'Unstructured'
static VertexBoundarySize(zone_node)

Return the number of boundary vertices per direction of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

tuple of IndexDimension() int – number of boundary vertices in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0],[6,5,0]])
>>> PT.Zone.VertexBoundarySize(zone)
(0, 0)
static VertexSize(zone_node)

Return the number of vertices per direction of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

tuple of IndexDimension() int – number of vertices in each direction

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0], [2,1,0]])
>>> PT.Zone.VertexSize(zone)
(11, 6, 2)
static coordinates(zone_node, name=None)

Return the coordinate arrays of the Zone_t node

Cartesian, cylindrical, spherical and auxiliary coordinates are supported.

Parameters
  • zone_node (CGNSTree) – Input Zone_t node

  • name (str, optional) – Name of the GridCoordinates node from which coordinates are taken. If not specified, first container found is used.

Returns

Triplet of ndarray or None – for each direction, corresponding coordinate array or None if physicalDimension is != 3, stored in a named tuple.

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_GridCoordinates(fields={'CoordinateX' : [0., 0.5, 1.],
...                                'CoordinateY' : [.5, .5, .5]},
...                        parent=zone)
>>> PT.Zone.coordinates(zone)
CartesianCoordinates(CoordinateX=array([0. , 0.5, 1. ], dtype=float32),
                     CoordinateY=array([0.5, 0.5, 0.5], dtype=float32),
                     CoordinateZ=None)
static elt_ordering_by_dim(zone_node)

Return a flag indicating if elements belonging to a Zone_t node are sorted

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – Flag indicating how elements are sorted:

  • 1 if elements of lower dimension have lower ElementRange

  • -1 if elements of lower dimension have higher ElementRange

  • 0 if elements are not sorted

If all the elements belonging to the zone have the same dimension, this function returns 1.

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_Elements('TETRA', 'TETRA_4', erange=[1,10], parent=zone)
>>> PT.new_Elements('TRI', 'TRI_3', erange=[11,30], parent=zone)
>>> PT.Zone.elt_ordering_by_dim(zone)
-1
static get_elt_range_per_dim(zone_node)

Return the min & max element number of each dimension found in a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

list of 4 pairs – min and max element id for each dimension

Raises

RuntimeError – if elements of different dimension are interlaced

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_Elements('PYRA', 'PYRA_5', erange=[1,10],  parent=zone)
>>> PT.new_Elements('TRI',  'TRI_3',  erange=[11,30], parent=zone)
>>> PT.new_Elements('BAR',  'BAR_2',  erange=[31,40], parent=zone)
>>> PT.Zone.get_elt_range_per_dim(zone)
[[0, 0], [31, 40], [11, 30], [1, 10]]
static get_ordered_elements(zone_node)

Return the Elements under a Zone_t node, sorted according to their ElementRange

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

list of CGNSTree – Elements_t nodes

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_Elements('TETRA', 'TETRA_4', erange=[1,10], parent=zone)
>>> PT.new_Elements('TRI', 'TRI_3', erange=[11,30], parent=zone)
>>> [PT.get_name(node) for node in PT.Zone.get_ordered_elements(zone)]
['TETRA', 'TRI']
static get_ordered_elements_per_dim(zone_node)

Return the Elements under a Zone_t node, gathered according to their dimension

Within each dimension, Elements are sorted according to their ElementRange

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

list of 4 list of CGNSTree – Elements_t nodes

Example

>>> zone = PT.new_Zone(type='Unstructured')
>>> PT.new_Elements('PYRA', 'PYRA_5', erange=[1,10],  parent=zone)
>>> PT.new_Elements('TRI',  'TRI_3',  erange=[11,30], parent=zone)
>>> PT.new_Elements('QUAD', 'QUAD_4', erange=[31,40], parent=zone)
>>> [len(elts) for elts in PT.Zone.get_ordered_elements_per_dim(zone)]
[0, 0, 2, 1]
static has_nface_elements(zone_node)

Return True if some Element_t node of kind NFACE_n exists in the Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

bool

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.has_nface_elements(zone)
False
static has_ngon_elements(zone_node)

Return True if some Element_t node of kind NGON_n exists in the Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

bool

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.new_NGonElements(parent=zone)
>>> PT.Zone.has_ngon_elements(zone)
True
static n_cell(zone_node)

Return the total number of cells of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – number of cells

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.n_cell(zone)
50
static n_face(zone_node)

Return the total number of faces of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – number of faces

Example

>>> zone = PT.new_Zone(type='Structured', size=[[11,10,0], [6,5,0]])
>>> PT.Zone.n_face(zone)
115

Warning

Unstructured zones are supported only if they have a NGon connectivity

static n_vtx(zone_node)

Return the total number of vertices of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – number of vertices

Example

>>> zone = PT.new_Zone(type='Unstructured', size=[[11,10,0]])
>>> PT.Zone.n_vtx(zone)
11
static n_vtx_bnd(zone_node)

Return the total number of boundary vertices of a Zone_t node

Parameters

zone_node (CGNSTree) – Input Zone_t node

Returns

int – number of boundary vertices

Example

>>> zone = PT.new_Zone(type='Unstructured', size=[[11,10,0]])
>>> PT.Zone.n_vtx_bnd(zone)
0
class Element

The following functions apply to any Element_t node

static Dimension(elt_node)

Return the dimension of an Element_t node

Parameters

elt_node (CGNSTree) – Input Element_t node

Returns

int – Dimension of this element kind (0, 1, 2 or 3)

Example

>>> elt = PT.new_Elements(type='TRI_3')
>>> PT.Element.Dimension(elt)
2
static NVtx(elt_node)

Return the number of vertices of an Element_t node

Parameters

elt_node (CGNSTree) – Input Element_t node

Returns

int – Number of vertices for this element kind

Example

>>> elt = PT.new_Elements(type='PYRA_5')
>>> PT.Element.NVtx(elt)
5
static Range(elt_node)

Return the value of the ElementRange of an Element_t node

Parameters

elt_node (CGNSTree) – Input Element_t node

Returns

ndarray – ElementRange of the node

Example

>>> elt = PT.new_Elements(type='PYRA_5', erange=[21,40])
>>> PT.Element.Range(elt)
array([21, 40], dtype=int32)
static Size(elt_node)

Return the size (number of elements) of an Element_t node

Parameters

elt_node (CGNSTree) – Input Element_t node

Returns

int – Number of elements described by the node

Example

>>> elt = PT.new_Elements(type='PYRA_5', erange=[21,40])
>>> PT.Element.Size(elt)
20
static Type(elt_node)

Return the generic name of an Element_t node

Parameters

elt_node (CGNSTree) – Input Element_t node

Returns

str – CGNS name corresponding to this element kind

Example

>>> elt = PT.new_NFaceElements('MyElements')
>>> PT.Element.Type(elt)
'NFACE_n'
class GridConnectivity

The GridConnectivity namespace gather GridConnectivity_t and GridConnectivity1to1_t nodes

static Transform(gc_node, as_matrix=False)

Return the Transform specification of a GridConnectivity1to1 node.

Parameters
  • gc_node (CGNSTree) – Input GridConnectivity1to1 node

  • as_matrix (bool) – If True, return the transform matrix. Otherwise, return the transform vector.

Returns

ndarray – Transform specification

Example

>>> gc = PT.new_GridConnectivity1to1(transform=[-2,3,1])
>>> PT.GridConnectivity.Transform(gc, True)
array([[ 0,  0,  1],
       [-1,  0,  0],
       [ 0,  1,  0]])
static Type(gc_node)

Return the type of a GridConnectivity node

Parameters

gc_node (CGNSTree) – Input GridConnectivity node

Returns

str – One of ‘Null’, ‘UserDefined’, ‘Overset’, ‘Abutting’ or ‘Abutting1to1’

Example

>>> gc = PT.new_GridConnectivity1to1('GC')
>>> PT.GridConnectivity.Type(gc)
'Abutting1to1'
static ZoneDonorPath(gc_node, cur_base_name)

Return the path of the opposite zone of a GridConnectivity node

Parameters
  • gc_node (CGNSTree) – Input GridConnectivity node

  • cur_base_name (str) – Name of the parent base of this node

Returns

str – Path (Basename/Zonename) of the opposite zone

Example

>>> gc = PT.new_GridConnectivity('GC', donor_name='OtherBase/OppZone')
>>> PT.GridConnectivity.ZoneDonorPath(gc, 'Base')
'OtherBase/OppZone'
static is1to1(gc_node)

Return True if the GridConnectivity node is of type ‘Abutting1to1’

Parameters

gc_node (CGNSTree) – Input GridConnectivity node

Returns

bool

Example

>>> gc = PT.new_GridConnectivity('GC', type='Overset')
>>> PT.GridConnectivity.is1to1(gc)
False
static isperiodic(gc_node)

Return True if the GridConnectivity node is periodic

Parameters

gc_node (CGNSTree) – Input GridConnectivity node

Returns

bool

Example

>>> gc = PT.new_GridConnectivity('GC', type='Overset')
>>> PT.GridConnectivity.isperiodic(gc)
False
static periodic_values(gc_node)

Return the periodic transformation of a GridConnectivity node

Parameters

gc_node (CGNSTree) – Input GridConnectivity node

Returns

Triplet of ndarray or None – values of RotationCenter, RotationAngle and Translation, stored in a named tuple

Example

>>> gc = PT.new_GridConnectivity('GC')
>>> PT.new_GridConnectivityProperty({'translation' : [1., 0, 0]}, parent=gc)
>>> PT.GridConnectivity.periodic_values(gc)
PeriodicValues(RotationCenter=array([0., 0., 0.], dtype=float32),
               RotationAngle=array([0., 0., 0.], dtype=float32),
               Translation=array([1., 0., 0.], dtype=float32))
class Subset

A subset is a node defining a subregion of the mesh through a PointList or a PointRange node (eg BC_t, some ZoneSubRegion_t, …).

static GridLocation(subset_node)

Return the GridLocation value of a Subset node

Parameters

subset_node (CGNSTree) – Input Subset node

Returns

str – One of ‘Null’, ‘UserDefined’, ‘Vertex’, ‘CellCenter’, ‘FaceCenter’, ‘IFaceCenter’, ‘JFaceCenter’, ‘KFaceCenter’, or ‘EdgeCenter’

Example

>>> bc = PT.new_BC('BC', loc='FaceCenter')
>>> PT.Subset.GridLocation(bc)
'FaceCenter'
static getPatch(subset_node)

Return the PointList or PointRange node defining the Subset node

Parameters

subset_node (CGNSTree) – Input Subset node

Returns

CGNSTree – PointList or PointRange node

Example

>>> bc = PT.new_BC('BC', loc='FaceCenter', point_list=[[1,2,3,4]])
>>> PT.Subset.getPatch(bc)
['PointList', array([[1, 2, 3, 4]], dtype=int32), [], 'IndexArray_t']
static n_elem(subset_node)

Return the number of mesh elements included in a Subset node

Parameters

subset_node (CGNSTree) – Input Subset node

Returns

int – Number of elements

Example

>>> gc = PT.new_GridConnectivity1to1('GC', point_range=[[10,1],[1,10]])
>>> PT.Subset.n_elem(gc)
100
>>> bc = PT.new_BC('BC', loc='FaceCenter', point_list=[[1,2,3,4]])
>>> PT.Subset.n_elem(bc)
4
static normal_axis(subset_node)

Return the normal direction of a structured subset.

This function is only relevant for subsets defining a 2d or 1d structured region (having a PointRange node).

Parameters

subset_node (CGNSTree) – Input Subset node

Returns

int – Normal axis of the subset (0,1 or 2)

Raises

ValueError – if normal axis can not be determined

Example

>>> bc = PT.new_BC(point_range=[[1,10], [5,5], [1,100]], loc='Vertex')
>>> PT.Subset.normal_axis(bc)
1
class Container

A container is node designed to store fields, such as FlowSolution_t, ZoneSubRegion_t, …

static GridLocation(cnt_node, parent_node=None)

Return the GridLocation value of a container node

If the container does not defines its own subset (eg. a ZoneSubRegion with a BCRegionName), the parent zone node must be passed in parent_node argument (for BCDataSet containers, parent BC_t node is also accepted).

Parameters
  • cnt_node (CGNSTree) – Input container node

  • parent_node (CGNSTree) – parent of the container node (see above)

Returns

str – One of ‘Null’, ‘UserDefined’, ‘Vertex’, ‘CellCenter’, ‘FaceCenter’, ‘IFaceCenter’, ‘JFaceCenter’, ‘KFaceCenter’, or ‘EdgeCenter’

Example

>>> fs = PT.new_FlowSolution('Fields@Cell@Init', loc='CellCenter')
>>> PT.Container.GridLocation(fs)
'CellCenter'
>>> zone = PT.new_Zone('Zone')
>>> bc   = PT.new_BC('RelevantBC', loc='FaceCenter', parent=PT.new_ZoneBC(parent=zone))
>>> zsr  = PT.new_ZoneSubRegion('ZSR', bc_name='RelevantBC')
>>> PT.Container.GridLocation(zsr, zone)
'FaceCenter'
static SubsetNode(cnt_node, parent_node)

Return the subset node related to the input container node.

This function mainly makes sense for ZoneSubRegion_t or BCDataSet_t containers, since their geometrical patch can be defined by an other node. The result can be the input node itself if the container defines its own geometrical patch.

Parameters
  • cnt_node (CGNSTree) – Input ZoneSubRegion_t node

  • parent_node (CGNSTree) – Parent Zone_t node. For BCDataSet containers, parent BC_t node is also accepted.

Returns

CGNSTree – related subset node

Example

>>> zone = PT.new_Zone('Zone')
>>> bc   = PT.new_BC('RelevantBC', parent=PT.new_ZoneBC(parent=zone))
>>> zsr  = PT.new_ZoneSubRegion('ZSR', bc_name='RelevantBC')
>>> PT.get_label(PT.Container.SubsetNode(zsr, zone))
'BC_t'
>>> zsr  = PT.new_ZoneSubRegion('ZSR', point_list=[1,2,3,4], parent=zone)
>>> PT.get_label(PT.Container.SubsetNode(zsr, zone))
'ZoneSubRegion_t'
static fields(cnt_node)

Return the value of fields found under the container node.

Result is returned as a dictionnary mapping field name (str) to field value (ndarray). Note that if container is a BCDataSet, keys of the dictionnary are actually the path of data array, including the name of the intermediary BCData node.

Parameters

cnt_node (CGNSTree) – Input container node

Returns

dict – field name to field value mapping

Example

>>> zsr = PT.new_ZoneSubRegion('ZSR')
>>> PT.new_DataArray('Temperature', [21, 29], parent=zsr)
>>> PT.new_DataArray('Pressure', [1004, 1010], parent=zsr)
>>> PT.Container.fields(zsr)
{'Temperature': array([21, 29], dtype=int32), 'Pressure': array([1004, 1010], dtype=int32)}