Source code for tracesuite.simulation_setup

"""Provides abstract classes for block groups which are used by pyPost and pyTrace."""

from __future__ import annotations

import abc
import collections
import typing

__all__ = (
    "Block",
    "BlockGroup",
    "Component",
    "Panel",
    "PanelGroup",
    "Row",
    "Setup",
    "Stage",
)

[docs] class Setup(abc.ABC): """Complete turbomachine setup.""" @property def panel_groups(self) -> collections.ChainMap[str, PanelGroup]: """Returns dictionary of all panel groups in either TRACE or POST.""" return collections.ChainMap(self.boundaries) @property @abc.abstractmethod def block_groups(self) -> collections.ChainMap[str, BlockGroup]: """Returns dictionary of all blocks groups in either TRACE or POST.""" @property @abc.abstractmethod def blocks(self) -> dict[str, Block]: """Returns dictionary of all blocks.""" @property @abc.abstractmethod def rows(self) -> dict[str, Row]: """Returns dictionary of all rows.""" @property @abc.abstractmethod def stages(self) -> dict[str, Stage]: """Returns dictionary of all stages.""" @property @abc.abstractmethod def components(self) -> dict[str, Component]: """Returns dictionary of all components.""" @property @abc.abstractmethod def boundaries(self) -> dict[str, PanelGroup]: """Returns dictionary of all boundaries."""
[docs] class BlockGroup(abc.ABC): """Abstract class for pyTrace and pyPost block groups.""" @property @abc.abstractmethod def name(self) -> str: """Returns the block group name.""" @property @abc.abstractmethod def blocks(self) -> dict[str, Block]: """Returns a dictionary of all blocks.""" @property @abc.abstractmethod def local_blocks(self) -> dict[str, Block]: """Returns dictionary of all local blocks."""
[docs] class PanelGroup(abc.ABC): """Abstract class for pyTrace and pyPost panel groups.""" @property @abc.abstractmethod def name(self) -> str: """Returns the panel group name.""" @property @abc.abstractmethod def n_bands(self) -> int: """Return the number of bands."""
[docs] class Row(BlockGroup, abc.ABC): """Specific BlockGroup representing a single row in turbomachinery context.""" @property @abc.abstractmethod def type(self): """Returns the row type.""" @property @abc.abstractmethod def parent_stage(self) -> Stage: """Returns the parent stage.""" @property @abc.abstractmethod def parent_component(self) -> Component: """Returns the parent component.""" @property @abc.abstractmethod def is_rotating(self) -> bool: """Returns true if the row is rotating.""" @property @abc.abstractmethod def revolutions_per_minute(self) -> float: """Returns the RPM of the row."""
[docs] class Stage(BlockGroup, abc.ABC): """Specific BlockGroup representing a single stage in turbomachinery context.""" @property @abc.abstractmethod def parent_component(self) -> Component: """Returns the parent component.""" @property @abc.abstractmethod def rows(self) -> dict[str, Row]: """Returns dictionary of all rows."""
[docs] class Component(BlockGroup, abc.ABC): """Specific BlockGroup representing a single component in turbomachinery context.""" @property @abc.abstractmethod def rows(self) -> dict[str, Row]: """Returns dictionary of all rows.""" @property @abc.abstractmethod def stages(self) -> dict[str, Stage]: """Returns dictionary of all stages."""
class VolumeSource(abc.ABC): """Abstract class for volume source groups.""" @property @abc.abstractmethod def name(self) -> str: """Returns the volume source name."""
[docs] class Block(abc.ABC): """Python class representing a general block. I.e. a structured or unstructured part of the computational domain handled by an instance of `SolverCntl`. Note that Trace holds meta information of all blocks on each rank but only allocates actual (e.g. solution) data on blocks that are assigned to its own rank (i.e. local blocks). If this is a local block, dimensionalized access to the underlying data fields is provided. Furthermore, iterators can be used to loop over all cells in a single loop. All methods and properties are valid on each rank. Nevertheless, if the block is not local, fields will be empty and iterators loop length will be zero. """ variable_names: typing.ClassVar[tuple[str]] = ( "WallDistance", "Mach", "ViscosityEddy", "ViscosityEddyRatio", "TurbulentEnergyKinetic", "TurbulentDissipationRate", "TurbulenceIntensity", "TurbulentProduction", "ReynoldsStressXX", "ReynoldsStressXY", "ReynoldsStressXZ", "ReynoldsStressYY", "ReynoldsStressYZ", "ReynoldsStressZZ", "StrainNorm", "StrainRateXX", "StrainRateXY", "StrainRateXZ", "StrainRateYY", "StrainRateYZ", "StrainRateZZ", "VorticityNorm", "VorticityXY", "VorticityXZ", "VorticityYZ", "TkeGradientX", "TkeGradientY", "TkeGradientZ", "PressureGradientX", "PressureGradientY", "PressureGradientZ", "VelocityXGradientX", "VelocityXGradientY", "VelocityXGradientZ", "VelocityYGradientX", "VelocityYGradientY", "VelocityYGradientZ", "VelocityZGradientX", "VelocityZGradientY", "VelocityZGradientZ", "PerturbationMagnitudeUQ", ) @property @abc.abstractmethod def name(self) -> str: """Returns the name.""" @property @abc.abstractmethod def cells(self): """Returns the cells of the block.""" @property @abc.abstractmethod def inner_cells(self): """Returns the inner cells of the block.""" @property @abc.abstractmethod def dim(self): """Returns the dimension of the block.""" @property @abc.abstractmethod def is_local(self) -> bool: """Returns true if the block is local.""" @property @abc.abstractmethod def family(self) -> BlockGroup: """Returns the block's family."""
[docs] class Panel(abc.ABC): """Python class representing a general panel. All methods and properties are valid on each rank. """ @property @abc.abstractmethod def name(self) -> str: """Returns the name.""" @property @abc.abstractmethod def family(self) -> PanelGroup: """Returns the panel's family."""