Skip to content

Commit

Permalink
Implement TransientMechanicalSimulation results (#282)
Browse files Browse the repository at this point in the history
* Use the time_scoping of the FieldsContainer and not its TimeFreqSupport

* Add TransientMechanicalSimulation.displacement

* Add TransientMechanicalSimulation.velocity and acceleration

* Add TransientMechanicalSimulation.stress and all variants

* Add TransientMechanicalSimulation.elastic_strain and all variants

* Move TransientMechanicalSimulation and StaticMechanicalSimulation to individual modules

* Confirm a first set of results for TransientMechanicalSimulation

* Specify available component IDs for vectorial results.

* Specify available component IDs for matrix results.

* Specify available component IDs for principal results. Rework all.

* Switching to node_ids and element_ids.

* Add the case of list of named selections

* Switch to node_ids in TestTransientMechanicalSimulation.

* Add testing for list of named_selections.

* Specify precedence of "selection" argument.

* Mention priority order for filtering arguments.

* Switch to node_ids, element_ids and named_selections in static_mechanical_simulation.py.

* Add component info for vector results in static_mechanical_simulation.py

* Add component info for matrix results in static_mechanical_simulation.py

* Add component info for principal results in static_mechanical_simulation.py

* Fix tests

* Fix DataObject docstring

* Fix 02-get_data_from_static_simulation.py

* component_ids -> components

* Also use set_ids, load_steps, and sub_steps, in signatures for transient_mechanical_simulation.py

* _build_mesh_scoping now returns either a Scoping or an operator Output giving a Scoping.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* sub_steps is now declared using a tuple for load_steps.
Priority of arguments is given in the docstrings.

* Force mutual exclusivity of timefreq arguments, as well as of mesh scoping arguments

* Add an "all_sets" argument which is set to True means all sets will be extracted.

* Improve docstrings to explain extraction defaults in case of no argument given.

* Add implementation for "times" input.

* Reorder and fix all result methods signatures and docstrings.
  • Loading branch information
PProfizi committed Mar 8, 2023
1 parent 03dc0d8 commit ddc6abc
Show file tree
Hide file tree
Showing 8 changed files with 8,371 additions and 3,758 deletions.
8 changes: 4 additions & 4 deletions examples/00-Overview/02-get_data_from_static_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Get and plot stresses
# ---------------------
# Request "XY" stress component averaged on nodes
stress = simulation.stress_nodal(component_ids="XY")
stress = simulation.stress_nodal(components="XY")

###############################################################################
# Print information
Expand All @@ -47,7 +47,7 @@
# Get stresses at only 5 nodes
# ------------------------------
# Request stress only at the first 5 nodes using their IDs.
stress_nodes = simulation.stress_nodal(nodes=range(1, 6))
stress_nodes = simulation.stress_nodal(node_ids=range(1, 6))

###############################################################################
# Print information
Expand All @@ -63,7 +63,7 @@
# Get the name of the first named selection in the simulation
ns = simulation.named_selections[0]
# Request nodal stresses for this named selection
stress_named_sel = simulation.stress_nodal(named_selection=ns)
stress_named_sel = simulation.stress_nodal(named_selections=ns)

###############################################################################
# Print information
Expand All @@ -77,7 +77,7 @@
# Get stresses in a few elements
# ------------------------------
# Request stress only for a few elements selected by their ID
stress_elements = simulation.stress_nodal(elements=[1, 2, 3])
stress_elements = simulation.stress_nodal(element_ids=[1, 2, 3])

###############################################################################
# Print information
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/post/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from ansys.dpf.post.simulation import (
HarmonicMechanicalSimulation,
ModalMechanicalSimulation,
StaticMechanicalSimulation,
TransientMechanicalSimulation,
)
from ansys.dpf.post.static_mechanical_simulation import StaticMechanicalSimulation
from ansys.dpf.post.transient_mechanical_simulation import TransientMechanicalSimulation

# class ElShapes(Enum):
# """Class with Enum inheritance. This class must be used to
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/post/data_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def as_data_frame(self, columns=None, **kwargs):
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.multishells_rst)
>>> # Export the displacements vector field at step 1 as a DataFrame
>>> displacement = simulation.displacement(load_steps=[1], nodes=[1, 2, 3])
>>> displacement = simulation.displacement(load_steps=[1], node_ids=[1, 2, 3])
>>> df = displacement.as_data_frame()
>>> print(df)
UX UY UZ
Expand Down Expand Up @@ -113,7 +113,7 @@ def as_array(self):
>>> from ansys.dpf.post import examples
>>> simulation = post.load_simulation(examples.multishells_rst)
>>> # Export the displacements vector field at step 1 as a DataFrame
>>> displacement = simulation.displacement(load_steps=[1], nodes=[1, 2, 3])
>>> displacement = simulation.displacement(load_steps=[1], node_ids=[1, 2, 3])
>>> arr = displacement.as_array()
>>> print(arr)
[[ 0.39831985 -13.79737819 -0.16376683]
Expand Down
Loading

0 comments on commit ddc6abc

Please sign in to comment.