Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions doc/source/api/tree_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ ACP objects
Stackup
ElementSet
EdgeSet
CADGeometry
CADComponent
VirtualGeometry
Rosette
LookUpTable1D
LookUpTable1DColumn
Expand All @@ -21,6 +24,8 @@ ACP objects
CylindricalSelectionRule
SphericalSelectionRule
TubeSelectionRule
CutoffSelectionRule
GeometricalSelectionRule
VariableOffsetSelectionRule
BooleanSelectionRule
OrientedSelectionSet
Expand Down
168 changes: 84 additions & 84 deletions poetry.lock

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/ansys/acp/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
from ._tree_objects import (
AnalysisPly,
BooleanSelectionRule,
CADComponent,
CADGeometry,
CutoffSelectionRule,
CylindricalSelectionRule,
EdgeSet,
EdgeSetType,
ElementalDataType,
ElementSet,
Fabric,
FabricWithAngle,
GeometricalSelectionRule,
Lamina,
LinkedSelectionRule,
LookUpTable1D,
Expand All @@ -34,6 +38,7 @@
TubeSelectionRule,
UnitSystemType,
VariableOffsetSelectionRule,
VirtualGeometry,
)

__version__ = importlib.metadata.version(__name__.replace(".", "-"))
Expand All @@ -50,9 +55,13 @@
"Material",
"Fabric",
"SubLaminate",
"Lamina",
"ElementSet",
"EdgeSet",
"EdgeSetType",
"CADGeometry",
"CADComponent",
"VirtualGeometry",
"Rosette",
"LookUpTable1D",
"LookUpTable1DColumn",
Expand All @@ -62,6 +71,8 @@
"CylindricalSelectionRule",
"SphericalSelectionRule",
"TubeSelectionRule",
"CutoffSelectionRule",
"GeometricalSelectionRule",
"VariableOffsetSelectionRule",
"BooleanSelectionRule",
"LinkedSelectionRule",
Expand All @@ -72,6 +83,7 @@
"AnalysisPly",
"UnitSystemType",
"Stackup",
"Sensor",
"FabricWithAngle",
"ElementalDataType",
"NodalDataType",
Expand Down
10 changes: 10 additions & 0 deletions src/ansys/acp/core/_tree_objects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from .analysis_ply import AnalysisPly
from .boolean_selection_rule import BooleanSelectionRule
from .cad_component import CADComponent
from .cad_geometry import CADGeometry
from .cutoff_selection_rule import CutoffSelectionRule
from .cylindrical_selection_rule import CylindricalSelectionRule
from .edge_set import EdgeSet
from .element_set import ElementSet
from .enums import EdgeSetType, ElementalDataType, NodalDataType, UnitSystemType
from .fabric import Fabric
from .geometrical_selection_rule import GeometricalSelectionRule
from .linked_selection_rule import LinkedSelectionRule
from .lookup_table_1d import LookUpTable1D
from .lookup_table_1d_column import LookUpTable1DColumn
Expand All @@ -24,6 +28,7 @@
from .sublaminate import Lamina, SubLaminate
from .tube_selection_rule import TubeSelectionRule
from .variable_offset_selection_rule import VariableOffsetSelectionRule
from .virtual_geometry import VirtualGeometry

