Muscat.Bridges.CGNSBridge module¶
- CGNSToMesh(pyTree: list, baseNames: List[str] | None = None, zoneNames: List[str] | None = None, fieldsAsTags: bool = False) Mesh [source]¶
Read a CGNS tree and return a corresponding Muscat Mesh
- Parameters:
pyTree (list) – CGNS tree to read
baseNames (Optional[List[str]], optional) – Names of the CGNS Bases to treat, if None every CGNS Bases are treated. Defaults to None.
zoneNames (Optional[List[str]], optional) – Names of the CGNS Zones to treat, if None every CGNS Zones are treated. Defaults to None.
fieldsAsTags (bool, optional) – _description_. Defaults to False.
- Raises:
ValueError – if cell dimension not in [2, 3]
- Returns:
Corresponding Muscat Mesh
- Return type:
- CleanDoubleNodesOnMatch(mesh: Mesh, nodesSurfaces: list)[source]¶
Remove double nodes of a structured multi-zones mesh merged
- GetCGNSNumberToMuscat(cgnsNumber: int)[source]¶
Get Muscat ElementType from CGNS element type number
- Parameters:
cgnsNumber (int) – CGNS element type number
- Raises:
Exception – if there is no equivalent to CGNS element type in Muscat
- Returns:
Corresponding elment type in Muscat
- Return type:
res (ElementType)
- MeshToCGNS(mesh: Mesh, outputPyTree: list | None = None, tagsAsFields: bool = False, exportOriginalIDs: bool = True, updateZone: bool | str = False, defaultFamilyName: str = 'Bulk')[source]¶
Write a CGNS Tree from a Muscat Mesh
- Parameters:
mesh (Mesh) – Muscat Mesh to export in CGNS.
outputPyTree (list, optional) – If the mesh has to be written in an pre-existing CGNS tree. Defaults to None.
tagsAsFields (bool, optional) – Create a field FlowSolution with tags for paraview visualisation. Defaults to False.
exportOriginalIDs (bool, optional) – Create a OriginalIds data array in the CGNS. Defaults to True.
updateZone (Union[bool, str], optional) – If outputPyTree, zones to update can be specified: True -> all zones, False -> no update, zone name -> only this zone. Defaults to False.
defaultFamilyName (str, optional) – Default family name. Defaults to “Bulk”.
- Raises:
RuntimeError – Mesh points dimensionality should be in [2, 3]
- Returns:
CGNS tree including Muscat Mesh
- Return type:
outputPyTree (list)
- StructuredZoneSurfaceIds(zone: list, offset: int)[source]¶
Get global ids of the nodes on the surface of CGNS structured zone
- Parameters:
zone (list) – zone node to treat
offset (int) – offset for the zone node ids in the global mesh
- Returns:
global ids of node on each boundary surface of the zone
- Return type:
res (list)
- createMissingFamilies(tree: list)[source]¶
Check and create if missing corresponding Family_t node for every FamilyName_t node found.
- Parameters:
tree (list) – CGNSTree_t or CGNSBase_t to check and complete
- newFamilyName(parent: list, family: str, base: list = None)[source]¶
Add a FamilyName to a node
- Parameters:
parent (list) – CGNS pytree where to add the new FamilyName node
family (str) – Name of the family to set
base (list, optional) – Ancestor CGNSBase_t node to automatically create the corresponding family. Defaults to None.
- newZoneSubRegion(parent: list, name: str, pointList: ndarray[Any, dtype[_ScalarType_co]], dim: int, gridLocation: str = 'CellCenter', family: str = '')[source]¶
Create a new ZoneSubRegion in CGNS pytree
- Parameters:
parent (list) – CGNS pytree where to add the new ZoneSubRegion node
name (str) – name of the CGNS ZoneSubRegion node
pointList (NDArray) – list of nodes or elements to add to the ZoneSubRegion
dim (int) – physical dimension of the CGNS pytree (2 for 2D, 3 for 3D)
gridLocation (str, optional) – Determine if it is a selection of nodes or elements. Defaults to “CellCenter”.
family (str, optional) – Corresponding familyName. Defaults to “”.
- Returns:
ZoneSubRegion node
- Return type:
znode (list)