|
| 1 | +# Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates. |
| 2 | +# SPDX-License-Identifier: MIT |
| 3 | +# |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +from __future__ import annotations |
| 24 | + |
| 25 | +from collections.abc import Iterable |
| 26 | +import dataclasses |
| 27 | + |
| 28 | +from ansys.api.acp.v0 import interface_layer_pb2, interface_layer_pb2_grpc |
| 29 | + |
| 30 | +from .._utils.property_protocols import ReadWriteProperty |
| 31 | +from ._grpc_helpers.linked_object_list import ( |
| 32 | + define_linked_object_list, |
| 33 | + define_polymorphic_linked_object_list, |
| 34 | +) |
| 35 | +from ._grpc_helpers.property_helper import ( |
| 36 | + grpc_data_property, |
| 37 | + grpc_data_property_read_only, |
| 38 | + mark_grpc_properties, |
| 39 | +) |
| 40 | +from ._mesh_data import ( |
| 41 | + ElementalData, |
| 42 | + NodalData, |
| 43 | + VectorData, |
| 44 | + elemental_data_property, |
| 45 | + nodal_data_property, |
| 46 | +) |
| 47 | +from .base import CreatableTreeObject, IdTreeObject |
| 48 | +from .element_set import ElementSet |
| 49 | +from .enums import status_type_from_pb |
| 50 | +from .object_registry import register |
| 51 | +from .oriented_selection_set import OrientedSelectionSet |
| 52 | + |
| 53 | + |
| 54 | +@dataclasses.dataclass |
| 55 | +class InterfaceLayerElementalData(ElementalData): |
| 56 | + """Represents elemental data for a Modeling Ply.""" |
| 57 | + |
| 58 | + normal: VectorData | None = None |
| 59 | + |
| 60 | + |
| 61 | +@dataclasses.dataclass |
| 62 | +class InterfaceLayerNodalData(NodalData): |
| 63 | + """Represents nodal data for a Modeling Ply.""" |
| 64 | + |
| 65 | + ply_offset: VectorData | None = None |
| 66 | + |
| 67 | + |
| 68 | +@mark_grpc_properties |
| 69 | +@register |
| 70 | +class InterfaceLayer(CreatableTreeObject, IdTreeObject): |
| 71 | + """Instantiate an interface layer. |
| 72 | +
|
| 73 | + The interface layer is a separation layer in the stacking sequence. It can be |
| 74 | + used to analyze the crack growth of existing cracks. They can also be used to |
| 75 | + define contacts zones between two layers. |
| 76 | + The topology is defined with an interface layer in ACP, while all other fracture |
| 77 | + settings need to be specified in the downstream analysis (MAPDL or Mechanical). |
| 78 | +
|
| 79 | + Parameters |
| 80 | + ---------- |
| 81 | + name : |
| 82 | + Name of the interface layer. |
| 83 | + global_ply_nr : |
| 84 | + Global ply number for the stacking sequence. |
| 85 | + active : |
| 86 | + Inactive interface layers are ignored in ACP and the downstream analysis. |
| 87 | + oriented_selection_sets : |
| 88 | + Oriented Selection Set for the expansion of the interface layer. |
| 89 | + open_area_sets : |
| 90 | + Defines the initial crack of a Virtual Crack Closure Technique (VCCT) layer. |
| 91 | + Can contain ``OrientedSelectionSet`` and ``ElementSet`` objects. |
| 92 | + """ |
| 93 | + |
| 94 | + __slots__: Iterable[str] = tuple() |
| 95 | + _COLLECTION_LABEL = "interface_layers" |
| 96 | + _OBJECT_INFO_TYPE = interface_layer_pb2.ObjectInfo |
| 97 | + _CREATE_REQUEST_TYPE = interface_layer_pb2.CreateRequest |
| 98 | + _SUPPORTED_SINCE = "25.1" |
| 99 | + |
| 100 | + def __init__( |
| 101 | + self, |
| 102 | + *, |
| 103 | + name: str = "InterfaceLayer", |
| 104 | + global_ply_nr: int = 0, |
| 105 | + active: bool = True, |
| 106 | + oriented_selection_sets: Iterable[OrientedSelectionSet] = (), |
| 107 | + open_area_sets: Iterable[ElementSet | OrientedSelectionSet] = (), |
| 108 | + ): |
| 109 | + super().__init__(name=name) |
| 110 | + self.global_ply_nr = global_ply_nr |
| 111 | + self.active = active |
| 112 | + self.oriented_selection_sets = oriented_selection_sets |
| 113 | + self.open_area_sets = open_area_sets |
| 114 | + |
| 115 | + def _create_stub(self) -> interface_layer_pb2_grpc.ObjectServiceStub: |
| 116 | + return interface_layer_pb2_grpc.ObjectServiceStub(self._channel) |
| 117 | + |
| 118 | + status = grpc_data_property_read_only("properties.status", from_protobuf=status_type_from_pb) |
| 119 | + global_ply_nr: ReadWriteProperty[int, int] = grpc_data_property("properties.global_ply_nr") |
| 120 | + active: ReadWriteProperty[bool, bool] = grpc_data_property("properties.active") |
| 121 | + oriented_selection_sets = define_linked_object_list( |
| 122 | + "properties.oriented_selection_sets", OrientedSelectionSet |
| 123 | + ) |
| 124 | + open_area_sets = define_polymorphic_linked_object_list( |
| 125 | + "properties.open_area_sets", allowed_types=(ElementSet, OrientedSelectionSet) |
| 126 | + ) |
| 127 | + |
| 128 | + elemental_data = elemental_data_property(InterfaceLayerElementalData) |
| 129 | + nodal_data = nodal_data_property(InterfaceLayerNodalData) |
0 commit comments