diff --git a/src/ansys/dpf/composites/_composite_model_impl.py b/src/ansys/dpf/composites/_composite_model_impl.py index d10cc73fb..2f264103a 100644 --- a/src/ansys/dpf/composites/_composite_model_impl.py +++ b/src/ansys/dpf/composites/_composite_model_impl.py @@ -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. + """ + 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. diff --git a/src/ansys/dpf/composites/_composite_model_impl_2023r2.py b/src/ansys/dpf/composites/_composite_model_impl_2023r2.py index bd5f3c4d4..c6515063d 100644 --- a/src/ansys/dpf/composites/_composite_model_impl_2023r2.py +++ b/src/ansys/dpf/composites/_composite_model_impl_2023r2.py @@ -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. diff --git a/src/ansys/dpf/composites/composite_model.py b/src/ansys/dpf/composites/composite_model.py index 5e4bb49b1..06a17b9da 100644 --- a/src/ansys/dpf/composites/composite_model.py +++ b/src/ansys/dpf/composites/composite_model.py @@ -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.