turbo_moc.io.cgns_adf module#

Small NumPy-only CGNS/ADF container reader and writer.

Extracted from ParaBlade projects/mesh_examples/3D/cgns_adf_3Dto2D.py. This module handles the container; callers construct the CGNS node tree. It supports ADF files, not HDF5 files.

exception turbo_moc.io.cgns_adf.AdfError[source]#

Bases: ValueError

Malformed or unsupported ADF/CGNS content.

class turbo_moc.io.cgns_adf.AdfNode(name: str, label: str = '', data=None, dtype: str | None = None, children: Iterable[AdfNode] | None = None)[source]#

Bases: object

One node of an ADF tree.

label is the CGNS node type (Zone_t …). data is None (data type MT), a str (data type C1) or a numpy array whose dtype maps to an ADF data type. Multi-dimensional arrays keep their Fortran (column-major) ordering on disk.

Attributes:
children
data
dtype
label
name
text

String content of a C1 node (trailing NULs/blanks stripped).

Methods

copy()

Deep copy of the sub-tree (array data is shared, never mutated).

get([name, label])

set_data(data[, dtype])

add

find_all

walk

add(node: AdfNode) → AdfNode[source]#
children: list[AdfNode]#
copy() → AdfNode[source]#

Deep copy of the sub-tree (array data is shared, never mutated).

data#
dtype#
find_all(label: str) → list[AdfNode][source]#
get(name: str | None = None, label: str | None = None) → AdfNode | None[source]#
label#
name#
set_data(data, dtype: str | None = None) → None[source]#
property text: str#

String content of a C1 node (trailing NULs/blanks stripped).

walk(path: str = '')[source]#
turbo_moc.io.cgns_adf.new_root() → AdfNode[source]#

Create an empty ADF root node.

turbo_moc.io.cgns_adf.read_adf(filename: str) → AdfNode[source]#

Read a complete ADF (CGNS) file into an AdfNode tree.

turbo_moc.io.cgns_adf.read_adf_bytes(data: bytes, filename: str = '<memory>') → AdfNode[source]#

Read an ADF image, including a mesh stored inside a project ZIP.

turbo_moc.io.cgns_adf.serialize_adf(root: AdfNode) → bytes[source]#

Serialize a tree without creating an intermediate file.

turbo_moc.io.cgns_adf.write_adf(filename: str, root: AdfNode) → None[source]#

Write an AdfNode tree as a new little-endian ADF (CGNS) file.