__all__ = [
"Model",
Expand All @@ -35,6 +40,9 @@
"Lamina",
"ElementSet",
"EdgeSet",
"CADGeometry",
"CADComponent",
"VirtualGeometry",
"Rosette",
"LookUpTable1D",
"LookUpTable1DColumn",
Expand All @@ -45,6 +53,8 @@
"CylindricalSelectionRule",
"SphericalSelectionRule",
"TubeSelectionRule",
"CutoffSelectionRule",
"GeometricalSelectionRule",
"VariableOffsetSelectionRule",
"BooleanSelectionRule",
"LinkedSelectionRule",
Expand Down
129 changes: 129 additions & 0 deletions src/ansys/acp/core/_tree_objects/cutoff_selection_rule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
from __future__ import annotations

from collections.abc import Iterable
import dataclasses

import numpy as np
import numpy.typing as npt

from ansys.api.acp.v0 import cutoff_selection_rule_pb2, cutoff_selection_rule_pb2_grpc

from ._grpc_helpers.property_helper import (
grpc_data_property,
grpc_data_property_read_only,
grpc_link_property,
mark_grpc_properties,
)
from ._mesh_data import ElementalData, NodalData, elemental_data_property, nodal_data_property
from .base import CreatableTreeObject, IdTreeObject
from .edge_set import EdgeSet
from .enums import (
CutoffRuleType,
PlyCutoffType,
cutoff_rule_type_from_pb,
cutoff_rule_type_to_pb,
ply_cutoff_type_from_pb,
ply_cutoff_type_to_pb,
status_type_from_pb,
)
from .object_registry import register
from .virtual_geometry import VirtualGeometry

__all__ = [
"CutoffSelectionRule",
"CutoffSelectionRuleElementalData",
"CutoffSelectionRuleNodalData",
]


@dataclasses.dataclass
class CutoffSelectionRuleElementalData(ElementalData):
"""Represents elemental data for a Cutoff Selection Rule."""

normal: npt.NDArray[np.float64]


@dataclasses.dataclass
class CutoffSelectionRuleNodalData(NodalData):
"""Represents nodal data for a Cutoff Selection Rule."""


@mark_grpc_properties
@register
class CutoffSelectionRule(CreatableTreeObject, IdTreeObject):
"""Instantiate a Cutoff Selection Rule.

Parameters
----------
name :
Name of the Cutoff Selection Rule.
cutoff_rule_type :
Determines if the cut-off is defined by a geometry or by a tapering edge.
cutoff_geometry :
Geometry used to define the cut-off. Only applies if
``cutoff_rule_type`` is GEOMETRY.
taper_edge_set :
Edge used to define the cut-off. Only applies if
``cutoff_rule_type`` is :attr:`.CutoffRuleType.TAPER`.
offset :
Moves the cutting plane along the out-of-plane direction. Always measured
from the reference surface.
angle :
Defines the angle between the cutting plane and the reference surface.
ply_cutoff_type :
Either the complete production ply is cut-off
(:attr:`PlyCutoffType.PRODUCTION_PLY_CUTOFF`) or individual analysis plies
(:attr:`PlyCutoffType.ANALYSIS_PLY_CUTOFF`).
ply_tapering :
Whether the tapering of analysis plies is enabled.
"""

__slots__: Iterable[str] = tuple()

_COLLECTION_LABEL = "cutoff_selection_rules"
OBJECT_INFO_TYPE = cutoff_selection_rule_pb2.ObjectInfo
CREATE_REQUEST_TYPE = cutoff_selection_rule_pb2.CreateRequest

def __init__(
self,
name: str = "CutoffSelectionrule",
cutoff_rule_type: CutoffRuleType = CutoffRuleType.GEOMETRY,
cutoff_geometry: VirtualGeometry | None = None,
taper_edge_set: EdgeSet | None = None,
offset: float = 0.0,
angle: float = 0.0,
ply_cutoff_type: PlyCutoffType = PlyCutoffType.PRODUCTION_PLY_CUTOFF,
ply_tapering: bool = False,
):
super().__init__(name=name)
self.cutoff_rule_type = cutoff_rule_type
self.cutoff_geometry = cutoff_geometry
self.taper_edge_set = taper_edge_set
self.offset = offset
self.angle = angle
self.ply_cutoff_type = ply_cutoff_type
self.ply_tapering = ply_tapering

def _create_stub(self) -> cutoff_selection_rule_pb2_grpc.ObjectServiceStub:
return cutoff_selection_rule_pb2_grpc.ObjectServiceStub(self._channel)

status = grpc_data_property_read_only("properties.status", from_protobuf=status_type_from_pb)

cutoff_rule_type = grpc_data_property(
"properties.cutoff_rule_type",
from_protobuf=cutoff_rule_type_from_pb,
to_protobuf=cutoff_rule_type_to_pb,
)
cutoff_geometry = grpc_link_property("properties.cutoff_geometry")
taper_edge_set = grpc_link_property("properties.taper_edge_set")
offset = grpc_data_property("properties.offset")
angle = grpc_data_property("properties.angle")
ply_cutoff_type = grpc_data_property(
"properties.ply_cutoff_type",
from_protobuf=ply_cutoff_type_from_pb,
to_protobuf=ply_cutoff_type_to_pb,
)
ply_tapering = grpc_data_property("properties.ply_tapering")

elemental_data = elemental_data_property(CutoffSelectionRuleElementalData)
nodal_data = nodal_data_property(CutoffSelectionRuleNodalData)
22 changes: 22 additions & 0 deletions src/ansys/acp/core/_tree_objects/enums.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from ansys.api.acp.v0 import (
cut_off_material_pb2,
cutoff_selection_rule_pb2,
drop_off_material_pb2,
edge_set_pb2,
enum_types_pb2,
geometrical_selection_rule_pb2,
lookup_table_3d_pb2,
lookup_table_column_type_pb2,
mesh_query_pb2,
Expand Down Expand Up @@ -169,3 +171,23 @@
virtual_geometry_dimension_to_pb,
virtual_geometry_dimension_from_pb,
) = wrap_to_string_enum("VirtualGeometryDimension", virtual_geometry_pb2.Dimension, module=__name__)

(
CutoffRuleType,
cutoff_rule_type_to_pb,
cutoff_rule_type_from_pb,
) = wrap_to_string_enum("CutoffRuleType", cutoff_selection_rule_pb2.CutoffRuleType, module=__name__)

(
PlyCutoffType,
ply_cutoff_type_to_pb,
ply_cutoff_type_from_pb,
) = wrap_to_string_enum("PlyCutoffType", cutoff_selection_rule_pb2.PlyCutoffType, module=__name__)

(
GeometricalRuleType,
geometrical_rule_type_to_pb,
geometrical_rule_type_from_pb,
) = wrap_to_string_enum(
"GeometricalRuleType", geometrical_selection_rule_pb2.GeometricalRuleType, module=__name__
)
Loading