### ===================================================================================================================
### Class definition for MeshElement for the vibration simulation
### ===================================================================================================================
# Copyright ©2026 Haskoning Nederland B.V.
### ===================================================================================================================
### 1. Import modules
### ===================================================================================================================
# General imports
from dataclasses import dataclass
from typing import List
# References for functions and classes in the haskoning_atr_tools package
from haskoning_atr_tools.vibration_contour_plot.mesh.mesh_node import MeshNode
### ===================================================================================================================
### 2. MeshElement class
### ===================================================================================================================
[docs]
@dataclass
class MeshElement:
def __init__(self, id: int, mesh_nodes: List['MeshNode']):
self.id = id
self.mesh_nodes = mesh_nodes
@property
def id(self):
return self.__id
@id.setter
def id(self, new_id: int):
if new_id and not isinstance(new_id, int):
raise ValueError(
f"ERROR: The mesh_element requires an integer for id input argument, provided: {new_id}.")
elif new_id and new_id < 1:
raise ValueError(
f"ERROR: The meshnode requires a positive integer, minimum 1 for id input argument, provided: "
f"{new_id}.")
self.__id = new_id
@property
def mesh_nodes(self):
return self.__mesh_nodes
@mesh_nodes.setter
def mesh_nodes(self, new_mesh_nodes: List[MeshNode]):
if not isinstance(new_mesh_nodes, list) or not all(isinstance(node, MeshNode) for node in new_mesh_nodes):
raise ValueError("ERROR: Input for mesh nodes should be a list of MeshNode objects.")
else:
self.__mesh_nodes = new_mesh_nodes
[docs]
def get_mesh_nodes_ids(self) -> List[int]:
"""Returns a list of IDs of the mesh nodes in this element."""
return [node.id for node in self.mesh_nodes]
### ===================================================================================================================
### 3. End of script
### ===================================================================================================================