Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/exposure of material names #353

Merged
merged 26 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ec05643
Fix broken link, and port changes from 0.3.1 back to develop
roosre Sep 14, 2023
6a0bbbd
Merge branch 'main' of https://github.com/ansys/pydpf-composites
roosre Sep 21, 2023
d9f3db9
add `material_names` as property to the CompositeModel which returns …
roosre Sep 22, 2023
fe3c22e
add unit test
roosre Sep 22, 2023
4994770
apply pre-commit patch
roosre Sep 22, 2023
a60ac4a
apply pre-commit patch
roosre Sep 22, 2023
ba0587b
Fix typo
roosre Sep 25, 2023
8cca3cc
code style checks
roosre Sep 25, 2023
b8f9c35
code style checks
roosre Sep 25, 2023
8c91b31
code style checks
roosre Sep 25, 2023
e5c1b12
code style checks
roosre Sep 25, 2023
e8c91f7
code style checks
roosre Sep 25, 2023
c4bb351
code style checks
roosre Sep 25, 2023
2a3f261
run new test only if the latest server version is used.
roosre Sep 25, 2023
9127c8f
Update src/ansys/dpf/composites/layup_info/_layup_info.py
roosre Sep 25, 2023
453353a
Update src/ansys/dpf/composites/layup_info/_layup_info.py
roosre Sep 25, 2023
01c7b2f
Update src/ansys/dpf/composites/layup_info/_layup_info.py
roosre Sep 25, 2023
4d924c1
Update src/ansys/dpf/composites/layup_info/_layup_info.py
roosre Sep 25, 2023
a910500
Update src/ansys/dpf/composites/layup_info/_layup_info.py
roosre Sep 25, 2023
223292c
Update documentation
roosre Sep 25, 2023
de75ee1
Merge remote-tracking branch 'origin/feat/exposure_of_material_names'…
roosre Sep 25, 2023
88941d2
Merge branch 'main' into feat/exposure_of_material_names
roosre Sep 25, 2023
0e3468d
code style checks
roosre Sep 26, 2023
dd4b092
Merge remote-tracking branch 'origin/feat/exposure_of_material_names'…
roosre Sep 26, 2023
1b9d662
code style checks
roosre Sep 26, 2023
66f745f
fix documentation
roosre Sep 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ansys/dpf/composites/_composite_model_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,25 @@ def material_operators(self) -> MaterialOperators:
"""Material operators."""
return self._material_operators

@property
def material_names(self) -> Dict[str, int]:
"""
Material name to DPF material ID map.

Can be used to filter analysis plies or element layers.
roosre marked this conversation as resolved.
Show resolved Hide resolved
"""
helper_op = dpf.Operator("composite::materials_container_helper")
helper_op.inputs.materials_container(self._material_operators.material_provider.outputs)
string_field = helper_op.outputs.material_names()
material_ids = string_field.scoping.ids

names = {}
for mat_id in material_ids:
names[string_field.data[string_field.scoping.index(mat_id)]] = mat_id

return names


@_deprecated_composite_definition_label
def get_mesh(self, composite_definition_label: Optional[str] = None) -> MeshedRegion:
"""Get the underlying DPF meshed region.
Expand Down
9 changes: 9 additions & 0 deletions src/ansys/dpf/composites/_composite_model_impl_2023r2.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@ def material_operators(self) -> MaterialOperators:
"""Material operators."""
return self._material_operators

@property
def material_names(self) -> Dict[str, int]:
"""Material ID to name map"""
raise NotImplementedError(
"material_names is not implemented"
" for this version of DPF. Please upgrade to 7.0 (2024 R1)"
" or later."
)

def get_layup_operator(self, composite_definition_label: Optional[str] = None) -> Operator:
"""Get the lay-up operator.

Expand Down
5 changes: 5 additions & 0 deletions src/ansys/dpf/composites/composite_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def material_operators(self) -> MaterialOperators:
"""Material operators."""
return self._implementation.material_operators

@property
def material_names(self) -> Dict[str, int]:
"""Material ID to name map"""
return self._implementation.material_names

def get_mesh(self, composite_definition_label: Optional[str] = None) -> MeshedRegion:
"""Get the underlying DPF meshed region.

Expand Down
11 changes: 11 additions & 0 deletions tests/composite_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ def test_basic_functionality_of_composite_model(dpf_server, data_files, distribu

assert [ply["id"] for ply in sampling_point.analysis_plies] == analysis_ply_ids

ref_material_names = {
'Epoxy Carbon UD (230 GPa) Prepreg': 3,
'Epoxy Carbon Woven (230 GPa) Wet': 2,
'Honeycomb': 4,
'Structural Steel': 1
}
mat_names = composite_model.material_names
assert len(mat_names) == len(ref_material_names)
for mat_name, dpf_mat_id in ref_material_names.items():
assert mat_names[mat_name] == dpf_mat_id

timer.add("After getting properties")

timer.summary()
Expand Down