Skip to content

Commit

Permalink
Add average_across body argument for all simulation types
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
janvonrickenbach committed Oct 8, 2024
1 parent 33b87cb commit 0c7cb2c
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ansys/dpf/post/fluid_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def _get_result_workflow(

_connect_initial_results_inputs(
initial_result_workflow=initial_result_workflow,
split_by_body_workflow=None,
force_elemental_nodal=False,
location=location,
selection=selection,
Expand Down
7 changes: 7 additions & 0 deletions src/ansys/dpf/post/harmonic_mechanical_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _get_result_workflow(
selection: Union[Selection, None] = None,
expand_cyclic: Union[bool, List[Union[int, List[int]]]] = True,
phase_angle_cyclic: Union[float, None] = None,
average_across_bodies: bool = True,
) -> (dpf.Workflow, Union[str, list[str], None], str):
"""Generate (without evaluating) the Workflow to extract results."""
result_workflow_inputs = _create_result_workflow_inputs(
Expand All @@ -63,6 +64,7 @@ def _get_result_workflow(
mesh_provider=self._model.metadata.mesh_provider,
amplitude=amplitude,
sweeping_phase=sweeping_phase,
average_across_bodies=average_across_bodies,
)
result_workflows = _create_result_workflows(
server=self._model._server,
Expand Down Expand Up @@ -130,6 +132,7 @@ def _get_result(
phase_angle_cyclic: Union[float, None] = None,
external_layer: Union[bool, List[int]] = False,
skin: Union[bool, List[int]] = False,
average_across_bodies: bool = True,
) -> DataFrame:
"""Extract results from the simulation.
Expand Down Expand Up @@ -202,6 +205,9 @@ def _get_result(
is computed over list of elements (not supported for cyclic symmetry). Getting the
skin on more than one result (several time freq sets, split data...) is only
supported starting with Ansys 2023R2.
average_across_bodies:
If true, averaging happens across all bodies. If False the resulting dataframe
contains an entry for each body.
Returns
-------
Expand Down Expand Up @@ -261,6 +267,7 @@ def _get_result(
selection=selection,
expand_cyclic=expand_cyclic,
phase_angle_cyclic=phase_angle_cyclic,
average_across_bodies=average_across_bodies,
)

# Evaluate the workflow
Expand Down
6 changes: 6 additions & 0 deletions src/ansys/dpf/post/modal_mechanical_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def _get_result_workflow(
selection: Union[Selection, None] = None,
expand_cyclic: Union[bool, List[Union[int, List[int]]]] = True,
phase_angle_cyclic: Union[float, None] = None,
average_across_bodies: bool = True,
) -> (dpf.Workflow, Union[str, list[str], None], str):
"""Generate (without evaluating) the Workflow to extract results."""
result_workflow_inputs = _create_result_workflow_inputs(
Expand All @@ -50,6 +51,7 @@ def _get_result_workflow(
selection=selection,
create_operator_callable=self._model.operator,
mesh_provider=self._model.metadata.mesh_provider,
average_across_bodies=average_across_bodies,
)
result_workflows = _create_result_workflows(
server=self._model._server,
Expand Down Expand Up @@ -111,6 +113,7 @@ def _get_result(
phase_angle_cyclic: Union[float, None] = None,
external_layer: Union[bool, List[int]] = False,
skin: Union[bool, List[int]] = False,
average_across_bodies: bool = True,
) -> DataFrame:
"""Extract results from the simulation.
Expand Down Expand Up @@ -176,6 +179,9 @@ def _get_result(
is computed over list of elements (not supported for cyclic symmetry). Getting the
skin on more than one result (several time freq sets, split data...) is only
supported starting with Ansys 2023R2.
average_across_bodies:
If true, averaging happens across all bodies. If False the resulting dataframe
contains an entry for each body.
Returns
-------
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/dpf/post/result_workflows/_build_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ def _create_result_workflow_inputs(
selection: Selection,
create_operator_callable: Callable[[str], Operator],
mesh_provider: Any,
# todo: make this input required
average_across_bodies: bool = True,
average_across_bodies: bool,
amplitude: bool = False,
sweeping_phase: Union[float, None] = 0.0,
) -> _CreateWorkflowInputs:
Expand Down
3 changes: 3 additions & 0 deletions src/ansys/dpf/post/static_mechanical_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ def _get_result(
is computed over list of elements (not supported for cyclic symmetry). Getting the
skin on more than one result (several time freq sets, split data...) is only
supported starting with Ansys 2023R2.
average_across_bodies:
If true, averaging happens across all bodies. If False the resulting dataframe
contains an entry for each body.
Returns
-------
Expand Down
7 changes: 7 additions & 0 deletions src/ansys/dpf/post/transient_mechanical_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def _get_result_workflow(
components: Union[str, List[str], int, List[int], None] = None,
norm: bool = False,
selection: Union[Selection, None] = None,
average_across_bodies: bool = True,
) -> (dpf.Workflow, Union[str, list[str], None], str):
"""Generate (without evaluating) the Workflow to extract results."""
result_workflow_inputs = _create_result_workflow_inputs(
Expand All @@ -48,6 +49,7 @@ def _get_result_workflow(
selection=selection,
create_operator_callable=self._model.operator,
mesh_provider=self._model.metadata.mesh_provider,
average_across_bodies=average_across_bodies,
)
result_workflows = _create_result_workflows(
server=self._model._server,
Expand Down Expand Up @@ -110,6 +112,7 @@ def _get_result(
named_selections: Union[List[str], str, None] = None,
external_layer: Union[bool, List[int]] = False,
skin: Union[bool, List[int]] = False,
average_across_bodies: bool = True,
) -> DataFrame:
"""Extract results from the simulation.
Expand Down Expand Up @@ -171,6 +174,9 @@ def _get_result(
is computed over list of elements (not supported for cyclic symmetry). Getting the
skin on more than one result (several time freq sets, split data...) is only
supported starting with Ansys 2023R2.
average_across_bodies:
If true, averaging happens across all bodies. If False the resulting dataframe
contains an entry for each body.
Returns
-------
Expand Down Expand Up @@ -214,6 +220,7 @@ def _get_result(
components=components,
norm=norm,
selection=selection,
average_across_bodies=average_across_bodies,
)

# Evaluate the workflow
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3844,7 +3844,7 @@ def test_averaging_per_body_nodal(
],
)
def test_averaging_per_body_elemental(
request, is_skin, result, result_file, ref_file_folder, named_selection_name
request, is_skin, result, result_file, named_selection_name
):
# Expectation is that elemental results are not affected by the average per body flag.

Expand Down

0 comments on commit 0c7cb2c

Please sign in to comment.