diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 22d5f7a3d..2c8f9000d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.8", "3.9", "3.10"] os: ["windows-latest", "ubuntu-latest"] steps: diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml index bf298d87c..9f00bdedc 100644 --- a/.github/workflows/ci_release.yml +++ b/.github/workflows/ci_release.yml @@ -56,7 +56,9 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8", "3.9", "3.10"] + ANSYS_VERSION: ["241"] + suffix: [".pre0"] + python-version: ["3.8", "3.9", "3.10"] os: ["windows-latest", "ubuntu-latest"] steps: @@ -73,14 +75,14 @@ jobs: uses: ansys/pydpf-actions/build_package@v2.3 with: python-version: ${{ matrix.python-version }} - ANSYS_VERSION: '241' + ANSYS_VERSION: ${{ matrix.ANSYS_VERSION }} PACKAGE_NAME: ${{env.PACKAGE_NAME}} MODULE: ${{env.MODULE}} dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}} install_extras: plotting wheel: true wheelhouse: true - standalone_suffix: '' + standalone_suffix: ${{ matrix.suffix }} - name: "Prepare Testing Environment" uses: ansys/pydpf-actions/prepare_tests@v2.3 @@ -191,14 +193,14 @@ jobs: with: ANSYS_VERSION: '241' python_versions: '["3.10"]' - standalone_suffix: '' + standalone_suffix: '.pre0' secrets: inherit docs: uses: ./.github/workflows/docs.yml with: ANSYS_VERSION: '241' - standalone_suffix: '' + standalone_suffix: '.pre0' event_name: ${{ github.event_name }} secrets: inherit diff --git a/README.md b/README.md index c8804a6c8..77080dc8d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,16 @@ The Python `ansys-dpf-post` package provides a high-level, physics-oriented API Loading a simulation (defined by its result files) allows you to extract simulation metadata as well as results and then apply postprocessing operations on it. +The latest version of DPF supports Ansys solver result files for: + + - MAPDL (`.rst`, `.mode`, `.rfrq`, `.rdsp`) + - LS-DYNA (`.d3plot`, `.binout`) + - Fluent (`.cas/dat.h5`, `.flprj`) + - CFX (`.cad/dat.cff`, `.flprj`) + +See the `PyDPF-Core main page `_ +for more information on compatibility. + This module leverages the PyDPF-Core project's ``ansys-dpf-core`` package, which is available at [PyDPF-Core GitHub](https://github.com/ansys/pydpf-core). Use the ``ansys-dpf-core`` package for building more advanced and customized workflows @@ -41,10 +51,10 @@ pip install . --user ## Brief demo -Provided you have Ansys 2023 R1 installed, a DPF server starts +Provided you have Ansys 2023 R1 or later installed, a DPF server starts automatically once you start using PyDPF-Post. -To load a simulation to extract and postprocess results, use this code: +To load a simulation to extract and post-process results, use this code: ```pycon >>> from ansys.dpf import post @@ -54,16 +64,16 @@ To load a simulation to extract and postprocess results, use this code: >>> print(displacement) ``` ```pycon - results U - set_id 3 - node comp - 4872 X -3.41e-05 - Y 1.54e-03 - Z -2.64e-06 - 9005 X -5.56e-05 - Y 1.44e-03 - Z 5.31e-06 - ... + results U (m) + set_ids 3 + node_ids components + 4872 X -3.4137e-05 + Y 1.5417e-03 + Z -2.6398e-06 + 9005 X -5.5625e-05 + Y 1.4448e-03 + Z 5.3134e-06 + ... ... ... ``` ```pycon >>> displacement.plot() diff --git a/docs/source/images/crankshaft_disp.png b/docs/source/images/crankshaft_disp.png index 3a91e9cf1..fc6d0c4de 100644 Binary files a/docs/source/images/crankshaft_disp.png and b/docs/source/images/crankshaft_disp.png differ diff --git a/docs/source/images/crankshaft_stress.png b/docs/source/images/crankshaft_stress.png index a61ab5cb3..281c864e5 100644 Binary files a/docs/source/images/crankshaft_stress.png and b/docs/source/images/crankshaft_stress.png differ diff --git a/docs/source/index.rst b/docs/source/index.rst index 531e567a5..7f7e9fc23 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -11,6 +11,16 @@ for postprocessing. Loading a simulation (defined by its result files) allows yo to extract simulation metadata as well as results and then apply postprocessing operations on it. +The latest version of DPF supports Ansys solver result files for: + +- MAPDL (``.rst``, ``.mode``, ``.rfrq``, ``.rdsp``) +- LS-DYNA (``.d3plot``, ``.binout``) +- Fluent (``.cas/dat.h5``, ``.flprj``) +- CFX (``.cad/dat.cff``, ``.flprj``) + +See the `PyDPF-Core main page `_ +for more information on file support. + This module leverages the PyDPF-Core project's ``ansys-dpf-core`` package, which is available at `PyDPF-Core GitHub `_. Use the ``ansys-dpf-core`` package for building more advanced and customized diff --git a/docs/source/user_guide/known_issues_list.rst b/docs/source/user_guide/known_issues_list.rst new file mode 100644 index 000000000..cceea2ac8 --- /dev/null +++ b/docs/source/user_guide/known_issues_list.rst @@ -0,0 +1,31 @@ +.. _ref_kil: + +============ +Known issues +============ + +This page gathers the known issues a user can experience for each version of DPF. + +ansys-dpf-server-2023-2-pre1 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +ansys-dpf-server-2023-2-pre0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +- Pip install error with ``setuptools>=67.0.0``. + + +Ansys 2023R1 +~~~~~~~~~~~~ + + +Ansys 2022R2 +~~~~~~~~~~~~ + + +Ansys 2022R1 +~~~~~~~~~~~~ + + +Ansys 2021R2 +~~~~~~~~~~~~ diff --git a/docs/source/user_guide/troubleshooting.rst b/docs/source/user_guide/troubleshooting.rst index 266cbf88c..861d8c440 100644 --- a/docs/source/user_guide/troubleshooting.rst +++ b/docs/source/user_guide/troubleshooting.rst @@ -6,6 +6,28 @@ Troubleshooting This section explains how to resolve the most common issues encountered with PyDPF-Post. It also includes suggestions for improving scripts. + +Known issues list +~~~~~~~~~~~~~~~~~ +Please refer to the :ref:`Known issues page ` for a list of known issues for each version of DPF. + + +Installation +~~~~~~~~~~~~ +When pip installing older versions of the PyDPF libraries, an error might occur stating: + +.. code-block:: shell-session + + 'python_requires' must be a string containing valid version specifiers; Invalid specifier: '>=3.7.*' + +In this case, modify your Python environment to use a version of the ``setuptools`` library strictly +older than ``67.0.0`` using the command below: + +.. code:: + + pip uninstall -y packaging; pip uninstall -y setuptools; pip install "setuptools<67.0.0" + + Auto-completion ~~~~~~~~~~~~~~~ Depending on your scripting environment, auto-completion might not work correctly when using the diff --git a/examples/00-Different-analysis-types/05-fluid-simulation.py b/examples/00-Different-analysis-types/05-fluid-simulation.py index cee36153d..48e3c9caa 100644 --- a/examples/00-Different-analysis-types/05-fluid-simulation.py +++ b/examples/00-Different-analysis-types/05-fluid-simulation.py @@ -29,10 +29,17 @@ ############################################################################### -# Explore the available structure -# ------------------------------- +# Explore the available metadata +# ------------------------------ # Check the available cell and face zones -# print(simulation.zones) +print(simulation.cell_zones) +print(simulation.face_zones) + +############################################################################### +# The mesh metadata is available separately from the mesh +# as accessing the mesh means loading it. +# Use the mesh_info property to explore the mesh structure to define queries +print(simulation.mesh_info) ############################################################################### # Check the available species diff --git a/examples/04-Fluid-Examples/00-explore-fluid-simulation.py b/examples/04-Fluid-Examples/00-explore-fluid-simulation.py index 6532af028..ff7e1d69c 100644 --- a/examples/04-Fluid-Examples/00-explore-fluid-simulation.py +++ b/examples/04-Fluid-Examples/00-explore-fluid-simulation.py @@ -29,10 +29,17 @@ ############################################################################### -# Explore the available structure -# ------------------------------- +# Explore the available metadata +# ------------------------------ # Check the available cell and face zones -# print(simulation.zones) +print(simulation.cell_zones) +print(simulation.face_zones) + +############################################################################### +# The mesh metadata is available separately from the mesh +# as accessing the mesh means loading it. +# Use the mesh_info property to explore the mesh structure to define queries +print(simulation.mesh_info) ############################################################################### # Check the available species diff --git a/pyproject.toml b/pyproject.toml index 7d392cb80..a406a6a23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ name = "ansys-dpf-post" version = "0.4.1.dev0" description = "PyDPF-Post Python library." readme = "README.md" -requires-python = ">=3.7,<4.0" +requires-python = ">=3.8,<4.0" license = {file = "LICENSE"} authors = [ {name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"}, diff --git a/requirements/requirements_docs.txt b/requirements/requirements_docs.txt index bc4777f7e..8cf3c92ca 100644 --- a/requirements/requirements_docs.txt +++ b/requirements/requirements_docs.txt @@ -2,7 +2,7 @@ pypandoc==1.10 imageio==2.31.0 numpydoc==1.4.0 imageio-ffmpeg==0.4.7 -Sphinx==7.0.0 +Sphinx==7.1.0 sphinx-autobuild==2021.3.14 sphinxcontrib-napoleon==0.7 sphinxcontrib-websupport==1.2.4 diff --git a/requirements/requirements_test.txt b/requirements/requirements_test.txt index 02d36afc5..73678c6d3 100644 --- a/requirements/requirements_test.txt +++ b/requirements/requirements_test.txt @@ -1,5 +1,5 @@ coverage==7.2.7 pytest-cov==4.0.0 pytest-rerunfailures==11.0 -pytest==7.3.1 +pytest==7.4.0 pyvista==0.38.5 diff --git a/src/ansys/dpf/post/__init__.py b/src/ansys/dpf/post/__init__.py index 0c90727d7..54fc2eb9b 100644 --- a/src/ansys/dpf/post/__init__.py +++ b/src/ansys/dpf/post/__init__.py @@ -52,7 +52,6 @@ from ansys.dpf.post.transient_mechanical_simulation import ( # noqa: F401 TransientMechanicalSimulation, ) -from ansys.dpf.post.zone import Zone, Zones # noqa: F401 # this must be after some ansys.dpf.post import __version__ = importlib_metadata.version("ansys-dpf-post") diff --git a/src/ansys/dpf/post/dataframe.py b/src/ansys/dpf/post/dataframe.py index e79b10c97..ad851d34d 100644 --- a/src/ansys/dpf/post/dataframe.py +++ b/src/ansys/dpf/post/dataframe.py @@ -736,6 +736,8 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None The interactive plotter object used for plotting. """ + if len(self.index.mesh_index) == 0: + raise ValueError("Cannot plot a Dataframe with an empty mesh index.") label_space = {} if kwargs != {}: axis_kwargs, kwargs = self._filter_arguments(arguments=kwargs) @@ -772,6 +774,8 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None fc = self._fc label_space = fc.get_label_space(0) + if len(fc) == 0: + raise ValueError("No data to plot.") for field in fc: # Treat multi-layer field shell_layer_check = field.shell_layers diff --git a/src/ansys/dpf/post/faces.py b/src/ansys/dpf/post/faces.py new file mode 100644 index 000000000..656d2419e --- /dev/null +++ b/src/ansys/dpf/post/faces.py @@ -0,0 +1,159 @@ +"""This module contains Face and Faces classes.""" + +from __future__ import annotations + +from abc import ABC, abstractmethod +from typing import List + +from ansys.dpf.core import errors +from ansys.dpf.core import faces as core_faces + +from ansys.dpf.post.elements import ElementType +from ansys.dpf.post.nodes import NodeListByIndex + + +class Face: + """Proxy class wrapping dpf.core.faces.Face.""" + + def __init__(self, face: core_faces.Face): + """Constructs a Proxy Face object.""" + self._face = face + + @property + def node_ids(self) -> List[int]: + """See :py:meth:`ansys.dpf.core.faces.Face.node_ids`.""" + return self._face.node_ids + + @property + def id(self) -> int: + """See :py:meth:`ansys.dpf.core.faces.Face.id`.""" + return self._face.id + + @property + def index(self) -> int: + """See :py:meth:`ansys.dpf.core.faces.Face.index`.""" + return self._face.index + + @property + def nodes(self) -> NodeListByIndex: + """See :py:meth:`ansys.dpf.post.nodes.NodeListByIndex`.""" + return NodeListByIndex(self._face.nodes) + + @property + def num_nodes(self) -> int: + """See :py:meth:`ansys.dpf.core.faces.Face.n_nodes`.""" + return self._face.n_nodes + + @property + def type_info(self) -> ElementType: + """Gets an element descriptor, See :py:meth:`ansys.dpf.core.faces.Face.id`.""" + return ElementType(self._face.type.value) + + @property + def type(self) -> core_elements.element_types: + """Returns the Element Type.""" + return self._face.type + + @property + def to_node_connectivity(self) -> List[int]: + """See :py:meth:`ansys.dpf.core.faces.Face.connectivity`.""" + return self._face.connectivity + + def __repr__(self) -> str: + """Returns string representation of a Face.""" + return f"Face(type={self.type},index={self.index},id={self.id})" + + def __str__(self) -> str: + """Returns string representation of a Face.""" + return str(self._face) + + +class _FaceList(ABC): + """Iterator class for the FaceList.""" + + def __init__(self, face_list: core_faces.Faces): + """Constructs an Iterator from a face list.""" + self._face_list = face_list + self._idx = 0 + + def __next__(self) -> Face: + """Returns the next Face in the list.""" + if self._idx >= len(self._face_list): + raise StopIteration + ret = self[self._idx] + self._idx += 1 + return ret + + def __getitem__(self, index: int) -> Face: + """Returns a post.Face based on an index in the current list.""" + return Face(self._face_list[index]) + + def __len__(self) -> int: + """Returns the number of faces in the list.""" + return self._face_list.n_faces + + def __repr__(self) -> str: + """Returns a string representation of _FaceList object.""" + return f"{self.__class__.__name__}({self}, __len__={len(self)})" + + def _short_list(self) -> str: + _str = "[" + if self.__len__() > 3: + _fst = Face(self._face_list[0]).type_info.name + _lst = Face(self._face_list[len(self) - 1]).type_info.name + _str += f"{_fst}, ..., {_lst}" + else: + face_list = [Face(self._face_list[idx]) for idx in range(len(self))] + _str += ", ".join(map(lambda el: el.type_info.name, face_list)) + _str += "]" + return _str + + def __str__(self) -> str: + """Returns a string representation of a _FaceList object.""" + return self._short_list() + + @abstractmethod + def __iter__(self): # pragma: no cover + """Returns the object to iterate on.""" + raise NotImplementedError + + +class FaceListByIndex(_FaceList): + """Face list object using indexes as input.""" + + @property + def by_id(self) -> FaceListById: + """Returns an equivalent list which accepts IDs as input.""" + return FaceListById(self._face_list) + + def __iter__(self) -> FaceListByIndex: + """Returns the object to iterate over.""" + self._idx = 0 + return self + + def __contains__(self, face: Face) -> bool: + """Checks if the given element in the list.""" + return len(self) > face.index >= 0 + + +class FaceListById(_FaceList): + """Face list object using IDs as input.""" + + def __getitem__(self, id: int) -> Face: # pylint: disable=redefined-builtin + """Access a Face with an ID.""" + idx = self._face_list.scoping.index(id) + try: + return super().__getitem__(idx) + except errors.DPFServerException as e: + if "face not found" in str(e): + raise ValueError(f"Face with ID={id} not found in the list.") + else: + raise e # pragma: no cover + + def __contains__(self, face: Face) -> bool: + """Checks if the given face is in the list.""" + return face.id in self._face_list.scoping.ids + + def __iter__(self) -> FaceListByIndex: + """Returns the object to iterate over.""" + return FaceListByIndex(self._face_list) diff --git a/src/ansys/dpf/post/fluid_simulation.py b/src/ansys/dpf/post/fluid_simulation.py index 5f26d3212..c4be464be 100644 --- a/src/ansys/dpf/post/fluid_simulation.py +++ b/src/ansys/dpf/post/fluid_simulation.py @@ -10,11 +10,11 @@ from ansys.dpf import core as dpf from ansys.dpf.post import locations from ansys.dpf.post.dataframe import DataFrame +from ansys.dpf.post.mesh_info import FluidMeshInfo from ansys.dpf.post.phase import PhasesDict from ansys.dpf.post.selection import Selection from ansys.dpf.post.simulation import ResultCategory, Simulation from ansys.dpf.post.species import SpeciesDict -from ansys.dpf.post.zone import Zones class FluidSimulation(Simulation): @@ -62,13 +62,15 @@ def _build_selection( elif cell_ids is not None: if location == locations.nodal: selection.select_nodes_of_elements(elements=cell_ids, mesh=self.mesh) + elif location == locations.faces: + selection.select_faces_of_elements(elements=cell_ids, mesh=self.mesh) else: selection.select_elements(elements=cell_ids) elif face_ids is not None: if location == locations.nodal: - selection.select_nodes_of_elements(elements=face_ids, mesh=self.mesh) + selection.select_nodes_of_faces(faces=face_ids, mesh=self.mesh) else: - selection.select_elements(elements=face_ids) + selection.select_faces(faces=face_ids) elif node_ids is not None: if location != locations.nodal: raise ValueError( @@ -164,27 +166,49 @@ def __init__( model = dpf.Model(ds, server=server) data_sources = model.metadata.data_sources super().__init__(data_sources=data_sources, model=model) + self._mesh_info = None @property - def zones(self) -> Zones: - """Return the list of Zones in the simulation.""" - return Zones() + def mesh_info(self) -> FluidMeshInfo: + """Return available mesh information.""" + if not self._mesh_info: + self._mesh_info = FluidMeshInfo(self._model.metadata.mesh_info) + return self._mesh_info + + @property + def cell_zones(self) -> dict: + """Return a dictionary of the cell zones in the simulation.""" + return self.mesh_info.cell_zones + + @property + def face_zones(self) -> dict: + """Return a dictionary of the face zones in the simulation.""" + return self.mesh_info.face_zones @property def species(self) -> SpeciesDict: - """Return the list of Species in the simulation.""" + """Return a dictionary-like object of species in the simulation.""" return SpeciesDict(self) @property def phases(self) -> PhasesDict: - """Return the list of PhasesDict in the simulation.""" + """Return a dictionary-like object of phases in the simulation.""" return PhasesDict(self) + def _filter_zones(self, zone_ids: List[int], keep: locations): + """Filter zone IDs to only keep zones of the given type.""" + if keep == locations.elemental: + ref = set(self.cell_zones.keys()) + elif keep == locations.faces: + ref = set(self.face_zones.keys()) + return [i for i in zone_ids if i in ref] + def _get_result( self, base_name: str, category: ResultCategory, - location: Union[str, None] = None, + native_location: str, + location: Union[locations, str, None] = None, components: Union[str, List[str], int, List[int], None] = None, norm: bool = False, selection: Union[Selection, None] = None, @@ -199,6 +223,7 @@ def _get_result( species: Union[List[int], None] = None, qualifiers: Union[dict, None] = None, named_selections: Union[List[str], str, None] = None, + integrated: Union[bool, None] = None, ) -> DataFrame: """Extract results from the simulation. @@ -218,14 +243,15 @@ def _get_result( Base name for the requested result. category: Type of result requested. See the :class:`ResultCategory` class. + native_location: + Native location of the result. location: Location to extract results at. Available locations are listed in class:`post.locations` and are: `post.locations.nodal`, - `post.locations.elemental`, and `post.locations.elemental_nodal`. - Using the default `post.locations.elemental_nodal` results in a value - for every node at each element. Similarly, using `post.locations.elemental` - gives results with one value for each element, while using `post.locations.nodal` - gives results with one value for each node. + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. components: Components to get results for. norm: @@ -257,6 +283,8 @@ def _get_result( Overrides any other qualifier argument such as `phases`, `species` or `zone_ids`. named_selections: Named selection or list of named selections to get results for. + integrated: + An integrated result cannot be requested on another location than its native_location. Returns ------- @@ -276,6 +304,66 @@ def _get_result( "are mutually exclusive." ) + # Raise for integrated result queried on anything else than its native location + if integrated: + if (native_location == "Faces" and location != locations.faces) or ( + native_location == "Elements" and location != locations.elemental + ): + raise ValueError( + f"Cannot query a {native_location} integrated result on {location}." + ) + + # Define required averaging step + averaging_op_name = None + if native_location == "Nodes": + if location != locations.nodal: + averaging_op_name = "to_elemental_fc" + elif native_location == "Elemental": + if location == locations.faces: + raise ValueError("Cannot query elemental results on faces.") + elif location == locations.nodal: + # averaging_op_name = "to_nodal_fc" + pass # nodal averaging seems to be automatic + elif native_location == "Faces": + if location == locations.elemental: + raise ValueError("Cannot query faces results on elements.") + elif location == locations.nodal: + # averaging_op_name = "to_nodal_fc" + pass # nodal averaging seems to be automatic + elif native_location == "ElementalAndFaces": + if location == locations.nodal: + # averaging_op_name = "to_nodal_fc" + pass # nodal averaging seems to be automatic + elif location == locations.faces: + if qualifiers and ("zone" in qualifiers): + qualifiers["zone"] = self._filter_zones( + zone_ids=qualifiers["zone"], keep=locations.faces + ) + elif zone_ids: + zone_ids = self._filter_zones( + zone_ids=zone_ids, keep=locations.faces + ) + else: + if not self._model._server.meet_version("7.1"): + raise ValueError( + "Querying an ElementalAndFaces result on faces " + "currently requires the use of face zone ids in the " + "'qualifiers' or the 'zone_ids' arguments." + ) + else: + raise NotImplementedError + + elif location == locations.elemental: + # CFF only returns results on face zones if qualifiers have been set + if qualifiers and ("zone" in qualifiers): + qualifiers["zone"] = self._filter_zones( + zone_ids=qualifiers["zone"], keep=locations.elemental + ) + elif zone_ids: + zone_ids = self._filter_zones( + zone_ids=zone_ids, keep=locations.elemental + ) + selection = self._build_selection( base_name=base_name, category=category, @@ -362,6 +450,12 @@ def _get_result( wf.add_operator(operator=norm_op) out = norm_op.outputs.fields_container + # if averaging_op_name: + # average_op = self._model.operator(name=averaging_op_name) + # average_op.connect(0, out) + # wf.add_operator(operator=average_op) + # out = average_op.outputs.fields_container + # Set the workflow output wf.set_output_name("out", out) wf.progress_bar = False @@ -376,6 +470,12 @@ def _get_result( fc, location, columns, comp, base_name.split("::")[-1], None ) + def _try_get_result_info(self, name: str): + try: + return self.result_info[name] + except ValueError: + raise ValueError(f"Result {name} is not available.") + def density( self, node_ids: Union[List[int], None] = None, @@ -390,6 +490,7 @@ def density( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract density results from the simulation. @@ -432,15 +533,23 @@ def density( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("density") return self._get_result( - base_name="RHO", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -456,6 +565,7 @@ def density( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def density_on_nodes( @@ -520,8 +630,9 @@ def density_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("density") return self._get_result( - base_name="RHO", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -538,12 +649,13 @@ def density_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def density_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -560,7 +672,7 @@ def density_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `face_ids`, and `cell_ids` are mutually + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -570,8 +682,6 @@ def density_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -599,8 +709,9 @@ def density_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("density") return self._get_result( - base_name="RHO", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -611,12 +722,13 @@ def density_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def density_on_cells( @@ -675,8 +787,9 @@ def density_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("density") return self._get_result( - base_name="RHO", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -693,6 +806,7 @@ def density_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def dynamic_viscosity( @@ -709,6 +823,7 @@ def dynamic_viscosity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract dynamic viscosity results from the simulation. @@ -751,15 +866,23 @@ def dynamic_viscosity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("dynamic_viscosity") return self._get_result( - base_name="MU", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -775,6 +898,7 @@ def dynamic_viscosity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def dynamic_viscosity_on_nodes( @@ -792,7 +916,7 @@ def dynamic_viscosity_on_nodes( named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, ) -> DataFrame: - """Extract dynamic viscosity results from the simulation. + """Extract dynamic viscosity results on nodes from the simulation. Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. @@ -839,8 +963,9 @@ def dynamic_viscosity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("dynamic_viscosity") return self._get_result( - base_name="MU", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -857,12 +982,13 @@ def dynamic_viscosity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def dynamic_viscosity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -879,7 +1005,7 @@ def dynamic_viscosity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -889,8 +1015,6 @@ def dynamic_viscosity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -918,8 +1042,9 @@ def dynamic_viscosity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("dynamic_viscosity") return self._get_result( - base_name="MU", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -930,12 +1055,13 @@ def dynamic_viscosity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def dynamic_viscosity_on_cells( @@ -994,8 +1120,9 @@ def dynamic_viscosity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("dynamic_viscosity") return self._get_result( - base_name="MU", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -1012,6 +1139,7 @@ def dynamic_viscosity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def enthalpy( @@ -1028,6 +1156,7 @@ def enthalpy( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract enthalpy results from the simulation. @@ -1070,15 +1199,23 @@ def enthalpy( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("enthalpy") return self._get_result( - base_name="H_S", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -1094,6 +1231,7 @@ def enthalpy( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def enthalpy_on_nodes( @@ -1158,8 +1296,9 @@ def enthalpy_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("enthalpy") return self._get_result( - base_name="H_S", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -1176,12 +1315,13 @@ def enthalpy_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def enthalpy_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -1198,7 +1338,7 @@ def enthalpy_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -1208,8 +1348,6 @@ def enthalpy_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -1237,8 +1375,9 @@ def enthalpy_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("enthalpy") return self._get_result( - base_name="H_S", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -1249,12 +1388,13 @@ def enthalpy_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def enthalpy_on_cells( @@ -1313,8 +1453,9 @@ def enthalpy_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("enthalpy") return self._get_result( - base_name="H_S", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -1331,6 +1472,7 @@ def enthalpy_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def entropy( @@ -1347,6 +1489,7 @@ def entropy( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract entropy results from the simulation. @@ -1389,15 +1532,23 @@ def entropy( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("entropy") return self._get_result( - base_name="S_S", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -1413,6 +1564,7 @@ def entropy( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def entropy_on_nodes( @@ -1477,8 +1629,9 @@ def entropy_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("entropy") return self._get_result( - base_name="S_S", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -1495,12 +1648,13 @@ def entropy_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def entropy_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -1517,7 +1671,7 @@ def entropy_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -1527,8 +1681,6 @@ def entropy_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -1556,8 +1708,9 @@ def entropy_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("entropy") return self._get_result( - base_name="S_S", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -1568,12 +1721,13 @@ def entropy_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def entropy_on_cells( @@ -1632,8 +1786,9 @@ def entropy_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("entropy") return self._get_result( - base_name="S_S", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -1650,6 +1805,7 @@ def entropy_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def epsilon( @@ -1666,6 +1822,7 @@ def epsilon( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract epsilon results from the simulation. @@ -1708,15 +1865,23 @@ def epsilon( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("epsilon") return self._get_result( - base_name="EPS", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -1732,6 +1897,7 @@ def epsilon( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def epsilon_on_nodes( @@ -1796,8 +1962,9 @@ def epsilon_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("epsilon") return self._get_result( - base_name="EPS", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -1814,12 +1981,13 @@ def epsilon_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def epsilon_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -1836,7 +2004,7 @@ def epsilon_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -1846,8 +2014,6 @@ def epsilon_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -1875,8 +2041,9 @@ def epsilon_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("epsilon") return self._get_result( - base_name="EPS", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -1887,12 +2054,13 @@ def epsilon_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def epsilon_on_cells( @@ -1951,8 +2119,9 @@ def epsilon_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("epsilon") return self._get_result( - base_name="EPS", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -1969,6 +2138,7 @@ def epsilon_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mach_number( @@ -1985,6 +2155,7 @@ def mach_number( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract mach number results from the simulation. @@ -2027,15 +2198,23 @@ def mach_number( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mach_number") return self._get_result( - base_name="MACH", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -2051,6 +2230,7 @@ def mach_number( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mach_number_on_nodes( @@ -2115,8 +2295,9 @@ def mach_number_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mach_number") return self._get_result( - base_name="MACH", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -2133,12 +2314,13 @@ def mach_number_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mach_number_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -2155,7 +2337,7 @@ def mach_number_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -2165,8 +2347,6 @@ def mach_number_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -2194,8 +2374,9 @@ def mach_number_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mach_number") return self._get_result( - base_name="MACH", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -2206,12 +2387,13 @@ def mach_number_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mach_number_on_cells( @@ -2227,7 +2409,7 @@ def mach_number_on_cells( named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, ) -> DataFrame: - """Extract mach number results from the simulation. + """Extract mach number results on cells from the simulation. Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. @@ -2270,8 +2452,9 @@ def mach_number_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mach_number") return self._get_result( - base_name="MACH", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -2288,13 +2471,13 @@ def mach_number_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mass_flow_rate( self, - node_ids: Union[List[int], None] = None, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -2305,95 +2488,16 @@ def mass_flow_rate( named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, ) -> DataFrame: - """Extract mass flow rate results from the simulation. - - Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually - exclusive. - If none of the above is given, only the last result will be returned. - - Arguments `selection`, `named_selections`, `cell_ids`, `face_ids`, and `node_ids` - are mutually exclusive. - If none of the above is given, results will be extracted for the whole mesh. - - Argument `qualifiers` overrides arguments `zones_ids`, `phases`, and `species`. - - Parameters - ---------- - node_ids: - List of IDs of nodes to get results for. - face_ids: - List of IDs of faces to get results for. - cell_ids: - List of IDs of cells to get results for. - zone_ids: - List of IDs of zones to get results for. - phases: - List of IDs of phases to get results for. - species: - List of IDs of species to get results for. - qualifiers: - Dictionary of qualifier labels with associated values to get results for. - Overrides any other qualifier argument such as `phases`, `species` or `zone_ids`. - times: - List of time values to get results for. - set_ids: - Sets to get results for. - A set is defined as a unique combination of {time, load step, sub-step}. - all_sets: - Whether to get results for all sets. - named_selections: - Named selection or list of named selections to get results for. - selection: - Selection to get results for. - A Selection defines both spatial and time-like criteria for filtering. - - Returns - ------- - Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. - - """ - return self._get_result( - base_name="MDOT", - location=None, - category=ResultCategory.scalar, - components=None, - norm=False, - selection=selection, - times=times, - set_ids=set_ids, - all_sets=all_sets, - node_ids=node_ids, - face_ids=face_ids, - cell_ids=cell_ids, - zone_ids=zone_ids, - qualifiers=qualifiers, - phases=phases, - species=species, - named_selections=named_selections, - ) + """Extract mass flow rate results on faces from the simulation. - def mass_flow_rate_on_nodes( - self, - node_ids: Union[List[int], None] = None, - face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, - zone_ids: Union[List[int], None] = None, - phases: Union[List[Union[int, str]], None] = None, - species: Union[List[int], None] = None, - qualifiers: Union[dict, None] = None, - times: Union[float, List[float], None] = None, - set_ids: Union[int, List[int], None] = None, - all_sets: bool = False, - named_selections: Union[List[str], str, None] = None, - selection: Union[Selection, None] = None, - ) -> DataFrame: - """Extract mass flow rate results on nodes from the simulation. + .. note:: + This is an integrated result only available on faces. Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, `face_ids`, and `node_ids` + Arguments `selection`, `named_selections`, `face_ids`, and `node_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -2401,12 +2505,8 @@ def mass_flow_rate_on_nodes( Parameters ---------- - node_ids: - List of IDs of nodes to get results for. face_ids: - List of IDs of faces which nodes to get results for. - cell_ids: - List of IDs of cells which nodes to get results for. + List of IDs of faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -2434,9 +2534,10 @@ def mass_flow_rate_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_flow_rate") return self._get_result( - base_name="MDOT", - location=locations.nodal, + base_name=result_info.operator_name, + location=locations.faces, category=ResultCategory.scalar, components=None, norm=False, @@ -2444,20 +2545,22 @@ def mass_flow_rate_on_nodes( times=times, set_ids=set_ids, all_sets=all_sets, - node_ids=node_ids, + node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + integrated=True, + native_location=result_info.native_location, ) def mass_flow_rate_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -2470,11 +2573,14 @@ def mass_flow_rate_on_faces( ) -> DataFrame: """Extract mass flow rate results on faces from the simulation. + .. note:: + This is an integrated result only available on faces. + Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -2484,8 +2590,6 @@ def mass_flow_rate_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -2513,8 +2617,9 @@ def mass_flow_rate_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_flow_rate") return self._get_result( - base_name="MDOT", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -2525,88 +2630,14 @@ def mass_flow_rate_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, - zone_ids=zone_ids, - qualifiers=qualifiers, - phases=phases, - species=species, - named_selections=named_selections, - ) - - def mass_flow_rate_on_cells( - self, - cell_ids: Union[List[int], None] = None, - zone_ids: Union[List[int], None] = None, - phases: Union[List[Union[int, str]], None] = None, - species: Union[List[int], None] = None, - qualifiers: Union[dict, None] = None, - times: Union[float, List[float], None] = None, - set_ids: Union[int, List[int], None] = None, - all_sets: bool = False, - named_selections: Union[List[str], str, None] = None, - selection: Union[Selection, None] = None, - ) -> DataFrame: - """Extract mass flow rate results on cells from the simulation. - - Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually - exclusive. - If none of the above is given, only the last result will be returned. - - Arguments `selection`, `named_selections`, and `cell_ids` - are mutually exclusive. - If none of the above is given, results will be extracted for the whole mesh. - - Argument `qualifiers` overrides arguments `zones_ids`, `phases`, and `species`. - - Parameters - ---------- - cell_ids: - List of IDs of cells to get results for. - zone_ids: - List of IDs of zones to get results for. - phases: - List of IDs of phases to get results for. - species: - List of IDs of species to get results for. - qualifiers: - Dictionary of qualifier labels with associated values to get results for. - Overrides any other qualifier argument such as `phases`, `species` or `zone_ids`. - times: - List of time values to get results for. - set_ids: - Sets to get results for. - A set is defined as a unique combination of {time, load step, sub-step}. - all_sets: - Whether to get results for all sets. - named_selections: - Named selection or list of named selections to get results for. - selection: - Selection to get results for. - A Selection defines both spatial and time-like criteria for filtering. - - Returns - ------- - Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. - - """ - return self._get_result( - base_name="MDOT", - location=locations.elemental, - category=ResultCategory.scalar, - components=None, - norm=False, - selection=selection, - times=times, - set_ids=set_ids, - all_sets=all_sets, - node_ids=None, - face_ids=None, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + integrated=True, + native_location=result_info.native_location, ) def mass_fraction( @@ -2623,6 +2654,7 @@ def mass_fraction( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract mass fraction results from the simulation. @@ -2665,15 +2697,23 @@ def mass_fraction( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_fraction") return self._get_result( - base_name="Y", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -2689,6 +2729,7 @@ def mass_fraction( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mass_fraction_on_nodes( @@ -2753,8 +2794,9 @@ def mass_fraction_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_fraction") return self._get_result( - base_name="Y", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -2771,12 +2813,13 @@ def mass_fraction_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mass_fraction_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -2793,7 +2836,7 @@ def mass_fraction_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -2803,8 +2846,6 @@ def mass_fraction_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -2832,8 +2873,9 @@ def mass_fraction_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_fraction") return self._get_result( - base_name="Y", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -2844,12 +2886,13 @@ def mass_fraction_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mass_fraction_on_cells( @@ -2908,8 +2951,9 @@ def mass_fraction_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mass_fraction") return self._get_result( - base_name="Y", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -2926,6 +2970,7 @@ def mass_fraction_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_static_pressure( @@ -2942,6 +2987,7 @@ def mean_static_pressure( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract mean static pressure results from the simulation. @@ -2984,15 +3030,23 @@ def mean_static_pressure( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_static_pressure") return self._get_result( - base_name="P_SA", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -3008,6 +3062,7 @@ def mean_static_pressure( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_static_pressure_on_nodes( @@ -3025,7 +3080,7 @@ def mean_static_pressure_on_nodes( named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, ) -> DataFrame: - """Extract mean static pressure results from the simulation. + """Extract mean static pressure results on nodes from the simulation. Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. @@ -3072,8 +3127,9 @@ def mean_static_pressure_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_static_pressure") return self._get_result( - base_name="P_SA", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -3090,12 +3146,13 @@ def mean_static_pressure_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_static_pressure_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -3112,7 +3169,7 @@ def mean_static_pressure_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -3122,8 +3179,6 @@ def mean_static_pressure_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -3151,8 +3206,9 @@ def mean_static_pressure_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_static_pressure") return self._get_result( - base_name="P_SA", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -3163,12 +3219,13 @@ def mean_static_pressure_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_static_pressure_on_cells( @@ -3227,8 +3284,9 @@ def mean_static_pressure_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_static_pressure") return self._get_result( - base_name="P_SA", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -3245,6 +3303,7 @@ def mean_static_pressure_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_temperature( @@ -3261,6 +3320,7 @@ def mean_temperature( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract mean temperature results from the simulation. @@ -3303,15 +3363,23 @@ def mean_temperature( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_temperature") return self._get_result( - base_name="TEMP_A", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -3327,6 +3395,7 @@ def mean_temperature( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_temperature_on_nodes( @@ -3391,8 +3460,9 @@ def mean_temperature_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_temperature") return self._get_result( - base_name="TEMP_A", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -3409,12 +3479,13 @@ def mean_temperature_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_temperature_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -3431,7 +3502,7 @@ def mean_temperature_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -3441,8 +3512,6 @@ def mean_temperature_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -3470,8 +3539,9 @@ def mean_temperature_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_temperature") return self._get_result( - base_name="TEMP_A", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -3482,12 +3552,13 @@ def mean_temperature_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_temperature_on_cells( @@ -3546,8 +3617,9 @@ def mean_temperature_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_temperature") return self._get_result( - base_name="TEMP_A", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -3564,6 +3636,7 @@ def mean_temperature_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_velocity( @@ -3582,6 +3655,7 @@ def mean_velocity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract mean velocity results from the simulation. @@ -3629,15 +3703,23 @@ def mean_velocity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_velocity") return self._get_result( - base_name="V_A", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.vector, components=components, norm=norm, @@ -3653,6 +3735,7 @@ def mean_velocity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_velocity_on_nodes( @@ -3724,9 +3807,10 @@ def mean_velocity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_velocity") return self._get_result( - base_name="V_A", - location=None, + base_name=result_info.operator_name, + location=locations.nodal, category=ResultCategory.vector, components=components, norm=norm, @@ -3742,12 +3826,13 @@ def mean_velocity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_velocity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -3766,7 +3851,7 @@ def mean_velocity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -3776,8 +3861,6 @@ def mean_velocity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -3810,8 +3893,9 @@ def mean_velocity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_velocity") return self._get_result( - base_name="V_A", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.vector, components=components, @@ -3822,12 +3906,13 @@ def mean_velocity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def mean_velocity_on_cells( @@ -3893,8 +3978,9 @@ def mean_velocity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("mean_velocity") return self._get_result( - base_name="V_A", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.vector, components=components, @@ -3911,6 +3997,7 @@ def mean_velocity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def omega( @@ -3927,6 +4014,7 @@ def omega( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract omega results from the simulation. @@ -3969,15 +4057,23 @@ def omega( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("omega") return self._get_result( - base_name="OME", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -3993,6 +4089,7 @@ def omega( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def omega_on_nodes( @@ -4057,8 +4154,9 @@ def omega_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("omega") return self._get_result( - base_name="OME", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -4075,12 +4173,13 @@ def omega_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def omega_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -4097,7 +4196,7 @@ def omega_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -4107,8 +4206,6 @@ def omega_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -4136,8 +4233,9 @@ def omega_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("omega") return self._get_result( - base_name="OME", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -4148,12 +4246,13 @@ def omega_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def omega_on_cells( @@ -4212,8 +4311,9 @@ def omega_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("omega") return self._get_result( - base_name="OME", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -4230,6 +4330,7 @@ def omega_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_static_pressure( @@ -4246,6 +4347,7 @@ def rms_static_pressure( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract RMS static pressure results from the simulation. @@ -4288,15 +4390,23 @@ def rms_static_pressure( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_static_pressure") return self._get_result( - base_name="P_SRMS", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -4312,6 +4422,7 @@ def rms_static_pressure( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_static_pressure_on_nodes( @@ -4376,8 +4487,9 @@ def rms_static_pressure_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_static_pressure") return self._get_result( - base_name="P_SRMS", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -4394,12 +4506,13 @@ def rms_static_pressure_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_static_pressure_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -4416,7 +4529,7 @@ def rms_static_pressure_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -4426,8 +4539,6 @@ def rms_static_pressure_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -4455,8 +4566,9 @@ def rms_static_pressure_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_static_pressure") return self._get_result( - base_name="P_SRMS", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -4467,12 +4579,13 @@ def rms_static_pressure_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_static_pressure_on_cells( @@ -4531,8 +4644,9 @@ def rms_static_pressure_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_static_pressure") return self._get_result( - base_name="P_SRMS", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -4549,6 +4663,7 @@ def rms_static_pressure_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_temperature( @@ -4565,6 +4680,7 @@ def rms_temperature( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract RMS temperature results from the simulation. @@ -4607,15 +4723,23 @@ def rms_temperature( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_temperature") return self._get_result( - base_name="TEMP_RMS", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -4631,6 +4755,7 @@ def rms_temperature( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_temperature_on_nodes( @@ -4695,8 +4820,9 @@ def rms_temperature_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_temperature") return self._get_result( - base_name="TEMP_RMS", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -4713,12 +4839,13 @@ def rms_temperature_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_temperature_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -4735,7 +4862,7 @@ def rms_temperature_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -4745,8 +4872,6 @@ def rms_temperature_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -4774,8 +4899,9 @@ def rms_temperature_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_temperature") return self._get_result( - base_name="TEMP_RMS", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -4786,12 +4912,13 @@ def rms_temperature_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_temperature_on_cells( @@ -4850,8 +4977,9 @@ def rms_temperature_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_temperature") return self._get_result( - base_name="TEMP_RMS", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -4868,6 +4996,7 @@ def rms_temperature_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_velocity( @@ -4886,6 +5015,7 @@ def rms_velocity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract RMS velocity results from the simulation. @@ -4933,15 +5063,23 @@ def rms_velocity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_velocity") return self._get_result( - base_name="V_RMS", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.vector, components=components, norm=norm, @@ -4957,6 +5095,7 @@ def rms_velocity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_velocity_on_nodes( @@ -5028,8 +5167,9 @@ def rms_velocity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_velocity") return self._get_result( - base_name="V_RMS", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.vector, components=components, @@ -5046,12 +5186,13 @@ def rms_velocity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_velocity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -5070,7 +5211,7 @@ def rms_velocity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -5080,8 +5221,6 @@ def rms_velocity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -5114,8 +5253,9 @@ def rms_velocity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_velocity") return self._get_result( - base_name="V_RMS", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.vector, components=components, @@ -5126,12 +5266,13 @@ def rms_velocity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def rms_velocity_on_cells( @@ -5197,8 +5338,9 @@ def rms_velocity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("rms_velocity") return self._get_result( - base_name="V_RMS", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.vector, components=components, @@ -5215,6 +5357,7 @@ def rms_velocity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def specific_heat( @@ -5231,6 +5374,7 @@ def specific_heat( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract specific heat results from the simulation. @@ -5273,15 +5417,23 @@ def specific_heat( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("specific_heat") return self._get_result( - base_name="CP", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -5297,6 +5449,7 @@ def specific_heat( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def specific_heat_on_nodes( @@ -5361,8 +5514,9 @@ def specific_heat_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("specific_heat") return self._get_result( - base_name="CP", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -5379,12 +5533,13 @@ def specific_heat_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def specific_heat_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -5401,7 +5556,7 @@ def specific_heat_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -5411,8 +5566,6 @@ def specific_heat_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -5440,8 +5593,9 @@ def specific_heat_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("specific_heat") return self._get_result( - base_name="CP", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -5452,12 +5606,13 @@ def specific_heat_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def specific_heat_on_cells( @@ -5516,8 +5671,9 @@ def specific_heat_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("specific_heat") return self._get_result( - base_name="CP", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -5534,6 +5690,7 @@ def specific_heat_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def static_pressure( @@ -5550,6 +5707,7 @@ def static_pressure( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract static pressure results from the simulation. @@ -5592,15 +5750,23 @@ def static_pressure( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("static_pressure") return self._get_result( - base_name="P_S", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -5616,6 +5782,7 @@ def static_pressure( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def static_pressure_on_nodes( @@ -5680,8 +5847,9 @@ def static_pressure_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("static_pressure") return self._get_result( - base_name="P_S", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -5698,12 +5866,13 @@ def static_pressure_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def static_pressure_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -5720,7 +5889,7 @@ def static_pressure_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -5730,8 +5899,6 @@ def static_pressure_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -5759,8 +5926,9 @@ def static_pressure_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("static_pressure") return self._get_result( - base_name="P_S", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -5771,12 +5939,13 @@ def static_pressure_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def static_pressure_on_cells( @@ -5835,8 +6004,9 @@ def static_pressure_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("static_pressure") return self._get_result( - base_name="P_S", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -5853,6 +6023,7 @@ def static_pressure_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def superficial_velocity( @@ -5871,6 +6042,7 @@ def superficial_velocity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract superficial velocity results from the simulation. @@ -5918,15 +6090,23 @@ def superficial_velocity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("superficial_velocity") return self._get_result( - base_name="V_SUP", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.vector, components=components, norm=norm, @@ -5942,6 +6122,7 @@ def superficial_velocity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def superficial_velocity_on_nodes( @@ -6013,8 +6194,9 @@ def superficial_velocity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("superficial_velocity") return self._get_result( - base_name="V_SUP", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.vector, components=components, @@ -6031,12 +6213,13 @@ def superficial_velocity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def superficial_velocity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -6055,7 +6238,7 @@ def superficial_velocity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -6065,8 +6248,6 @@ def superficial_velocity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -6099,8 +6280,9 @@ def superficial_velocity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("superficial_velocity") return self._get_result( - base_name="V_SUP", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.vector, components=components, @@ -6111,12 +6293,13 @@ def superficial_velocity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def superficial_velocity_on_cells( @@ -6182,8 +6365,9 @@ def superficial_velocity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("superficial_velocity") return self._get_result( - base_name="V_SUP", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.vector, components=components, @@ -6200,13 +6384,13 @@ def superficial_velocity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def surface_heat_rate( self, - node_ids: Union[List[int], None] = None, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -6217,13 +6401,16 @@ def surface_heat_rate( named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, ) -> DataFrame: - """Extract surface heat rate results from the simulation. + """Extract surface heat rate results on faces from the simulation. + + .. note:: + This is an integrated result only available on faces. Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, `face_ids`, and `node_ids` + Arguments `selection`, `named_selections`, `face_ids`, and `node_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -6231,12 +6418,8 @@ def surface_heat_rate( Parameters ---------- - node_ids: - List of IDs of nodes to get results for. face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -6264,8 +6447,9 @@ def surface_heat_rate( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("surface_heat_rate") return self._get_result( - base_name="Q", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -6274,102 +6458,22 @@ def surface_heat_rate( times=times, set_ids=set_ids, all_sets=all_sets, - node_ids=node_ids, - face_ids=face_ids, - cell_ids=cell_ids, - zone_ids=zone_ids, - qualifiers=qualifiers, - phases=phases, - species=species, - named_selections=named_selections, - ) - - def surface_heat_rate_on_nodes( - self, - node_ids: Union[List[int], None] = None, - face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, - zone_ids: Union[List[int], None] = None, - phases: Union[List[Union[int, str]], None] = None, - species: Union[List[int], None] = None, - qualifiers: Union[dict, None] = None, - times: Union[float, List[float], None] = None, - set_ids: Union[int, List[int], None] = None, - all_sets: bool = False, - named_selections: Union[List[str], str, None] = None, - selection: Union[Selection, None] = None, - ) -> DataFrame: - """Extract surface heat rate results on nodes from the simulation. - - Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually - exclusive. - If none of the above is given, only the last result will be returned. - - Arguments `selection`, `named_selections`, `cell_ids`, `face_ids`, and `node_ids` - are mutually exclusive. - If none of the above is given, results will be extracted for the whole mesh. - - Argument `qualifiers` overrides arguments `zones_ids`, `phases`, and `species`. - - Parameters - ---------- - node_ids: - List of IDs of nodes to get results for. - face_ids: - List of IDs of faces which nodes to get results for. - cell_ids: - List of IDs of cells which nodes to get results for. - zone_ids: - List of IDs of zones to get results for. - phases: - List of IDs of phases to get results for. - species: - List of IDs of species to get results for. - qualifiers: - Dictionary of qualifier labels with associated values to get results for. - Overrides any other qualifier argument such as `phases`, `species` or `zone_ids`. - times: - List of time values to get results for. - set_ids: - Sets to get results for. - A set is defined as a unique combination of {time, load step, sub-step}. - all_sets: - Whether to get results for all sets. - named_selections: - Named selection or list of named selections to get results for. - selection: - Selection to get results for. - A Selection defines both spatial and time-like criteria for filtering. - - Returns - ------- - Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. - - """ - return self._get_result( - base_name="Q", - location=locations.nodal, - category=ResultCategory.scalar, - components=None, - norm=False, - selection=selection, - times=times, - set_ids=set_ids, - all_sets=all_sets, - node_ids=node_ids, + node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + integrated=True, + native_location=result_info.native_location, ) def surface_heat_rate_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -6382,11 +6486,14 @@ def surface_heat_rate_on_faces( ) -> DataFrame: """Extract surface heat rate results on faces from the simulation. + .. note:: + This is an integrated result only available on faces. + Arguments `selection`, `set_ids`, `all_sets`, and `times` are mutually exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -6396,8 +6503,6 @@ def surface_heat_rate_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -6425,8 +6530,9 @@ def surface_heat_rate_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("surface_heat_rate") return self._get_result( - base_name="Q", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -6437,12 +6543,14 @@ def surface_heat_rate_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + integrated=True, + native_location=result_info.native_location, ) def temperature( @@ -6459,6 +6567,7 @@ def temperature( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract temperature results from the simulation. @@ -6501,15 +6610,23 @@ def temperature( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("temperature") return self._get_result( - base_name="TEMP", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -6525,6 +6642,7 @@ def temperature( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def temperature_on_nodes( @@ -6589,8 +6707,9 @@ def temperature_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("temperature") return self._get_result( - base_name="TEMP", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -6607,12 +6726,13 @@ def temperature_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def temperature_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -6629,7 +6749,7 @@ def temperature_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -6639,8 +6759,6 @@ def temperature_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -6668,8 +6786,9 @@ def temperature_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("temperature") return self._get_result( - base_name="TEMP", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -6680,12 +6799,13 @@ def temperature_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def temperature_on_cells( @@ -6744,8 +6864,9 @@ def temperature_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("temperature") return self._get_result( - base_name="TEMP", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -6762,6 +6883,7 @@ def temperature_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def thermal_conductivity( @@ -6778,6 +6900,7 @@ def thermal_conductivity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract thermal conductivity results from the simulation. @@ -6820,15 +6943,23 @@ def thermal_conductivity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("thermal_conductivity") return self._get_result( - base_name="KT", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -6844,6 +6975,7 @@ def thermal_conductivity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def thermal_conductivity_on_nodes( @@ -6908,8 +7040,9 @@ def thermal_conductivity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("thermal_conductivity") return self._get_result( - base_name="KT", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -6926,12 +7059,13 @@ def thermal_conductivity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def thermal_conductivity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -6948,7 +7082,7 @@ def thermal_conductivity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -6958,8 +7092,6 @@ def thermal_conductivity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -6987,8 +7119,9 @@ def thermal_conductivity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("thermal_conductivity") return self._get_result( - base_name="KT", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -6999,12 +7132,13 @@ def thermal_conductivity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def thermal_conductivity_on_cells( @@ -7063,8 +7197,9 @@ def thermal_conductivity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("thermal_conductivity") return self._get_result( - base_name="KT", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -7081,6 +7216,7 @@ def thermal_conductivity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_pressure( @@ -7097,6 +7233,7 @@ def total_pressure( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract total pressure results from the simulation. @@ -7139,15 +7276,23 @@ def total_pressure( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_pressure") return self._get_result( - base_name="P_TOT", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -7163,6 +7308,7 @@ def total_pressure( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_pressure_on_nodes( @@ -7227,8 +7373,9 @@ def total_pressure_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_pressure") return self._get_result( - base_name="P_TOT", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -7245,12 +7392,13 @@ def total_pressure_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_pressure_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -7267,7 +7415,7 @@ def total_pressure_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -7277,8 +7425,6 @@ def total_pressure_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -7306,8 +7452,9 @@ def total_pressure_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_pressure") return self._get_result( - base_name="P_TOT", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -7318,12 +7465,13 @@ def total_pressure_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_pressure_on_cells( @@ -7382,8 +7530,9 @@ def total_pressure_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_pressure") return self._get_result( - base_name="P_TOT", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -7400,6 +7549,7 @@ def total_pressure_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_temperature( @@ -7416,6 +7566,7 @@ def total_temperature( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract total temperature results from the simulation. @@ -7458,15 +7609,23 @@ def total_temperature( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_temperature") return self._get_result( - base_name="TEMP_TOT", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -7482,6 +7641,7 @@ def total_temperature( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_temperature_on_nodes( @@ -7546,8 +7706,9 @@ def total_temperature_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_temperature") return self._get_result( - base_name="TEMP_TOT", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -7564,12 +7725,13 @@ def total_temperature_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_temperature_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -7586,7 +7748,7 @@ def total_temperature_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -7596,8 +7758,6 @@ def total_temperature_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -7625,8 +7785,9 @@ def total_temperature_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_temperature") return self._get_result( - base_name="TEMP_TOT", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -7637,12 +7798,13 @@ def total_temperature_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def total_temperature_on_cells( @@ -7701,8 +7863,9 @@ def total_temperature_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("total_temperature") return self._get_result( - base_name="TEMP_TOT", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -7719,6 +7882,7 @@ def total_temperature_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def turbulent_kinetic_energy( @@ -7735,6 +7899,7 @@ def turbulent_kinetic_energy( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract turbulent kinetic energy results from the simulation. @@ -7777,15 +7942,23 @@ def turbulent_kinetic_energy( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_kinetic_energy") return self._get_result( - base_name="K", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -7801,6 +7974,9 @@ def turbulent_kinetic_energy( phases=phases, species=species, named_selections=named_selections, + native_location=self.result_info[ + "turbulent_kinetic_energy" + ].native_location, ) def turbulent_kinetic_energy_on_nodes( @@ -7865,8 +8041,9 @@ def turbulent_kinetic_energy_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_kinetic_energy") return self._get_result( - base_name="K", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -7883,12 +8060,15 @@ def turbulent_kinetic_energy_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=self.result_info[ + "turbulent_kinetic_energy" + ].native_location, ) def turbulent_kinetic_energy_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -7905,7 +8085,7 @@ def turbulent_kinetic_energy_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -7915,8 +8095,6 @@ def turbulent_kinetic_energy_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -7944,8 +8122,9 @@ def turbulent_kinetic_energy_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_kinetic_energy") return self._get_result( - base_name="K", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -7956,12 +8135,15 @@ def turbulent_kinetic_energy_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=self.result_info[ + "turbulent_kinetic_energy" + ].native_location, ) def turbulent_kinetic_energy_on_cells( @@ -8020,8 +8202,9 @@ def turbulent_kinetic_energy_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_kinetic_energy") return self._get_result( - base_name="K", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -8038,6 +8221,9 @@ def turbulent_kinetic_energy_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=self.result_info[ + "turbulent_kinetic_energy" + ].native_location, ) def turbulent_viscosity( @@ -8054,6 +8240,7 @@ def turbulent_viscosity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract turbulent viscosity results from the simulation. @@ -8096,15 +8283,23 @@ def turbulent_viscosity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_viscosity") return self._get_result( - base_name="MUT", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -8120,6 +8315,7 @@ def turbulent_viscosity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def turbulent_viscosity_on_nodes( @@ -8184,8 +8380,9 @@ def turbulent_viscosity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_viscosity") return self._get_result( - base_name="MUT", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -8202,12 +8399,13 @@ def turbulent_viscosity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def turbulent_viscosity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -8224,7 +8422,7 @@ def turbulent_viscosity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -8234,8 +8432,6 @@ def turbulent_viscosity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -8263,8 +8459,9 @@ def turbulent_viscosity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_viscosity") return self._get_result( - base_name="MUT", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -8275,12 +8472,13 @@ def turbulent_viscosity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def turbulent_viscosity_on_cells( @@ -8339,8 +8537,9 @@ def turbulent_viscosity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("turbulent_viscosity") return self._get_result( - base_name="MUT", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -8357,6 +8556,7 @@ def turbulent_viscosity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def velocity( @@ -8375,6 +8575,7 @@ def velocity( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract velocity results from the simulation. @@ -8422,15 +8623,23 @@ def velocity( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("velocity") return self._get_result( - base_name="V", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.vector, components=components, norm=norm, @@ -8446,6 +8655,7 @@ def velocity( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def velocity_on_nodes( @@ -8517,8 +8727,9 @@ def velocity_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("velocity") return self._get_result( - base_name="V", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.vector, components=components, @@ -8535,12 +8746,13 @@ def velocity_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def velocity_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -8559,7 +8771,7 @@ def velocity_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -8569,8 +8781,6 @@ def velocity_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -8603,8 +8813,9 @@ def velocity_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("velocity") return self._get_result( - base_name="V", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.vector, components=components, @@ -8615,12 +8826,13 @@ def velocity_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def velocity_on_cells( @@ -8686,8 +8898,9 @@ def velocity_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("velocity") return self._get_result( - base_name="V", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.vector, components=components, @@ -8704,6 +8917,7 @@ def velocity_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def volume_fraction( @@ -8720,6 +8934,7 @@ def volume_fraction( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract volume fraction results from the simulation. @@ -8762,15 +8977,23 @@ def volume_fraction( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("volume_fraction") return self._get_result( - base_name="VOF", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -8786,6 +9009,7 @@ def volume_fraction( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def volume_fraction_on_nodes( @@ -8850,8 +9074,9 @@ def volume_fraction_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("volume_fraction") return self._get_result( - base_name="VOF", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -8868,12 +9093,13 @@ def volume_fraction_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def volume_fraction_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -8890,7 +9116,7 @@ def volume_fraction_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -8900,8 +9126,6 @@ def volume_fraction_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -8929,8 +9153,9 @@ def volume_fraction_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("volume_fraction") return self._get_result( - base_name="VOF", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -8941,12 +9166,13 @@ def volume_fraction_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def volume_fraction_on_cells( @@ -9005,8 +9231,9 @@ def volume_fraction_on_cells( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("volume_fraction") return self._get_result( - base_name="VOF", + base_name=result_info.operator_name, location=locations.elemental, category=ResultCategory.scalar, components=None, @@ -9023,6 +9250,7 @@ def volume_fraction_on_cells( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def wall_shear_stress( @@ -9041,6 +9269,7 @@ def wall_shear_stress( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract wall shear stress results from the simulation. @@ -9088,15 +9317,23 @@ def wall_shear_stress( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("wall_shear_stress") return self._get_result( - base_name="TAU", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.vector, components=components, norm=norm, @@ -9112,6 +9349,7 @@ def wall_shear_stress( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def wall_shear_stress_on_nodes( @@ -9183,8 +9421,9 @@ def wall_shear_stress_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("wall_shear_stress") return self._get_result( - base_name="TAU", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.vector, components=components, @@ -9201,12 +9440,13 @@ def wall_shear_stress_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def wall_shear_stress_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -9225,7 +9465,7 @@ def wall_shear_stress_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -9235,8 +9475,6 @@ def wall_shear_stress_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -9269,8 +9507,9 @@ def wall_shear_stress_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("wall_shear_stress") return self._get_result( - base_name="TAU", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.vector, components=components, @@ -9281,12 +9520,13 @@ def wall_shear_stress_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def y_plus( @@ -9303,6 +9543,7 @@ def y_plus( all_sets: bool = False, named_selections: Union[List[str], str, None] = None, selection: Union[Selection, None] = None, + location: Union[locations, str, None] = None, ) -> DataFrame: """Extract y+ results from the simulation. @@ -9345,15 +9586,23 @@ def y_plus( selection: Selection to get results for. A Selection defines both spatial and time-like criteria for filtering. + location: + Location to extract results at. Available locations are listed in + class:`post.locations` and are: `post.locations.nodal`, + `post.locations.elemental`, and `post.locations.faces`. + If no location is given, the result is returned as it is stored in the result file. + Using `post.locations.elemental` gives results with one value for each cell, + while using `post.locations.nodal` gives results with one value for each node. Returns ------- Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("y_plus") return self._get_result( - base_name="YPLUS", - location=None, + base_name=result_info.operator_name, + location=location, category=ResultCategory.scalar, components=None, norm=False, @@ -9369,6 +9618,7 @@ def y_plus( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def y_plus_on_nodes( @@ -9433,8 +9683,9 @@ def y_plus_on_nodes( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("y_plus") return self._get_result( - base_name="YPLUS", + base_name=result_info.operator_name, location=locations.nodal, category=ResultCategory.scalar, components=None, @@ -9451,12 +9702,13 @@ def y_plus_on_nodes( phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) def y_plus_on_faces( self, face_ids: Union[List[int], None] = None, - cell_ids: Union[List[int], None] = None, + # cell_ids: Union[List[int], None] = None, zone_ids: Union[List[int], None] = None, phases: Union[List[Union[int, str]], None] = None, species: Union[List[int], None] = None, @@ -9473,7 +9725,7 @@ def y_plus_on_faces( exclusive. If none of the above is given, only the last result will be returned. - Arguments `selection`, `named_selections`, `cell_ids`, and `face_ids` + Arguments `selection`, `named_selections`, and `face_ids` are mutually exclusive. If none of the above is given, results will be extracted for the whole mesh. @@ -9483,8 +9735,6 @@ def y_plus_on_faces( ---------- face_ids: List of IDs of faces to get results for. - cell_ids: - List of IDs of cells which faces to get results for. zone_ids: List of IDs of zones to get results for. phases: @@ -9512,8 +9762,9 @@ def y_plus_on_faces( Returns a :class:`ansys.dpf.post.data_object.DataFrame` instance. """ + result_info = self._try_get_result_info("y_plus") return self._get_result( - base_name="YPLUS", + base_name=result_info.operator_name, location=locations.faces, category=ResultCategory.scalar, components=None, @@ -9524,10 +9775,11 @@ def y_plus_on_faces( all_sets=all_sets, node_ids=None, face_ids=face_ids, - cell_ids=cell_ids, + # cell_ids=cell_ids, zone_ids=zone_ids, qualifiers=qualifiers, phases=phases, species=species, named_selections=named_selections, + native_location=result_info.native_location, ) diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index 4e53a2d92..87965a18f 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -18,6 +18,7 @@ from ansys.dpf.post import index, locations from ansys.dpf.post.connectivity import ConnectivityListByIndex, ReturnMode from ansys.dpf.post.elements import Element, ElementListByIndex +from ansys.dpf.post.faces import FaceListByIndex from ansys.dpf.post.named_selection import NamedSelections from ansys.dpf.post.nodes import NodeListByIndex @@ -97,7 +98,7 @@ def element_ids(self) -> List[int]: @property def num_elements(self) -> int: - """Returns the number of element in the mesh. + """Returns the number of elements in the mesh. Examples -------- @@ -142,6 +143,55 @@ def get_element_by_id( """ return self.elements.by_id[id] + @property + def num_faces(self) -> int: + """Returns the number of faces in the mesh. + + Examples + -------- + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> print(simulation.mesh.num_faces) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + 44242 + """ + return self._meshed_region.faces.n_faces + + @property + def face_ids(self) -> List[int]: + """Returns the list of face IDs in the mesh. + + Examples + -------- + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> print(simulation.mesh.face_ids) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + [ 1003 1004 1005 ... 45165 45166 45167] + """ + return self._meshed_region.faces.scoping.ids + + @property + def faces(self) -> FaceListByIndex: + """Returns a list of faces indexed by ID. + + Examples + -------- + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> print(simulation.mesh.faces) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + [quad4, ..., quad4] + """ + return FaceListByIndex(self._meshed_region.faces) + + def get_face_by_id(self, id: int) -> Face: # pylint: disable=redefined-builtin + """Returns a face in the mesh from a given ID.""" + return self.faces.by_id[id] + @property def nodes(self) -> NodeListByIndex: """Returns a list of nodes indexed by ID. @@ -248,7 +298,7 @@ def materials(self) -> post.DataFrame: ) @property - def element_to_node_ids_connectivity(self): + def element_to_node_ids_connectivity(self) -> ConnectivityListByIndex: """Returns a connectivity map between element index and node IDs. To get the connectivity map by element ID, use the 'by_id' property of the object returned. @@ -272,7 +322,7 @@ def element_to_node_ids_connectivity(self): ) @property - def node_to_element_ids_connectivity(self): + def node_to_element_ids_connectivity(self) -> ConnectivityListByIndex: """Returns a connectivity map between node index and element IDs. To get the connectivity map by node ID, use the 'by_id' property of the object returned. @@ -296,7 +346,7 @@ def node_to_element_ids_connectivity(self): ) @property - def element_to_node_connectivity(self): + def element_to_node_connectivity(self) -> ConnectivityListByIndex: """Returns a connectivity map between element index and node indexes. To get the connectivity map by element ID, use the 'by_id' property of the object returned. @@ -320,7 +370,7 @@ def element_to_node_connectivity(self): ) @property - def node_to_element_connectivity(self): + def node_to_element_connectivity(self) -> ConnectivityListByIndex: """Returns a connectivity map between node index and element indexes. To get the connectivity map by node ID, use the 'by_id' property of the object returned. @@ -343,6 +393,30 @@ def node_to_element_connectivity(self): field=conn_field, mode=ReturnMode.IDX, scoping=elems_scoping ) + @property + def face_to_node_ids_connectivity(self) -> ConnectivityListByIndex: + """Returns a connectivity map between face index and node IDs. + + To get the connectivity map by face ID, use the 'by_id' property of the object returned. + """ + conn_field = self._meshed_region.faces.faces_nodes_connectivity_field + nodes_scoping = self._meshed_region.nodes.scoping + return ConnectivityListByIndex( + field=conn_field, mode=ReturnMode.IDS, scoping=nodes_scoping + ) + + @property + def face_to_node_connectivity(self) -> ConnectivityListByIndex: + """Returns a connectivity map between face index and node indexes. + + To get the connectivity map by face ID, use the 'by_id' property of the object returned. + """ + conn_field = self._meshed_region.faces.faces_nodes_connectivity_field + nodes_scoping = self._meshed_region.nodes.scoping + return ConnectivityListByIndex( + field=conn_field, mode=ReturnMode.IDX, scoping=nodes_scoping + ) + @property def unit(self) -> str: """Returns the unit of the mesh (same as coordinates of the mesh). diff --git a/src/ansys/dpf/post/mesh_info.py b/src/ansys/dpf/post/mesh_info.py new file mode 100644 index 000000000..8ce9e90e0 --- /dev/null +++ b/src/ansys/dpf/post/mesh_info.py @@ -0,0 +1,197 @@ +"""Module containing the ``FluidMeshInfo`` class. + +FluidMeshInfo +------------- + +""" +from ansys.dpf import core as dpf + + +class FluidMeshInfo: + """Holds the metadata relative to a fluid mesh. + + This class describes the available mesh information. + Use this to gather information about a large mesh prior to loading it + to define requests on limited parts of the mesh for improved performance. + + Parameters + ---------- + core_mesh_info : + Hold the information of the mesh region into a generic data container. + + Examples + -------- + Explore the mesh info from the model + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + Fluid mesh metadata + ------------------- + Number of nodes: 16660 + Number of faces: 45391 + Number of cells: 13856 + Cell zones: + {13: 'fluid-rotor', 28: 'fluid-stator'} + Face zones: + {2: 'default-interior:0',..., 27: 'stator-per-1-shadow'} + Cell to face zones: + {13: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],...} + """ + + def __init__(self, core_mesh_info: dpf.MeshInfo): + """Initialize this class.""" + self._core_object = core_mesh_info + self._face_zones = None + self._cell_zones = None + self._cell_zones_to_face_zones = None + + def __str__(self) -> str: + """String representation of this class.""" + txt = "Fluid mesh metadata\n" + txt += "-" * (len(txt) - 1) + "\n" + txt += f"Number of nodes: {self.num_nodes}\n" + txt += f"Number of faces: {self.num_faces}\n" + txt += f"Number of cells: {self.num_cells}\n" + txt += f"Cell zones:\n" + txt += f"\t{self.cell_zones}\n" + txt += f"Face zones:\n" + txt += f"\t{self.face_zones}\n" + txt += f"Cell to face zones:\n" + txt += f"\t{self.cell_zones_to_face_zones}\n" + return txt + + @property + def num_nodes(self) -> int: + """Returns the number of nodes in the mesh. + + Examples + -------- + Get the number of nodes in the mesh + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.num_nodes) + 16660 + """ + return self._core_object.number_nodes + + @property + def num_faces(self) -> int: + """Returns the number of faces in the mesh. + + Examples + -------- + Get the number of faces in the mesh + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.num_faces) + 45391 + """ + return self._core_object.number_faces + + @property + def num_cells(self) -> int: + """Returns the number of cells in the mesh. + + Examples + -------- + Get the number of cells in the mesh + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.num_cells) + 13856 + """ + return self._core_object.number_elements + + @property + def face_zones(self) -> dict: + """Returns a dictionary of face zones in the mesh. + + Examples + -------- + Get information on the face zones available in the mesh + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.face_zones) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + {2: 'default-interior:0', 3: 'rotor-hub', ...26: 'stator-per-1', 27: 'stator-per-1-shadow'} + """ + if not self._face_zones: + zones = {} + string_field = self._core_object.get_property("face_zone_names") + for zone_id in string_field.scoping.ids: + zone_name = string_field.get_entity_data_by_id(zone_id)[0] + zones[zone_id] = zone_name + self._face_zones = zones + return self._face_zones + + @property + def cell_zones(self) -> dict: + """Returns a dictionary of cell zones (bodies) in the mesh. + + Examples + -------- + Get information on the cell zones available in the mesh + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.cell_zones) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + {13: 'fluid-rotor', 28: 'fluid-stator'} + """ + if not self._cell_zones: + zones = {} + string_field = self._core_object.body_names + for zone_id in string_field.scoping.ids: + zone_name = string_field.get_entity_data_by_id(zone_id)[0] + zones[zone_id] = zone_name + self._cell_zones = zones + return self._cell_zones + + @property + def cell_zones_to_face_zones(self) -> dict: + """Returns a map between cell zone (body) IDs and their associated face zone IDs. + + Examples + -------- + Get the mapping between cell zone IDs and face zone IDs + + >>> from ansys.dpf import post + >>> from ansys.dpf.post import examples + >>> files = examples.download_fluent_axial_comp() + >>> simulation = post.FluidSimulation(cas=files['cas'][0], dat=files['dat'][0]) + >>> mesh_info = simulation.mesh_info + >>> print(mesh_info.cell_zones_to_face_zones) # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS + {13: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], + 28: [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]} + """ + if not self._cell_zones_to_face_zones: + result = {} + property_field = self._core_object.get_property("body_face_topology") + for cell_zone_id in property_field.scoping.ids: + face_zone_ids = property_field.get_entity_data_by_id( + cell_zone_id + ).tolist() + result[cell_zone_id] = face_zone_ids + self._cell_zones_to_face_zones = result + return self._cell_zones_to_face_zones diff --git a/src/ansys/dpf/post/selection.py b/src/ansys/dpf/post/selection.py index 6308ee418..e2cad3f45 100644 --- a/src/ansys/dpf/post/selection.py +++ b/src/ansys/dpf/post/selection.py @@ -249,16 +249,16 @@ def select_named_selection( self._selection.set_input_name( _WfNames.data_sources, op.inputs.data_sources ) - self._selection.set_input_name( - _WfNames.streams, op.inputs.streams_container - ) + # self._selection.set_input_name( + # _WfNames.streams, op.inputs.streams_container + # ) self._selection.set_output_name(_WfNames.scoping, op.outputs.mesh_scoping) else: op = operators.utility.merge_scopings(server=self._server) forward_ds = operators.utility.forward(any=None, server=self._server) forward_sc = operators.utility.forward(any=None, server=self._server) self._selection.set_input_name(_WfNames.data_sources, forward_ds.inputs.any) - self._selection.set_input_name(_WfNames.streams, forward_sc.inputs.any) + # self._selection.set_input_name(_WfNames.streams, forward_sc.inputs.any) for pin, ns in enumerate(named_selection): mesh_scoping_op = operators.scoping.on_named_selection( requested_location=location, @@ -533,13 +533,92 @@ def select_nodes_of_elements( ) op = operators.scoping.transpose( - mesh_scoping=scoping, meshed_region=mesh._meshed_region, inclusive=0 + mesh_scoping=scoping, + meshed_region=mesh._meshed_region, + inclusive=0, + requested_location=locations.nodal, + ) + self._selection.add_operator(op) + self._selection.set_output_name( + _WfNames.scoping, op.outputs.mesh_scoping_as_scoping + ) + + def select_nodes_of_faces( + self, + faces: Union[List[int], Scoping], + mesh: Mesh, + ) -> None: + """Select all nodes of faces using the faces' IDs or a faces mesh scoping. + + Parameters + ---------- + faces: + face IDs or faces mesh scoping. + mesh: + Mesh containing the necessary connectivity. + """ + if isinstance(faces, Scoping): + scoping = faces + else: + scoping = Scoping(location=locations.faces, ids=faces, server=self._server) + + op = operators.scoping.transpose( + mesh_scoping=scoping, + meshed_region=mesh._meshed_region, + inclusive=0, + requested_location=locations.nodal, + ) + self._selection.add_operator(op) + self._selection.set_output_name( + _WfNames.scoping, op.outputs.mesh_scoping_as_scoping + ) + + def select_faces_of_elements( + self, + elements: Union[List[int], Scoping], + mesh: Mesh, + ) -> None: + """Select all faces of elements using the elements' IDs or an elemental mesh scoping. + + Parameters + ---------- + elements: + element IDs or elemental mesh scoping. + mesh: + Mesh containing the necessary connectivity. + """ + if isinstance(elements, Scoping): + scoping = elements + else: + scoping = Scoping( + location=locations.elemental, ids=elements, server=self._server + ) + + op = operators.scoping.transpose( + mesh_scoping=scoping, + meshed_region=mesh._meshed_region, + inclusive=0, + requested_location=locations.faces, ) self._selection.add_operator(op) self._selection.set_output_name( _WfNames.scoping, op.outputs.mesh_scoping_as_scoping ) + def select_faces(self, faces: Union[List[int], Scoping]) -> None: + """Select faces using their IDs or a faces mesh scoping. + + Parameters + ---------- + faces : + face IDs or faces mesh scoping. + """ + if isinstance(faces, Scoping): + scoping = faces + else: + scoping = Scoping(location=locations.faces, ids=faces, server=self._server) + self.select_with_scoping(scoping) + def select_elements(self, elements: Union[List[int], Scoping]) -> None: """Select elements using their IDs or an elemental mesh scoping. @@ -783,6 +862,18 @@ def select_nodes(self, nodes: Union[List[int], Scoping]) -> None: """ self._spatial_selection.select_nodes(nodes) + def select_faces(self, faces: Union[List[int], Scoping]) -> None: + """Select a mesh scoping with its face IDs. + + Select a mesh scoping corresponding to a list of face IDs. + + Parameters + ---------- + faces: + face IDs. + """ + self._spatial_selection.select_faces(faces) + def select_elements(self, elements: Union[List[int], Scoping]) -> None: """Select a mesh scoping with its element IDs. @@ -811,6 +902,38 @@ def select_nodes_of_elements( """ self._spatial_selection.select_nodes_of_elements(elements, mesh) + def select_nodes_of_faces( + self, faces: Union[List[int], Scoping], mesh: Mesh + ) -> None: + """Select nodes belonging to faces defined by their IDs. + + Select a nodal mesh scoping corresponding to faces. + + Parameters + ---------- + faces: + face IDs. + mesh: + Mesh containing the connectivity. + """ + self._spatial_selection.select_nodes_of_faces(faces, mesh) + + def select_faces_of_elements( + self, elements: Union[List[int], Scoping], mesh: Mesh + ) -> None: + """Select faces belonging to elements defined by their IDs. + + Select a faces mesh scoping corresponding to elements. + + Parameters + ---------- + elements: + element IDs. + mesh: + Mesh containing the connectivity. + """ + self._spatial_selection.select_faces_of_elements(elements, mesh) + def select_external_layer( self, location: Union[locations, str] = locations.elemental, diff --git a/src/ansys/dpf/post/simulation.py b/src/ansys/dpf/post/simulation.py index 1f3dd7ae7..0f22a3310 100644 --- a/src/ansys/dpf/post/simulation.py +++ b/src/ansys/dpf/post/simulation.py @@ -90,11 +90,6 @@ def release_streams(self): """Release the streams to data files if any is active.""" self._model.metadata.release_streams() - @property - def mesh_info(self): - """Return available mesh information.""" - return self._model.metadata.mesh_info - @property def results(self) -> List[dpf.result_info.available_result.AvailableResult]: r"""Available results. diff --git a/src/ansys/dpf/post/zone.py b/src/ansys/dpf/post/zone.py deleted file mode 100644 index 7eb2e6724..000000000 --- a/src/ansys/dpf/post/zone.py +++ /dev/null @@ -1,70 +0,0 @@ -"""Module containing the ``Zone`` class and sub-classes. - -Zone ----- - -""" -from abc import ABC -from typing import List - - -class Zone(ABC): - """Base class for fluid Zone objects.""" - - def __init__( - self, name: str, id: int, scoping - ): # pylint: disable=redefined-builtin - """Initialize this class.""" - self._name = name - self._id = id - self._mesh_scoping = scoping - - @property - def name(self) -> str: - """Return the name of the Zone.""" - return self._name - - @property - def id(self) -> int: - """Return the ID of the Zone.""" - return self._id - - -class CellZone(Zone): - """Fluid zone defined on cells.""" - - @property - def cells(self) -> List[int]: - """Return the list of IDs of the cells in the Zone.""" - return self._mesh_scoping.ids - - -class FaceZone(Zone): - """Fluid zone defined on faces.""" - - @property - def faces(self) -> List[int]: - """Return the list of IDs of the faces in the Zone.""" - return self._mesh_scoping.ids - - -class Zones: - """List of fluid zones.""" - - def __init__(self): - """Initialize this class.""" - self._zones = [] # list of CellZone and FaceZone - self._face_zones_ind = 0 - - @property - def cell_zones(self) -> List[CellZone]: - """Return the list of CellZone instances only.""" - return self._zones[: self._face_zones_ind] - - def face_zones(self) -> List[FaceZone]: - """Return the list of FaceZone instances only.""" - return self._zones[self._face_zones_ind :] - - def __getitem__(self, key: int) -> Zone: - """Return the Zone at the given position in the list.""" - return self._zones[key] diff --git a/tests/test_faces.py b/tests/test_faces.py new file mode 100644 index 000000000..cf59457da --- /dev/null +++ b/tests/test_faces.py @@ -0,0 +1,68 @@ +from ansys.dpf.core import examples +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 +import pytest +from pytest import fixture + +from ansys.dpf import core as dpf +from ansys.dpf import post +from ansys.dpf.post.faces import Face, FaceListById, FaceListByIndex +from ansys.dpf.post.nodes import NodeListByIndex + + +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="Faces added with ansys-dpf-server 2024.1.pre0.", +) +class TestFaces: + @fixture + def fluent_simulation(self): + fluid_example_files = examples.download_fluent_axial_comp() + ds = dpf.DataSources() + ds.set_result_file_path( + fluid_example_files["cas"][0], + key="cas", + ) + ds.add_file_path( + fluid_example_files["dat"][0], + key="dat", + ) + return post.FluidSimulation(ds) # noqa + + def test_faces(self, fluent_simulation): + faces = fluent_simulation.mesh.faces + assert isinstance(faces, FaceListByIndex) + assert len(faces) == 44242 + ref = "FaceListByIndex([quad4, ..., quad4], __len__=44242)" + assert repr(faces) == ref + ref = "[quad4, ..., quad4]" + assert str(faces) == ref + assert faces[0] in faces + for face in faces: + assert isinstance(face, Face) + faces_by_id = faces.by_id + assert isinstance(faces_by_id, FaceListById) + assert len(faces_by_id) == 44242 + ref = "FaceListById([quad4, ..., quad4], __len__=44242)" + assert repr(faces_by_id) == ref + ref = "[quad4, ..., quad4]" + assert str(faces_by_id) == ref + assert faces[0] in faces_by_id + for face in faces_by_id: + assert isinstance(face, Face) + assert faces_by_id[faces[0].id].id == faces[0].id + face = faces[0] + assert face.node_ids == [11291, 11416, 11455, 11325] + assert face.id == 1003 + assert face.index == 0 + assert isinstance(face.nodes, NodeListByIndex) + assert face.num_nodes == 4 + assert face.type == dpf.element_types.Quad4 + ref = "Face(type=element_types.Quad4,index=0,id=1003)" + assert repr(face) == ref + ref = """DPF Face 1003 +\tIndex: 0 +\tNodes: 4 +\tType: element_types.Quad4 +""" + assert str(face) == ref + assert face.to_node_connectivity == [11290, 11415, 11454, 11324] diff --git a/tests/test_fluid_simulation.py b/tests/test_fluid_simulation.py index acb5485a5..2fca3e918 100644 --- a/tests/test_fluid_simulation.py +++ b/tests/test_fluid_simulation.py @@ -99,11 +99,6 @@ def test_results_cfx(self, cfx_simulation, result_name): result = getattr(cfx_simulation, result_name)(phases=[2]) assert isinstance(result, post.DataFrame) - def test_fluid_simulation_zones(self, fluent_simulation): - from ansys.dpf.post.zone import Zones - - assert isinstance(fluent_simulation.zones, Zones) - def test_fluid_simulation_species(self, fluent_simulation): from ansys.dpf.post.species import SpeciesDict @@ -113,3 +108,324 @@ def test_fluid_simulation_phases(self, fluent_simulation): from ansys.dpf.post.phase import PhasesDict assert isinstance(fluent_simulation.phases, PhasesDict) + + def test_fluid_simulation_result_unavailable(self, fluent_simulation): + print(fluent_simulation) + with pytest.raises(ValueError, match="is not available."): + _ = fluent_simulation.wall_shear_stress() + + def test_results_fluent_averaging_from_elemental(self, fluent_simulation): + print(fluent_simulation) + # ######## Elemental Result ################# + # Request on None + result = fluent_simulation.enthalpy() + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + + # Request on nodes + result = fluent_simulation.enthalpy(location=post.locations.nodal) + assert result.index.mesh_index.location == post.locations.nodal + assert result._core_object[0].location == post.locations.nodal + result = fluent_simulation.enthalpy_on_nodes() + assert result.index.mesh_index.location == post.locations.nodal + assert result._core_object[0].location == post.locations.nodal + + # Request on faces + with pytest.raises( + ValueError, match="Cannot query elemental results on faces." + ): + _ = fluent_simulation.enthalpy(location=post.locations.faces) + + # Request on cells + result = fluent_simulation.enthalpy(location=post.locations.elemental) + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + result = fluent_simulation.enthalpy_on_cells() + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + + def test_results_fluent_averaging_from_elemental_faces(self, fluent_simulation): + print(fluent_simulation) + # ######## ElementalFaces Result ################# + # Request on None + result = fluent_simulation.static_pressure() + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + + # Request on nodes + result = fluent_simulation.static_pressure(location=post.locations.nodal) + assert result.index.mesh_index.location == post.locations.nodal + assert result._core_object[0].location == post.locations.nodal + result = fluent_simulation.static_pressure_on_nodes() + assert result.index.mesh_index.location == post.locations.nodal + assert result._core_object[0].location == post.locations.nodal + + # Request on faces (requires filter-out of cell zones) + with pytest.raises( + ValueError, + match="Querying an ElementalAndFaces result on " + "faces currently requires the use of face zone ids", + ): + _ = fluent_simulation.static_pressure(location=post.locations.faces) + # print(result) + # assert result.index.mesh_index.location == post.locations.faces + # assert result._core_object[0].location == post.locations.faces + # result._fc[0].plot() + with pytest.raises( + ValueError, + match="Querying an ElementalAndFaces result on " + "faces currently requires the use of face zone ids", + ): + _ = fluent_simulation.static_pressure_on_faces() + # print(result) + # assert result.index.mesh_index.location == post.locations.faces + # # assert result._core_object[0].location == post.locations.faces + # result.plot() + + # Request on cells (requires filter-out of face zones) + result = fluent_simulation.static_pressure(location=post.locations.elemental) + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + result = fluent_simulation.static_pressure_on_cells() + assert result.index.mesh_index.location == "cells" + assert result._core_object[0].location == post.locations.elemental + + def test_results_cfx_cross_locations_on_nodes(self, cfx_simulation): + result = cfx_simulation.temperature_on_nodes( + node_ids=cfx_simulation.mesh.node_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + assert len(result.index.mesh_index) == cfx_simulation.mesh_info.num_nodes + ref = """ + results TEMP (K) + set_ids 1 + phase Water at 25 C (2) Copper (3) + node_ids + 1 3.0550e+02 + 2 3.0445e+02 + 3 3.0147e+02 + 4 3.0157e+02 + 5 3.0301e+02 + 6 3.0478e+02 + ... ... ... +""" # noqa: W291, E501 + assert str(result) == ref + result = cfx_simulation.temperature_on_nodes( + cell_ids=cfx_simulation.mesh.element_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + assert len(result.index.mesh_index) == cfx_simulation.mesh_info.num_nodes + ref = """ + results TEMP (K) + set_ids 1 + phase Water at 25 C (2) Copper (3) + node_ids + 3149 3.0212e+02 + 4143 3.0047e+02 + 3140 3.0107e+02 + 3158 3.0132e+02 + 3154 3.0473e+02 + 4146 3.0047e+02 + ... ... ... +""" # noqa: W291, E501 + assert str(result) == ref + result = cfx_simulation.temperature_on_nodes( + face_ids=cfx_simulation.mesh.face_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + ref = """ + results TEMP (K) + set_ids 1 + phase Water at 25 C (2) Copper (3) + node_ids +""" # noqa: W291, E501 + assert str(result) == ref + + def test_results_cfx_cross_locations_on_faces(self, cfx_simulation): + # result = cfx_simulation.density_on_faces( + # cell_ids=cfx_simulation.mesh.element_ids + # ) + # assert result.index.mesh_index.location == post.locations.faces + # assert result._fc[0].location == post.locations.faces + # ref = """ + # results RHO (kg*m^-3) + # set_ids 1 + # phase Water at 25 C (2) Copper (3) + # face_ids + # 1 9.9700e+02 + # 2 9.9700e+02 + # 3 9.9700e+02 + # 4 9.9700e+02 + # 5 9.9700e+02 + # 6 9.9700e+02 + # ... ... ... + # """ # noqa: W291, E501 + # assert str(result) == ref + # result.plot() + result = cfx_simulation.temperature_on_faces( + face_ids=cfx_simulation.mesh.face_ids + ) + assert result.index.mesh_index.location == post.locations.faces + ref = """ + results TEMP (K) + set_ids 1 + phase Water at 25 C (2) Copper (3) + face_ids +""" # noqa: W291, E501 + assert str(result) == ref + with pytest.raises( + ValueError, match="Cannot plot a Dataframe with an empty mesh index." + ): + result.plot() + + def test_results_cfx_cross_locations_on_cells(self, cfx_simulation): + result = cfx_simulation.temperature_on_cells( + cell_ids=cfx_simulation.mesh.element_ids + ) + assert result.index.mesh_index.location == "cells" + assert len(result.index.mesh_index) == cfx_simulation.mesh_info.num_cells + ref = """ + results TEMP (K) + set_ids 1 + phase Water at 25 C (2) Copper (3) + cell_ids + 1 3.0124e+02 + 2 3.0200e+02 + 3 3.0184e+02 + 4 3.0071e+02 + 5 3.0327e+02 + 6 3.0063e+02 + ... ... ... +""" # noqa: W291, E501 + assert str(result) == ref + + def test_results_fluent_cross_locations_on_nodes(self, fluent_simulation): + result = fluent_simulation.density_on_nodes( + node_ids=fluent_simulation.mesh.node_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + ref = """ + results RHO (kg*m^-3) + set_ids 1 + node_ids + 1 1.0742e+00 + 2 1.0436e+00 + 3 1.0131e+00 + 4 1.0327e+00 + 5 1.0247e+00 + 6 1.0445e+00 + ... ... +""" # noqa: W291, E501 + assert str(result) == ref + result = fluent_simulation.density_on_nodes( + cell_ids=fluent_simulation.mesh.element_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + ref = """ + results RHO (kg*m^-3) + set_ids 1 + node_ids + 996 1.1041e+00 + 894 1.1035e+00 + 795 1.0982e+00 + 903 1.0985e+00 + 997 1.1097e+00 + 895 1.1091e+00 + ... ... +""" # noqa: W291, E501 + assert str(result) == ref + result = fluent_simulation.density_on_nodes( + face_ids=fluent_simulation.mesh.face_ids + ) + assert result.index.mesh_index.location == post.locations.nodal + ref = """ + results RHO (kg*m^-3) + set_ids 1 + node_ids + 11291 1.3590e+00 + 11416 1.3262e+00 + 11455 1.3104e+00 + 11325 1.3470e+00 + 11348 1.2896e+00 + 11388 1.2771e+00 + ... ... +""" # noqa: W291, E501 + assert str(result) == ref + + def test_results_fluent_cross_locations_on_faces(self, fluent_simulation): + # TODO investigate wrong plot, wrong mesh index for dataframes + # print(fluent_simulation) + # with pytest.raises( + # ValueError, + # match="Querying an ElementalAndFaces result on " + # "faces currently requires the use of face zone ids", + # ): + # _ = fluent_simulation.density_on_faces( + # cell_ids=fluent_simulation.mesh.element_ids + # ) + # print(result) + # assert result.index.mesh_index.location == post.locations.faces + # # assert len(result.index.mesh_index.values) == fluent_simulation.mesh.num_faces + # ref = """ + # results RHO (kg*m^-3) + # set_ids 1 + # face_ids + # 1 1.1095e+00 + # 2 1.1087e+00 + # 3 1.1098e+00 + # 4 1.0977e+00 + # 5 1.0949e+00 + # 6 1.1077e+00 + # ... ... + # """ # noqa: W291, E501 + # assert str(result) == ref + # result.plot() + with pytest.raises( + ValueError, + match="Querying an ElementalAndFaces result on " + "faces currently requires the use of face zone ids", + ): + _ = fluent_simulation.density_on_faces( + face_ids=fluent_simulation.mesh.face_ids + ) + + # print(result) + # assert result.index.mesh_index.location == post.locations.faces + # # assert len(result.index.mesh_index.values) == fluent_simulation.mesh.num_faces + # ref = """ + # results RHO (kg*m^-3) + # set_ids 1 + # face_ids + # 1003 1.0877e+00 + # 1004 1.0698e+00 + # 1005 1.0493e+00 + # 1006 1.0334e+00 + # 1007 1.0366e+00 + # 1008 1.0660e+00 + # ... ... + # """ # noqa: W291, E501 + # assert str(result) == ref + # result.plot() + + def test_results_fluent_cross_locations_on_cells(self, fluent_simulation): + result = fluent_simulation.density_on_cells( + cell_ids=fluent_simulation.mesh.element_ids + ) + assert result.index.mesh_index.location == "cells" + assert ( + len(result.index.mesh_index.values) == fluent_simulation.mesh.num_elements + ) + ref = """ + results RHO (kg*m^-3) + set_ids 1 + cell_ids + 1 1.1095e+00 + 2 1.1087e+00 + 3 1.1098e+00 + 4 1.0977e+00 + 5 1.0949e+00 + 6 1.1077e+00 + ... ... +""" # noqa: W291, E501 + assert str(result) == ref + result.plot() diff --git a/tests/test_mesh.py b/tests/test_mesh.py index 4ec8c9c5b..810906a23 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -1,9 +1,12 @@ import ansys.dpf.core as dpf +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 import numpy as np import pytest from pytest import fixture -from ansys.dpf.post import Mesh, StaticMechanicalSimulation +from ansys.dpf.post import FluidSimulation, Mesh, StaticMechanicalSimulation +from ansys.dpf.post.connectivity import ConnectivityListByIndex +from ansys.dpf.post.faces import Face @fixture @@ -12,6 +15,21 @@ def mesh(static_rst): return simulation.mesh +@fixture +def fluent_mesh(fluid_fluent_elbow_steady_state): + ds = dpf.DataSources() + ds.set_result_file_path( + fluid_fluent_elbow_steady_state["cas"][0], + key="cas", + ) + ds.add_file_path( + fluid_fluent_elbow_steady_state["dat"][0], + key="dat", + ) + simulation = FluidSimulation(ds) + return simulation.mesh # noqa + + def test_mesh_core_object(mesh): assert isinstance(mesh._core_object, dpf.MeshedRegion) assert mesh._core_object.nodes.n_nodes == 81 @@ -168,3 +186,24 @@ def test_mesh_element_types(mesh): def test_mesh_plot(mesh): mesh.plot() + + +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="Available starting DPF 7.0", +) +def test_mesh_faces(fluent_mesh): + assert fluent_mesh.num_faces == 94288 + assert len(fluent_mesh.face_ids) == 94288 + assert len(fluent_mesh.faces) == 94288 + assert isinstance(fluent_mesh.faces[0], Face) + first_face = fluent_mesh.get_face_by_id(fluent_mesh.face_ids[0]) + assert isinstance(first_face, Face) + assert first_face.index == 0 + assert first_face.id == fluent_mesh.face_ids[0] + assert isinstance(fluent_mesh.face_to_node_connectivity, ConnectivityListByIndex) + assert fluent_mesh.face_to_node_connectivity[0] == [20, 25, 2921] + assert isinstance( + fluent_mesh.face_to_node_ids_connectivity, ConnectivityListByIndex + ) + assert fluent_mesh.face_to_node_ids_connectivity[1] == [21, 2922, 23] diff --git a/tests/test_mesh_info.py b/tests/test_mesh_info.py new file mode 100644 index 000000000..ca6f26c6e --- /dev/null +++ b/tests/test_mesh_info.py @@ -0,0 +1,52 @@ +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 +import pytest +from pytest import fixture + +from ansys.dpf import core as dpf +from ansys.dpf import post +from ansys.dpf.post import examples + + +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="FluidMeshInfo added with ansys-dpf-server 2024.1.pre0.", +) +class TestFluidMeshInfo: + @fixture + def fluent_simulation(self): + fluid_example_files = examples.download_fluent_axial_comp() + ds = dpf.DataSources() + ds.set_result_file_path( + fluid_example_files["cas"][0], + key="cas", + ) + ds.add_file_path( + fluid_example_files["dat"][0], + key="dat", + ) + return post.FluidSimulation(ds) # noqa + + def test_fluid_mesh_info_print(self, fluent_simulation): + print(fluent_simulation.mesh_info) + ref = ( + "Fluid mesh metadata\n" + "-------------------\n" + "Number of nodes: 16660\n" + "Number of faces: 45391\n" + "Number of cells: 13856\n" + "Cell zones:\n" + "\t{13: 'fluid-rotor', 28: 'fluid-stator'}\n" + "Face zones:\n" + "\t{2: 'default-interior:0', 3: 'rotor-hub', 4: 'rotor-shroud', 5: 'rotor-inlet', " + "6: 'rotor-interface', 7: 'rotor-blade-1', 8: 'rotor-blade-2', " + "9: 'rotor-per-1-shadow', 10: 'rotor-per-1', 11: 'rotor-per-2-shadow', " + "12: 'rotor-per-2', 15: 'default-interior', 16: 'stator-hub', " + "17: 'stator-shroud', 18: 'stator-interface', 19: 'stator-outlet', " + "20: 'stator-blade-1', 21: 'stator-blade-2', 22: 'stator-blade-3', " + "23: 'stator-blade-4', 24: 'stator-per-2', 25: 'stator-per-2-shadow', " + "26: 'stator-per-1', 27: 'stator-per-1-shadow'}\n" + "Cell to face zones:\n" + "\t{13: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], " + "28: [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]}\n" + ) + assert str(fluent_simulation.mesh_info) == ref diff --git a/tests/test_selection.py b/tests/test_selection.py index cc791e418..6b871c584 100644 --- a/tests/test_selection.py +++ b/tests/test_selection.py @@ -1,43 +1,101 @@ +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 import numpy as np +import pytest +from pytest import fixture +from ansys.dpf import core as dpf from ansys.dpf import post +from ansys.dpf.post import examples from ansys.dpf.post.selection import SpatialSelection def test_spatial_selection_select_nodes(allkindofcomplexity): - solution = post.load_solution(allkindofcomplexity) + simulation = post.load_simulation(allkindofcomplexity) selection = SpatialSelection() selection.select_nodes([1, 2, 3]) - scoping = selection._evaluate_on(solution) - assert scoping.location == post.selection.locations.nodal + scoping = selection._evaluate_on(simulation) + assert scoping.location == post.locations.nodal assert np.allclose(scoping.ids, [1, 2, 3]) + +def test_spatial_selection_select_elements(allkindofcomplexity): + simulation = post.load_simulation(allkindofcomplexity) selection = SpatialSelection() selection.select_elements([1, 2, 3, 4]) - scoping = selection._evaluate_on(solution) - assert scoping.location == post.selection.locations.elemental + scoping = selection._evaluate_on(simulation) + assert scoping.location == post.locations.elemental assert np.allclose(scoping.ids, [1, 2, 3, 4]) - ids = selection.apply_to(solution) + ids = selection.apply_to(simulation) assert np.allclose(ids, [1, 2, 3, 4]) -# def test_spatial_selection_select_named_selection(allkindofcomplexity): -# solution = post.load_solution(allkindofcomplexity, legacy=False) -# -# selection = SpatialSelection() -# selection.select_named_selection( -# solution.mesh.available_named_selections[0], -# location=post.selection.locations.nodal, -# ) -# scoping = selection._evaluate_on(solution) -# assert scoping.location == post.selection.locations.nodal -# assert scoping.ids.size == 12970 -# assert 1857 in scoping.ids -# assert 14826 in scoping.ids -# ids = selection.apply_to(solution) -# assert len(ids) == 12970 -# assert 1857 in ids -# assert 14826 in ids +def test_spatial_selection_select_named_selection(allkindofcomplexity): + simulation = post.load_simulation(allkindofcomplexity) + selection = SpatialSelection() + selection.select_named_selection( + simulation.mesh.named_selections.keys()[0], + location=post.selection.locations.nodal, + ) + scoping = selection._evaluate_on(simulation) + assert scoping.location == post.locations.nodal + assert scoping.ids.size == 12970 + assert 1857 in scoping.ids + assert 14826 in scoping.ids + ids = selection.apply_to(simulation) + assert len(ids) == 12970 + assert 1857 in ids + assert 14826 in ids + + +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="Faces added with ansys-dpf-server 2024.1.pre0.", +) +class TestSpatialSelectionFaces: + @fixture + def fluent_simulation(self): + fluid_example_files = examples.download_fluent_axial_comp() + ds = dpf.DataSources() + ds.set_result_file_path( + fluid_example_files["cas"][0], + key="cas", + ) + ds.add_file_path( + fluid_example_files["dat"][0], + key="dat", + ) + return post.FluidSimulation(ds) # noqa + + def test_spatial_selection_select_faces(self, fluent_simulation): + selection = SpatialSelection() + selection.select_faces(fluent_simulation.mesh.face_ids) + scoping = selection._evaluate_on(fluent_simulation) + assert scoping.location == post.locations.faces + assert np.allclose(scoping.ids, fluent_simulation.mesh.face_ids) + + def test_spatial_selection_select_nodes_of_faces(self, fluent_simulation): + selection = SpatialSelection() + face_0 = fluent_simulation.mesh.faces[0] + selection.select_nodes_of_faces( + faces=[face_0.id], + mesh=fluent_simulation.mesh, + ) + scoping = selection._evaluate_on(fluent_simulation) + assert scoping.location == post.locations.nodal + assert np.allclose(scoping.ids, face_0.node_ids) + + def test_spatial_selection_select_faces_of_elements(self, fluent_simulation): + selection = SpatialSelection() + elem_0 = fluent_simulation.mesh.elements[0] + selection.select_faces_of_elements( + elements=[elem_0.id], + mesh=fluent_simulation.mesh, + ) + scoping = selection._evaluate_on(fluent_simulation) + assert scoping.location == post.locations.faces + assert np.allclose(scoping.ids, [11479, 11500, -1, 11502, 11503]) + + # # # def test_spatial_selection_intersect(allkindofcomplexity):