Internal: CGNS/python tree management
Version: 2.4 (29/03/2017)
Author: Onera

Preamble
This module provides simple and efficient functions for
creating/traversing/manipulating CGNS/Python data tree (pyTree).
This module is part of Cassiopee, a free open-source
pre- and post-processor for CFD simulations.
To use the module:
import Converter.Internal as Internal
All functions of Cassiopee modules (Converter.PyTree, Transform.PyTree, ...)
work on 3 types of containers: a container for grid coordinates
named __GridCoordinates__, a container for node solution named
__FlowSolutionNodes__ and a container for center solution named
__FlowSolutionCenters__. By default:
Internal.__GridCoordinates__ = 'GridCoordinates'
Internal.__FlowSolutionNodes__ = 'FlowSolution'
Internal.__FlowSolutionCenters__ = 'FlowSolution#Centers'
To make the functions operate on
another named container for example 'FlowSolution#Init',
start your script with:
Internal.__FlowSolutionNodes__ = 'FlowSolution#Init'
Internal.autoSetContainers:
adapt automatically the containers name (__FlowSolutionNode__, __FlowSolutionCenters__) to match the containers of a zone or a pyTree:
Internal.autoSetContainers(t)
Example of use: automatically adapt the container names (pyTree).
Node tests
Internal.isTopTree:
return True if node is a top tree:
res = Internal.isTopTree(
node)
Example of use: tell if a node is a top tree (pyTree).
Internal.isStdNode:
return 0 if node is a list of standard nodes, -1 if node is a standard node,
-2 otherwise:
res = Internal.isStdNode(node)
Example of use: tell if a node is a standard one (pyTree).
Internal.typeOfNode:
return 1 if node is a zone node, 2 if node is a list of zones,
3 if node is a tree, 4 if node is a base, 5 if node is a list
of bases, -1 otherwise:
res = Internal.typeOfNode(node)
Example of use: tell what kind of node is my node (pyTree).
Internal.isType:
compare given type and node type. Wildcards are accepted:
res = Internal.isType(node, 'Zone_t')
Example of use: has my node this type? (pyTree).
Internal.isName:
compare given name and node name. Wildcards are accepted:
res = Internal.isName(node, 'Zone*')
Example of use: has my node this name? (pyTree).
Internal.isValue:
compare given value and node value. If value is a string, accepts wildcards.
Accepts also numpy arrays as value:
res = Internal.isValue(node, 1.)
Example of use: has my node this value? (pyTree).
Set/create generic nodes
Internal.setValue:
set the given value in node (node is modified):
Internal.setValue(node, 1.)
Example of use: set value in node (pyTree).
Internal.setName:
set the given name to node (node is modified):
Internal.setName(node, 'myNode')
Example of use: set name in node (pyTree).
Internal.setType:
set the given type to node (node is modified):
Internal.setType(node, 'Zone_t')
Example of use: set type in node (pyTree).
Internal.createNode:
create a node with a given name and type and optional value and children:
node = Internal.createNode('myNode', 'DataArray_t', value=1., children=[])
Example of use: create a node (pyTree).
Internal.addChild:
add a child node to a given node. Position in children list can be
specified (node is modified):
child = Internal.addChild(node, child, pos=-1)
Example of use: add a child node to a node (pyTree).
Internal.createChild:
create a child node and attach it to a given node.
Child's node name, type, value and children can be specified.
Position in children list can also be specified (node is modified) and
newly created child node is returned:
child = Internal.createChild(node, 'myNode', 'DataArray_t', value=None, children=[], pos=-1)
Example of use: create a child node (pyTree).
Internal.createUniqueChild:
same as createChild except that, if a node with the same name already exists
in the children list, it is replaced by the new values (node is modified)
and newly created or modified child node is returned:
child = Internal.createUniqueChild(node, 'myNode', 'DataArray_t', value=None, pos=-1)
Example of use: create a unique child node (pyTree).
Create CGNS specific nodes
Internal.newCGNSTree:
create a tree node with the CGNS version node:
node = Internal.newCGNSTree()
Example of use: create a new tree node (pyTree).
Internal.newCGNSBase:
create a base node. cellDim is the dimension of zone cells of this
base, physDim is the
dimension of physical space. For example, triangle zones in 3D space will
correspond to cellDim=2 and physDim=3. If parent is not None, attach
it to parent node:
node = Internal.newCGNBase(name='Base', cellDim=3, physDim=3, parent=None)
Example of use: create a new base node (pyTree).
Internal.newZone:
create a zone node. zsize is the dimension of zone, ztype is the type of
zone ('Structured' or 'Unstructured'). If family is not None, attach a
zone family node. If parent is not None, attach it to parent node:
node = Internal.newZone(name='Zone', zsize=None, ztype='Structured', family=None, parent=None)
Example of use: create a new zone node (pyTree).
Internal.newGridCoordinates:
create a GridCoordinates node.
If parent is not None, attach it to parent node:
node = Internal.newGridCoordinates(name=__GridCoordinates__, parent=None)
Example of use: create a new GridCoordinates node (pyTree).
Internal.newDataArray:
create a DataArray node. value can be a string, an int, a float,
a numpy of ints, a numpy of floats.
If parent is not None, attach it to parent node:
node = Internal.newDataArray(name='Data', value=None, parent=None)
Example of use: create a new DataArray node (pyTree).
Internal.newDataClass:
create a DataClass node.
If parent is not None, attach it to parent node:
node = Internal.newDataClass(value='UserDefined', parent=None)
Example of use: create a new DataClass node (pyTree).
Internal.newDimensionalUnits:
create a DimensionalUnits node. Arguments describe the units of the
problem. If parent is not None, attach it to parent node:
node = Internal.newDimensionalUnits(massUnit='Kilogram', lengthUnit='Meter', timeUnit='Second', temperatureUnit='Kelvin', angleUnit='Radian', parent=None)
Example of use: create a new DimensionalUnits node (pyTree).
Internal.newDimensionalExponents:
create a DimensionalExponents node. Arguments describe the unit
exponent of the problem. If parent is not None, attach it to parent node:
node = Internal.newDimensionalExponents(massExponent='Kilogram', lengthExponent='Meter', timeExponent='Second', temperatureExponent='Kelvin', angleExponent='Radian', parent=None)
Example of use: create a new DimensionalExponents node (pyTree).
Internal.newDataConversion:
create a DataConversion node. Arguments describe the conversion factors.
If parent is not None, attach it to parent node:
node = Internal.newDataConversion(conversionScale=1., conversionOffset=0., parent=None)
Example of use: create a new DataConversion node (pyTree).
Internal.newDescriptor:
create a Descriptor node.
If parent is not None, attach it to parent node:
node = Internal.newDescriptor(name='Descriptor', value='', parent=None)
Example of use: create a new Descriptor node (pyTree).
Internal.newGridLocation:
create a GridLocation node.
If parent is not None, attach it to parent node:
node = Internal.newGridLocation(value='CellCenter', parent=None)
Example of use: create a new GridLocation node (pyTree).
Internal.newIndexArray:
create a indexArray node.
If parent is not None, attach it to parent node:
node = Internal.newIndexArray(name='Index', value=None, parent=None)
Example of use: create a new IndexArray node (pyTree).
Internal.newPointList:
create a PointList node.
If parent is not None, attach it to parent node:
node = Internal.newPointList(name='PointList', value=None, parent=None)
Example of use: create a new PointList node (pyTree).
Internal.newPointRange:
create a PointRange node.
If parent is not None, attach it to parent node:
node = Internal.newPointRange(name='PointRange', value=None, parent=None)
Example of use: create a new PointRange node (pyTree).
Internal.newRind:
create a Rind node.
If parent is not None, attach it to parent node:
node = Internal.newRind(value=None, parent=None)
Example of use: create a new Rind node (pyTree).
Internal.newSimulationType:
create a SimulationType node.
If parent is not None, attach it to parent node:
node = Internal.newSimulationType(value='TimeAccurate', parent=None)
Example of use: create a new SimulationType node (pyTree).
Internal.newOrdinal:
create a Ordinal node.
If parent is not None, attach it to parent node:
node = Internal.newOrdinal(value=0, parent=None)
Example of use: create a new Ordinal node (pyTree).
Internal.newDiscreteData:
create a DiscreteData node.
If parent is not None, attach it to parent node:
node = Internal.newDiscreteData(name='DiscreteData', parent=None)
Example of use: create a new DiscreteData node (pyTree).
Internal.newIntegralData:
create a IntegralData node.
If parent is not None, attach it to parent node:
node = Internal.newIntegralData(name='IntegralData', parent=None)
Example of use: create a new IntegralData node (pyTree).
Internal.newElements:
create a Elements node. etype is the element type
('BAR', 'TRI', 'QUAD', ...), econnectivity is the connectivity numpy
array and eboundary ...
If parent is not None, attach it to parent node:
node = Internal.newElements(name='Elements',
etype='UserDefined', econnectivity=None, eboundary=0, parent=None)
Example of use: create a new Elements node (pyTree).
Internal.newParentElements:
create a ParentElements node. value is a numpy array.
If parent is not None, attach it to parent node:
node = Internal.newParentElements(value=None, parent=None)
Example of use: create a new ParentElements node (pyTree).
Internal.newParentElementsPosition:
create a ParentElementsPosition node. value is a numpy array.
If parent is not None, attach it to parent node:
node = Internal.newParentElementsPosition(value=None, parent=None)
Example of use: create a new ParentElementsPosition node (pyTree).
Internal.newZoneBC:
create a ZoneBC node.
If parent is not None, attach it to parent node:
node = Internal.newZoneBC(parent=None)
Example of use: create a new ZoneBC node (pyTree).
Internal.newBC:
create a BC node. It can be defined by a pointRange for structured
zones or a pointList of faces for unstructured zones. btype
specifies the BC type. A BC familyName can also be defined.
If parent is not None, attach it to parent node:
node = Internal.newBC(name='BC', pointRange=None,
pointList=None, btype='Null', family=None, parent=None)
Example of use: create a new ZoneBC node (pyTree).
Internal.newBCDataSet:
create a BCDataSet node. value must be a BCType. GridLocation ('FaceCenter', 'Vertex') can be specified.
If parent is not None, attach it to parent node:
node = Internal.newBCDataSet(name='BCDataSet', value='Null', gridLocation=None, parent=None)
Example of use: create a new BCDataSet node (pyTree).
Internal.newBCData:
create a BCData node.
If parent is not None, attach it to parent node:
node = Internal.newBCData(name='BCData', parent=None)
Example of use: create a new BCData node (pyTree).
Internal.newBCProperty:
create a BCProperty node.
If parent is not None, attach it to parent node:
node = Internal.newBCProperty(wallFunction='Null', area='Null', parent=None)
Example of use: create a new BCProperty node (pyTree).
Internal.newAxiSymmetry:
create a AxiSymmetry node.
If parent is not None, attach it to parent node:
node = Internal.newAxiSymmetry(referencePoint=[0.,0.,0.],
axisVector=[0.,0.,0.], parent=None)
Example of use: create a new AxiSymmetry node (pyTree).
Internal.newRotatingCoordinates:
create a RotatingCoordinates node.
If parent is not None, attach it to parent node:
node = Internal.newRotatingCoordinates(rotationCenter=[0.,0.,0.], rotationRateVector=[0.,0.,0.], parent=None)
Example of use: create a new RotatingCoordinates node (pyTree).
Internal.newFlowSolution:
create a newFlowSolution node.
If parent is not None, attach it to parent node:
node = Internal.newFlowSolution(name=__FlowSolutionNodes__,
gridLocation='Vertex', parent=None)
Example of use: create a new FlowSolution node (pyTree).
Internal.newZoneGridConnectivity:
create a newZoneGridConnectivity node.
If parent is not None, attach it to parent node:
node = Internal.newZoneGridConnectivity(name='ZoneGridConnectivity', parent=None)
Example of use: create a new newZoneGridConnectivity node (pyTree).
Internal.newGridConnectivity1to1:
create a newGridConnectivity1to1 node.
If parent is not None, attach it to parent node:
node = Internal.newGridConnectivity1to1(name='Match',
donorName=None, pointRange=None, pointList=None,
pointRangeDonor=None, pointListDonor=None, transform=None, parent=None)
Example of use: create a new newGridConnectivity node (pyTree).
Internal.newGridConnectivity:
create a newGridConnectivity node.
If parent is not None, attach it to parent node:
node = Internal.newGridConnectivity(name='Overlap',
donorName=None, ctype='Overset', parent=None)
Example of use: create a new newGridConnectivity node (pyTree).
Internal.newGridConnectivityType:
create a newGridConnectivityType node.
If parent is not None, attach it to parent node:
node = Internal.newGridConnectivityType(ctype='Overset',parent=None)
Example of use: create a new newGridConnectivityType node (pyTree).
Internal.newGridConnectivityProperty:
create a newGridConnectivityProperty node.
If parent is not None, attach it to parent node:
node = Internal.newGridConnectivityProperty(parent=None)
Example of use: create a new newGridConnectivityProperty node (pyTree).
Internal.newPeriodic:
create a Periodic node.
If parent is not None, attach it to parent node:
node = Internal.newPeriodic(rotationCenter=[0.,0.,0.],
rotationAngle=[0.,0.,0.], translation=[0.,0.,0.], parent=None)
Example of use: create a new Periodic node (pyTree).
Internal.newOversetHoles:
create a OversetHoles node.
If parent is not None, attach it to parent node:
node = Internal.newOversetHoles(name='OversetHoles', pointRange=None, pointList=None, parent=None)
Example of use: create a new OversetHoles node (pyTree).
Internal.newFlowEquationSet:
create a FlowEquationSet node.
If parent is not None, attach it to parent node:
node = Internal.newFlowEquationSet(parent=None)
Example of use: create a new FlowEquationSet node (pyTree).
Internal.newGoverningEquations:
create a GoverningEquations node. value is the equation type in 'FullPotential', 'Euler', 'NSLaminar','NSTurbulent', 'NSLaminarIncompressible', 'NSTurbulentIncompressible'.
If parent is not None, attach it to parent node:
node = Internal.newGoverningEquations(value='Euler', parent=None)
Example of use: create a new GoverningEquations node (pyTree).
Internal.newGasModel:
create a GasModel node. value is the model type in 'Ideal', 'VanderWaals', 'CaloricallyPerfect', 'ThermallyPerfect', 'ConstantDensity', 'RedlichKwong'.
If parent is not None, attach it to parent node:
node = Internal.newGasModel(value='Ideal', parent=None)
Example of use: create a new GasModel node (pyTree).
Internal.newThermalConductivityModel:
create a ThermalConductivityModel node. value is the model type in 'ConstantPrandtl', 'PowerLaw', 'SutherlandLaw'.
If parent is not None, attach it to parent node:
node = Internal.newThermalConductivityModel(value='Null', parent=None)
Example of use: create a new ThermalConductivityModel node (pyTree).
Internal.newViscosityModel:
create a ViscosityModel node. value is the model type in 'Constant', 'PowerLaw', 'SutherlandLaw'.
If parent is not None, attach it to parent node:
node = Internal.newViscosityModel(value='Null', parent=None)
Example of use: create a new ViscosityModel node (pyTree).
Internal.newTurbulenceClosure:
create a TurbulenceClosure node. value is the closure type in 'EddyViscosity', 'ReynoldStress', 'ReynoldsStressAlgebraic'.
If parent is not None, attach it to parent node:
node = Internal.newTurbulenceClosure(value='Null', parent=None)
Example of use: create a new TurbulenceClosure node (pyTree).
Internal.newTurbulenceModel:
create a TurbulenceModel node. value is the model type in 'Algebraic_BaldwinLomax', 'Algebraic_CebeciSmith', 'HalfEquation_JohnsonKing', 'OneEquation_BaldwinBarth', 'OneEquation_SpalartAllmaras', 'TwoEquation_JonesLaunder', 'TwoEquation_MenterSST', 'TwoEquation_Wilcox'.
If parent is not None, attach it to parent node:
node = Internal.newTurbulenceModel(value='Null', parent=None)
Example of use: create a new TurbulenceModel node (pyTree).
Internal.newThermalRelaxationModel:
create a ThermalRelaxtionModel node. value is the model type in 'Frozen', 'ThermalEquilib', 'ThermalNonequilb'.
If parent is not None, attach it to parent node:
node = Internal.newThermalRelaxationModel(value='Null', parent=None)
Example of use: create a new ThermalRelaxationModel node (pyTree).
Internal.newChemicalKineticsModel:
create a ChemicalKineticsModel node. value is the model type in 'Frozen', 'ChemicalEquilibCurveFit', 'ChemicalEquilibMinimization', 'ChemicalNonequilib'.
If parent is not None, attach it to parent node:
node = Internal.newChemicalKineticsModel(value='Null', parent=None)
Example of use: create a new ChemicalKineticsModel node (pyTree).
Internal.newEMElectricFieldModel:
create a EMElectricFieldModel node. value is the model type in 'Constant', 'Frozen', 'Interpolated', 'Voltage'.
If parent is not None, attach it to parent node:
node = Internal.newEMElectricFieldModel(value='Null', parent=None)
Example of use: create a new EMElectricFieldModel node (pyTree).
Internal.newEMMagneticFieldModel:
create a EMMagneticFieldModel node. value is the model type in 'Constant', 'Frozen', 'Interpolated'.
If parent is not None, attach it to parent node:
node = Internal.newEMMagneticFieldModel(value='Null', parent=None)
Example of use: create a new EMMagneticFieldModel node (pyTree).
Internal.newEMConductivityModel:
create a EMConductivityModel node. value is the model type in 'Constant', 'Frozen', 'Equilibrium_LinRessler', 'Chemistry_LinRessler'.
If parent is not None, attach it to parent node:
node = Internal.newEMConductivityModel(value='Null', parent=None)
Example of use: create a new EMConductivityModel node (pyTree).
Internal.newBaseIterativeData:
create a BaseIterativeData node.
If parent is not None, attach it to parent node:
node = Internal.newBaseIterativeData(name='BaseIterativeData', parent=None)
Example of use: create a new BaseIterativeData node (pyTree).
Internal.newZoneIterativeData:
create a ZoneIterativeData node.
If parent is not None, attach it to parent node:
node = Internal.newZoneIterativeData(name='ZoneIterativeData', parent=None)
Example of use: create a new ZoneIterativeData node (pyTree).
Internal.newRigidGridMotion:
create a RigidGridMotion node. mtype is the motion type ('ConstantRate', 'VariableRate').
If parent is not None, attach it to parent node:
node = Internal.newRigidGridMotion(name='Motion', origin=[0.,0.,0.], mtype='Null', parent=None)
Example of use: create a new RigidGridMotion node (pyTree).
Internal.newRigidGridMotionType:
create a RigidGridMotionType node. value is the motion type ('ConstantRate', 'VariableRate').
If parent is not None, attach it to parent node:
node = Internal.newRigidGridMotionType(value='ConstantRate', parent=None)
Example of use: create a new RigidGridMotionType node (pyTree).
Internal.newReferenceState:
create a ReferenceState node.
If parent is not None, attach it to parent node:
node = Internal.newReferenceState(name='ReferenceState', parent=None)
Example of use: create a new ReferenceState node (pyTree).
Internal.newConvergenceHistory:
create a ConvergenceHistory node. value is an iteration number.
If parent is not None, attach it to parent node:
node = Internal.newConvergenceHistory(name='GlobalConvergenceHistory', value=0, parent=None)
Example of use: create a new ConvergenceHistory node (pyTree).
Internal.newFamily:
create a zone Family node.
If parent is not None, attach it to parent node:
node = Internal.newFamily(name='Family', parent=None)
Example of use: create a new Family node (pyTree).
Internal.newFamilyBC:
create a FamilyBC node. value is a BC type string.
If parent is not None, attach it to parent node:
node = Internal.newFamilyBC(value='UserDefined', parent=None)
Example of use: create a new FamilyBC node (pyTree).
Internal.newGeometryReference:
create a GeometryReference node. value is a type of CAD
('NASA-IGES', 'SDRC', 'Unigraphics', 'ProEngineer', 'ICEM-CFD').
If parent is not None, attach it to parent node:
node = Internal.newGeometryReference(value='Null', file='MyCAD.iges', parent=None)
Example of use: create a new GeometryReference node (pyTree).
Internal.newArbitraryGridMotion:
create a ArbitraryGridMotion node. value is the type of motion
('NonDeformingGrid', 'DeformingGrid').
If parent is not None, attach it to parent node:
node = Internal.newArbitraryGridMotion(name='Motion',
value='Null', parent=None)
Example of use: create a new ArbitraryGridMotion node (pyTree).
Internal.newUserDefinedData:
create a UserDefinedData node to store user specific data.
If parent is not None, attach it to parent node:
node = Internal.newUserDefinedData(name='UserDefined', value=None, parent=None)
Example of use: create a new UserDefined node (pyTree).
Internal.newGravity:
create a Gravity node. value is the gravity vector.
If parent is not None, attach it to parent node:
node = Internal.newGravity(value=[0.,0.,9.81], parent=None)
Example of use: create a new Gravity node (pyTree).
Access nodes
Internal.getNodeFromPath:
return a node from its path string. Note that node path is
relative to input node A. If not found, it returns None:
node = Internal.getNodeFromPath(A, 'Base/Zone')
Example of use: return a node specified by its path (pyTree).
Internal.getPathsFromType:
return a list of paths of nodes of A from their type. A can be
a standard node or a list of standard nodes:
paths = Internal.getPathsFromType(A, 'Zone_t')
Example of use: return paths of nodes specified by their type (pyTree).
Internal.getNodesFromType:
return a list of nodes of A from their type. A can be
a standard node or a list of standard nodes:
nodes = Internal.getNodesFromType(A, 'Zone_t')
This function can be limited to 1, 2 or 3 levels from the starting node A
by using Internal.getNodesFromType1,2,3.
Example of use: return nodes specified by their type (pyTree).
Internal.getNodeFromType:
return the first node of A of given type.
A must be a standard node. Wildcards are NOT accepted. This is
a fast routine:
node = Internal.getNodeFromType(A, 'Zone_t')
This function can be limited to 1, 2 or 3 levels from the starting node A
by using Internal.getNodeFromType1,2,3.
Example of use: return first node specified by its type (pyTree).
Internal.getByType:
return a standard node containing the matching type nodes of A.
A can be a standard node or a list of standard nodes:
nodes = Internal.getByType(A, 'Zone_t', recursive=-1)
Example of use: return nodes specified by their type (pyTree).
Internal.getNodesFromName:
return a list of nodes of a pyTree from their name (wildcards allowed):
nodes = Internal.getNodesFromName(A, 'cart')
This function can be limited to 1, 2 or 3 levels from the starting node A
by using Internal.getNodesFromName1,2,3.
Example of use: return nodes specified by their name (pyTree).
Internal.getNodeFromName:
return the first node of A of given name.
A must be a standard node. Wildcards are NOT accepted. If not found,
it returns None. This is a fast routine:
node = Internal.getNodeFromName(A, 'cart')
This function can be limited to 1, 2 or 3 levels from the starting node A
by using Internal.getNodeFromName1,2,3.
Example of use: return one node specified by its name (pyTree).
Internal.getByName:
return a standard node containing the matching name nodes of A.
A can be a standard node or a list of standard nodes. Wildcards are
accepted:
nodes = Internal.getByName(A, 'cart', recursive=-1)
Example of use: return nodes specified by their name (pyTree).
Internal.getNodesFromValue:
return a list of nodes of a pyTree from their value. Value can be
a string, a numpy, a float or an int:
nodes = Internal.getNodesFromValue(A, 'Structured')
Example of use: return nodes specified by their value (pyTree).
Internal.getZones:
return the list of zone nodes:
nodes = Internal.getZones(A)
Example of use: return zone nodes (pyTree).
Internal.getBases:
return the list of base nodes:
nodes = Internal.getBases(A)
Example of use: return base nodes (pyTree).
Internal.getParentOfNode:
return the parent node of given node. start must be a higher node in the
tree. It returns p (the parent node) and c (the position number of node
in the parent's children list).
If start is a node of a pyTree, then p[2][c] = node.
If starts is a list of standard nodes, then p == start and p[c] = node.
If node is not found, then p is None:
(p, c) = Internal.getParentOfNode(start, node)
Example of use: return the parent of a given node (pyTree).
Internal.getPath:
return the path of a node in A:
path = Internal.getPath(A, node)
Example of use: return the path of a node (pyTree).
Internal.getName:
return the name of a node:
name = Internal.getName(node)
Example of use: return the name of a node (pyTree).
Internal.getType:
return the CGNS type of a node:
type = Internal.getType(node)
Example of use: return the type of a node (pyTree).
Internal.getChildren:
return the children of a node. Children is a node list:
children = Internal.getChildren(node)
Example of use: return the list children nodes of a node (pyTree).
Internal.getValue:
return the value of a node, if the node contains a string, a float or
an integer. If the node contains an array, return the numpy array:
val = Internal.getValue(node)
Example of use: return the value of a node (pyTree).
Internal.getZoneDim:
return the dimension of a zone node. Return
['Structured', ni, nj, nk, celldim] for structured grids, return
['Unstructured', np, ne, eltsName, celldim] for unstructured grids.
np is the number of points, ne the number of elements, celldim is
0, 1, 2, 3 depending on element dimension, eltsName is one of NODE,
BAR, TRI, QUAD, TETRA, PYRA, PENTA, NGON, MULTIPLE:
dims = Internal.getZoneDim(node)
Example of use: return the dim of a zone node (pyTree).
Internal.getElementRange:
return the range of an element connectivity. node must be a zone node.
In case of multiple connectivity, the name of the connectivity,
its number or its type can be specified:
range = Internal.getElementRange(node, name=None, number=None, type=None)
Example of use: return the range of an Element connectivity of a zone (pyTree).
Check nodes
Internal.printTree:
pretty print a pyTree or a pyTree node to screen or in a file:
Internal.printTree(A, file=None)
Example of use: print a pyTree to screen (pyTree).
Internal.checkPyTree:
check pyTree A following level (0: valid version node,
1: node conformity, 2: unique base name,
3: unique zone name, 4: unique BC name, 5: valid BC range, 6: valid
opposite BC range for match and nearmatch, 7: referenced familyZone and
familyBCs must be defined in bases, 8: valid CGNS types, 9: valid connectivity,
10: valid CGNS flowfield name).
Return a list of pairs of invalid nodes and error message:
errors = Internal.checkPyTree(A, level=-20)
Example of use: check a pyTree (pyTree).
Internal.correctPyTree:
correct pyTree A following level (0: valid version node,
1:node conformity, 2: unique base name,
3: unique zone name, 4: unique BC names, 5: valid BC range, 6: valid
opposite BC range for match and nearMatch, 7: referenced familyZone and
familyBCs must be defined in bases, 8: valid CGNS types,
9: valid connectivity, 10: valid CGNS flowfield name).
Non unique names are made unique.
Missing families are added. Invalid nodes are removed. Return a new tree:
B = Internal.correctPyTree(A, level=-20)
Example of use: correct a pyTree (pyTree).
Internal.checkMultigrid:
check if pyTree is compatible with multigrid of given level (only
for structured zones).
Zone dimensions, but also BCs and grid connectivities are checked.
Check if coarse grids contain at least nbMinCoarseB points per
direction.
Check if coarse boundary and connectivity point ranges
contain at least nbMinCoarseW points.
Return a list of pairs of invalid nodes and error messages:
errors = Internal.checkMultigrid(A, level=1,
nbMinCoarseB=5, nbMinCoarseW=3)
Example of use: check multigrid level for a pyTree (pyTree).
Internal.checkSize:
check if the number of points of some zones in pyTree exceed sizeMax points:
errors = Internal.checkSize(A, sizeMax=100000000)
Example of use: check size of zones for a pyTree (pyTree).
Copy nodes
Internal.copyRef:
copy a tree sharing node values (in particular data numpys are shared):
B = Internal.copyRef(A)
Example of use: copy a tree keeping references on values (pyTree).
Internal.copyTree:
fully copy a tree. Node values (in particular data numpys) are copied:
B = Internal.copyTree(A)
Example of use: full copy of a tree (pyTree).
Internal.copyValue:
copy the value of nodes specified by byName or byType string. Wildcards are accepted:
B = Internal.copyValue(A, byName=None, byType=None)
Example of use: full copy of node values by names or types (pyTree).
Internal.copyNode:
copy only this node (no recursion). Node value (in particular data numpys) is copied:
B = Internal.copyNode(A)
Example of use: full copy of a single node (pyTree).
Add/Remove nodes
Internal.append:
append a node a to A by its path. Note that the path is relative to A:
B = Internal.append(A, a, 'Base')
Example of use: append a node by its path (pyTree).
Internal.rmNode:
remove a given node b in a (node a is modified):
Internal.rmNode(a, b)
Example of use: rm a node (pyTree).
Internal.rmNodeByPath:
remove a node by its path:
a = Internal.rmNodeByPath(a, 'Base/cart') .or. B = Internal.rmNodeByPath(A, 'zone0')
Example of use: rm a node by its name (pyTree).
Internal.rmNodesByName:
remove nodes by their name. Wildcards are accepted:
b = Internal.rmNodesByName(a, 'zone0') .or. B = Internal.rmNodesByName(A, 'zone0')
Example of use: rm nodes by their name (pyTree).
Internal.rmNodesByType:
remove nodes by their type:
b = Internal.rmNodesByType(a, 'Zone_t') .or. B = Internal.rmNodesByType(A, 'Zone_t')
Example of use: rm nodes by their type (pyTree).
Internal.rmNodesByNameAndType:
remove nodes verifying name and type at the same time. Wildcards accepted
for name:
b = Internal.rmNodesByNameAndType(a, 'cart', 'Zone_t') .or. B = Internal.rmNodesByNameAndType(A, 'cart', 'Zone_t')
Example of use: rm nodes by name and type (pyTree).
Internal.rmNodesByValue:
remove nodes by their value:
b = Internal.rmNodesByValue(a, value) .or. B = Internal.rmNodesByType(A, value)
Example of use: rm nodes by their value (pyTree).
Modify nodes
Internal.sortByName:
sort nodes by their name (alphabetical order). If recursive=True,
sort also chidren nodes:
B = Internal.sortByName(A, recursive=True)
Example of use: sort nodes by their name (pyTree).
Internal.appendBaseName2ZoneName:
add base name to zone name (resulting name is baseName_zoneName for each
zone). If updateRef=True, reference to zone names in BC,... are replaced.
Separator between base and zone name can be set with separator, a trailing
string can also be added:
B = Internal.appendBaseName2ZoneName(A, updateRef=True, separator='_', trailing='')
Example of use: append base name to zone names (pyTree).
Internal.renameNode:
rename node 'name' with 'newName'. Occurances of name elsewhere
in the tree is replaced with 'newName':
B = Internal.renameNode(A, name, newName)
Example of use: rename a zone and propagate the change (pyTree).
Internal.merge:
merge a list of trees defined in [A1,A2,...]. Return a merged tree B.
If a node appears more than once in different trees of the list,
the first found node is kept:
B = Internal.merge([A1, A2, ...])
Example of use: merge trees (pyTree).
Internal.groupBCByBCType:
for each base, group all BCs of same BCType in a family named FamilyName:
b = Internal.groupBCByBCType(a, type='BCWall', name='FamWall')
Example of use: group BCs in a family (pyTree).
Internal.adaptNFace2PE:
add the ParentElements node to a NGON/NFace zone:
b = Internal.adaptNFace2PE(a, remove=True)
Example of use: add ParentElements node (pyTree).
Internal.adaptPE2NFace:
add the NFace node to a NGON zone with ParentElements:
b = Internal.adaptPE2NFace(a, remove=True)
Example of use: add NFace node (pyTree).
Internal.adaptBCFace2BCC:
add boundary connectivities for boundaries defined by BCFace:
b = Internal.adaptBCFace2BCC(a, remove=True)
Example of use: add boundary connectivities for boundaries defined by BCFace (pyTree).
Internal.adaptZoneBCEltRange2EltList:
For unstructured zones, when the boundary conditions in ZoneBC
are defined with IndexRange. Change this to IndexArray. Usefull for
fetch users:
b = Internal.adaptZoneBCEltRange2EltList(a)
Example of use: change IndexRange to IndexArray (pyTree).
Return to main userguide