Skip to content
Open
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
9 changes: 4 additions & 5 deletions src/beamme/core/base_mesh_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""This module implements the class that will be used as the base for all items
that are in a mesh."""

from typing import Optional as _Optional
that are in a mesh, except for nodes and elements."""


class BaseMeshItem:
"""Base class for all objects that are related to a mesh."""
"""Base class for boundary conditions, functions, geometry sets and
materials."""

def __init__(self, data: _Optional[dict] = None):
def __init__(self, data: dict | None = None):
"""Create the base object.

Args:
Expand Down
17 changes: 9 additions & 8 deletions src/beamme/core/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ class CouplingDofType(_Enum):
joint = _auto()


class ElementType(_Enum):
"""Enum for element types."""

beam = _auto()
nurbs = _auto()
solid = _auto()


class DoubleNodes(_Enum):
"""Enum for handing double nodes in Neumann conditions."""

Expand All @@ -93,17 +101,10 @@ class BeamMe(object):

def __init__(self):
self.set_default_values()

# Geometry types.
self.geo = Geometry

# Boundary conditions types.
self.bc = BoundaryCondition

# Coupling types.
self.coupling_dof = CouplingDofType

# Handling of multiple nodes in Neumann bcs.
self.element_type = ElementType
self.double_nodes = DoubleNodes

def set_default_values(self):
Expand Down
9 changes: 4 additions & 5 deletions src/beamme/core/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@
# THE SOFTWARE.
"""This module implements the class that represents one element in the Mesh."""

from beamme.core.base_mesh_item import BaseMeshItem as _BaseMeshItem


class Element(_BaseMeshItem):
class Element:
"""A base class for an FEM element in the mesh."""

def __init__(self, nodes=None, material=None, **kwargs):
super().__init__(**kwargs)
def __init__(self, nodes=None, material=None):
# Global index of this item in a mesh.
self.i_global: None | int = None

# List of nodes that are connected to the element.
if nodes is None:
Expand Down
8 changes: 4 additions & 4 deletions src/beamme/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

import numpy as _np

from beamme.core.base_mesh_item import BaseMeshItem as _BaseMeshItem
from beamme.core.rotation import Rotation as _Rotation


class Node(_BaseMeshItem):
class Node:
"""This object represents one node in the mesh."""

def __init__(self, coordinates, *, is_middle_node=False, **kwargs):
super().__init__(**kwargs)
def __init__(self, coordinates, *, is_middle_node=False):
# Global index of this item in a mesh.
self.i_global: None | int = None

# Coordinates of this node.
self.coordinates = _np.array(coordinates, dtype=float)
Expand Down
14 changes: 4 additions & 10 deletions src/beamme/core/nurbs_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@ class NURBSPatch(_Element):
# A list of valid material types for this element
valid_materials = [_MaterialSolidBase]

def __init__(
self,
knot_vectors,
polynomial_orders,
material=None,
nodes=None,
data=None,
):
super().__init__(nodes=nodes, material=material, data=data)
def __init__(self, knot_vectors, polynomial_orders, material=None, nodes=None):
super().__init__(nodes=nodes, material=material)

# Knot vectors
self.knot_vectors = knot_vectors

# Polynomial degrees
self.polynomial_orders = polynomial_orders

# Set numbers for elements
# Global indices
self.i_global_start = None
self.i_nurbs_patch = None

def get_nurbs_dimension(self) -> int:
Expand Down
101 changes: 56 additions & 45 deletions src/beamme/four_c/element_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
"""This file implements beam elements for 4C."""

import warnings as _warnings
from typing import Any as _Any

import numpy as _np

from beamme.core.conf import bme as _bme
from beamme.core.element_beam import Beam as _Beam
from beamme.core.element_beam import Beam2 as _Beam2
from beamme.core.element_beam import generate_beam_class as _generate_beam_class
from beamme.four_c.four_c_types import (
BeamKirchhoffConstraintType as _BeamKirchhoffConstraintType,
Expand All @@ -35,6 +37,9 @@
BeamKirchhoffParametrizationType as _BeamKirchhoffParametrizationType,
)
from beamme.four_c.four_c_types import BeamType as _BeamType
from beamme.four_c.input_file_dump_item import (
get_four_c_legacy_dict as _get_four_c_legacy_dict,
)
from beamme.four_c.input_file_mappings import (
INPUT_FILE_MAPPINGS as _INPUT_FILE_MAPPINGS,
)
Expand All @@ -56,38 +61,35 @@ def dump_four_c_beam_to_list(self) -> dict:
# Check the material.
self._check_material()

# Gather the element data for the input file.
element_data = type(self).four_c_element_data | self.data
element_data["MAT"] = self.material
if type(self).four_c_triads:
element_data["TRIADS"] = [
# Get the legacy dictionary for FourCIPP.
node_ordering = _INPUT_FILE_MAPPINGS["beam_n_nodes_to_four_c_ordering"][
len(self.nodes)
]
legacy_dict = _get_four_c_legacy_dict(self, node_ordering=node_ordering)
dump_triads = {
_BeamType.reissner: True,
_BeamType.kirchhoff: True,
_BeamType.euler_bernoulli: False,
}
if dump_triads[type(self).beam_type]:
legacy_dict["data"]["TRIADS"] = [
item
for i in _INPUT_FILE_MAPPINGS["n_nodes_to_node_ordering"][len(self.nodes)]
for i in node_ordering
for item in self.nodes[i].rotation.get_rotation_vector()
]

return {
"id": self.i_global + 1,
"cell": {
"type": _INPUT_FILE_MAPPINGS["n_nodes_to_cell_type"][len(self.nodes)],
"connectivity": [
self.nodes[i]
for i in _INPUT_FILE_MAPPINGS["n_nodes_to_node_ordering"][
len(self.nodes)
]
],
},
"data": element_data,
}
return legacy_dict


def get_four_c_reissner_beam(n_nodes: int, is_hermite_centerline: bool) -> type[_Beam]:
"""Return a Simo-Reissner beam for 4C."""

four_c_element_data = {
"type": _INPUT_FILE_MAPPINGS["beam_types"][_BeamType.reissner],
"HERMITE_CENTERLINE": is_hermite_centerline,
}
four_c_type = _INPUT_FILE_MAPPINGS["beam_type_to_four_c_type"][_BeamType.reissner]
four_c_cell = _INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"][
_bme.element_type.beam, n_nodes
]
element_technology = {"HERMITE_CENTERLINE": is_hermite_centerline}

if is_hermite_centerline:
coupling_fix_dict = {"NUMDOF": 9, "ONOFF": [1, 1, 1, 1, 1, 1, 0, 0, 0]}
coupling_joint_dict = {"NUMDOF": 9, "ONOFF": [1, 1, 1, 0, 0, 0, 0, 0, 0]}
Expand All @@ -99,9 +101,9 @@ def get_four_c_reissner_beam(n_nodes: int, is_hermite_centerline: bool) -> type[
"BeamFourCSimoReissner",
(_generate_beam_class(n_nodes),),
{
"four_c_beam_type": _BeamType.reissner,
"four_c_triads": True,
"four_c_element_data": four_c_element_data,
"element_type": _bme.element_type.beam,
"beam_type": _BeamType.reissner,
"data": {four_c_type: {four_c_cell: element_technology}},
"valid_materials": [_MaterialReissner, _MaterialReissnerElastoplastic],
"coupling_fix_dict": coupling_fix_dict,
"coupling_joint_dict": coupling_joint_dict,
Expand All @@ -117,31 +119,36 @@ def get_four_c_kirchhoff_beam(
) -> type[_Beam]:
"""Return a Kirchhoff-Love beam for 4C."""

# Set the parameters for this beam.
four_c_element_data = {
"type": _INPUT_FILE_MAPPINGS["beam_types"][_BeamType.kirchhoff],
"CONSTRAINT": constraint.name,
"PARAMETRIZATION": parametrization.name,
"USE_FAD": is_fad,
}

# Show warning when not using rotvec.
if not parametrization == _BeamKirchhoffParametrizationType.rot:
_warnings.warn(
"Use tangent based parametrization with caution, especially when "
" applying the boundary conditions and couplings."
)

n_nodes = 3
four_c_type = _INPUT_FILE_MAPPINGS["beam_type_to_four_c_type"][_BeamType.kirchhoff]
four_c_cell = _INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"][
_bme.element_type.beam, n_nodes
]

element_technology = {
"CONSTRAINT": constraint.name,
"PARAMETRIZATION": parametrization.name,
"USE_FAD": is_fad,
}

coupling_fix_dict = {"NUMDOF": 7, "ONOFF": [1, 1, 1, 1, 1, 1, 0]}
coupling_joint_dict = {"NUMDOF": 7, "ONOFF": [1, 1, 1, 0, 0, 0, 0]}

return type(
"BeamFourCKirchhoffLove",
(_generate_beam_class(3),),
(_generate_beam_class(n_nodes),),
{
"four_c_beam_type": _BeamType.kirchhoff,
"four_c_triads": True,
"four_c_element_data": four_c_element_data,
"element_type": _bme.element_type.beam,
"beam_type": _BeamType.kirchhoff,
"kirchhoff_parametrization": parametrization,
"data": {four_c_type: {four_c_cell: element_technology}},
"valid_materials": [_MaterialKirchhoff],
"coupling_fix_dict": coupling_fix_dict,
"coupling_joint_dict": coupling_joint_dict,
Expand All @@ -150,13 +157,17 @@ def get_four_c_kirchhoff_beam(
)


class BeamFourCEulerBernoulli(_generate_beam_class(2)): # type: ignore[misc]
class BeamFourCEulerBernoulli(_Beam2):
"""Represents a Euler Bernoulli beam element."""

four_c_beam_type = _BeamType.euler_bernoulli
four_c_triads = False
four_c_element_data = {
"type": _INPUT_FILE_MAPPINGS["beam_types"][_BeamType.euler_bernoulli]
element_type = _bme.element_type.beam
beam_type = _BeamType.euler_bernoulli
data: dict[str, dict[str, _Any]] = {
_INPUT_FILE_MAPPINGS["beam_type_to_four_c_type"][_BeamType.euler_bernoulli]: {
_INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"][
_bme.element_type.beam, len(_Beam2.nodes_create)
]: {}
}
}

valid_materials = [_MaterialEulerBernoulli]
Expand All @@ -171,8 +182,8 @@ def dump_to_list(self):
# the start point to the end point.
if not self.nodes[0].rotation == self.nodes[1].rotation:
raise ValueError(
"The two nodal rotations in Euler Bernoulli beams must be the same, i.e. the beam "
"has to be straight!"
"The two nodal rotations in Euler Bernoulli beams must be the same,"
"i.e., the beam has to be straight!"
)
direction = self.nodes[1].coordinates - self.nodes[0].coordinates
t1 = self.nodes[0].rotation * [1, 0, 0]
Expand Down
Loading
Loading