plaid.utils.cgns_helper

Utility functions for working with CGNS trees and nodes.

Functions

get_base_names(→ list[str])

Get a list of base names from a CGNSTree.

get_time_values(→ numpy.ndarray)

Get consistent time values from CGNSBase_t nodes in a CGNSTree.

show_cgns_tree(pyTree[, pre])

Pretty print for CGNS Tree.

summarize_cgns_tree(→ str)

Provide a summary of a CGNS tree's contents.

Module Contents

get_base_names(tree: plaid.types.CGNSTree, full_path: bool = False, unique: bool = False) list[str][source]

Get a list of base names from a CGNSTree.

Parameters:
  • tree (CGNSTree) – The CGNSTree containing the CGNSBase_t nodes.

  • full_path (bool, optional) – If True, return full base paths including ‘/’ separators. Defaults to False.

  • unique (bool, optional) – If True, return unique base names. Defaults to False.

Returns:

A list of base names.

Return type:

list[str]

get_time_values(tree: plaid.types.CGNSTree) numpy.ndarray[source]

Get consistent time values from CGNSBase_t nodes in a CGNSTree.

Parameters:

tree (CGNSTree) – The CGNSTree containing CGNSBase_t nodes.

Returns:

An array of consistent time values.

Return type:

np.ndarray

Raises:

AssertionError – If the time values across bases are not consistent.

show_cgns_tree(pyTree: list, pre: str = '')[source]

Pretty print for CGNS Tree.

Parameters:
  • pyTree (list) – CGNS tree to print

  • pre (str, optional) – indentation of print. Defaults to ‘’.

summarize_cgns_tree(pyTree: list, verbose=True) str[source]

Provide a summary of a CGNS tree’s contents.

Parameters:
  • pyTree (list) – The CGNS tree to summarize.

  • verbose (bool, optional) – If True, include detailed field information. Defaults to True.

Example

>>> summarize_cgns_tree(pyTree)
Number of Bases: 2
Number of Zones: 5
Number of Nodes: 20
Number of Elements: 10
Number of Fields: 8
Fields:

‘Base1/Zone1/Solution1/Field1’ ‘Base1/Zone1/Solution1/Field2’ ‘Base2/Zone2/Solution2/Field1’ …