Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
janvonrickenbach committed Dec 8, 2023
1 parent 9bd530f commit 2893378
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ For in-depth documentation on the different failure criteria, refer to the ACP h
data_sources
failure_criteria
layup_info
ply_wise_data
result_definition
sampling_point
server_helpers
Expand Down
12 changes: 12 additions & 0 deletions doc/source/api/ply_wise_data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Data sources
------------

.. module:: ansys.dpf.composites.ply_wise_data

.. autosummary::
:toctree: _autosummary

ReductionStrategy
get_ply_wise_data


2 changes: 2 additions & 0 deletions src/ansys/dpf/composites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
data_sources,
failure_criteria,
layup_info,
ply_wise_data,
result_definition,
sampling_point,
select_indices,
Expand All @@ -27,6 +28,7 @@
"data_sources",
"failure_criteria",
"layup_info",
"ply_wise_data",
"result_definition",
"sampling_point",
"server_helpers",
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/composites/layup_info/_layup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ def get_dpf_material_id_by_analyis_ply_map(
DPF data source with rst file or streams_provider. The streams provider is
available from :attr:`.CompositeModel.core_model` (under metadata.streams_provider).
Note
----
Notes
-----
Cache the output because the computation can be performance-critical.
"""
warn(
Expand Down
2 changes: 2 additions & 0 deletions src/ansys/dpf/composites/ply_wise_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from ansys.dpf.core import Field, MeshedRegion, Operator, operators
from ansys.dpf.gate.common import locations

__all__ = ("ReductionStrategy", "get_ply_wise_data")


class ReductionStrategy(Enum):
"""The reduction strategy to get from spot values (BOT, MID, TOP) to a single value."""
Expand Down
20 changes: 12 additions & 8 deletions tests/ply_wise_data_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def get_reduced_value(all_spot_values: Sequence[float], reduction_strategy: Redu
]


def get_all_spot_values_first_element_first_node(stress_field, component=0):
all_spot_values = []
entity_data = stress_field.get_entity_data_by_id(1)[:, component]
number_of_nodes = 4
for spot_index in range(3):
all_spot_values.append(entity_data[spot_index * number_of_nodes])
return all_spot_values


def test_get_ply_wise_data(dpf_server):
files = get_basic_shell_files()

Expand All @@ -53,14 +62,6 @@ def test_get_ply_wise_data(dpf_server):
stress_result_op.inputs.bool_rotate_to_global(False)
stress_field = stress_result_op.outputs.fields_container()[0]

def get_all_spot_values_first_element_first_node(stress_field, component=0):
all_spot_values = []
entity_data = stress_field.get_entity_data_by_id(1)[:, component]
number_of_nodes = 4
for spot_index in range(3):
all_spot_values.append(entity_data[spot_index * number_of_nodes])
return all_spot_values

first_ply = "P1L1__woven_45"

element_id = 1
Expand All @@ -82,6 +83,7 @@ def get_all_spot_values_first_element_first_node(stress_field, component=0):

assert len(elemental_nodal_data.scoping.ids) == 4
assert len(elemental_nodal_data.get_entity_data_by_id(element_id)) == 4
assert elemental_nodal_data.location == locations.elemental_nodal

assert np.allclose(
elemental_nodal_data.get_entity_data_by_id(element_id)[first_node_index],
Expand All @@ -98,6 +100,7 @@ def get_all_spot_values_first_element_first_node(stress_field, component=0):
)
assert len(elemental_data.scoping.ids) == 4
assert len(elemental_data.get_entity_data_by_id(element_id)) == 1
assert elemental_data.location == locations.elemental

assert np.allclose(
elemental_data.get_entity_data_by_id(element_id)[first_node_index],
Expand All @@ -114,6 +117,7 @@ def get_all_spot_values_first_element_first_node(stress_field, component=0):
)
assert len(nodal_data.scoping.ids) == 9
assert len(nodal_data.get_entity_data_by_id(element_id)) == 1
assert nodal_data.location == locations.nodal

# Select node that only belongs to element 1
# no averaging needed
Expand Down

0 comments on commit 2893378

Please sign in to comment.