Coverage for src/beamme/core/conf.py: 98%
58 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +0000
1# The MIT License (MIT)
2#
3# Copyright (c) 2018-2026 BeamMe Authors
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
13# all 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
21# THE SOFTWARE.
22"""This module defines a global object that manages all kind of stuff."""
24from enum import Enum as _Enum
25from enum import auto as _auto
27# Lines to be added to each created input file
28INPUT_FILE_HEADER = [
29 "-" * 40,
30 "This input file was created with BeamMe.",
31 "Copyright (c) 2018-2026 BeamMe Authors",
32 "https://beamme-py.github.io/beamme/",
33 "-" * 40,
34]
37class Geometry(_Enum):
38 """Enum for geometry types."""
40 point = _auto()
41 line = _auto()
42 surface = _auto()
43 volume = _auto()
46class BoundaryCondition(_Enum):
47 """Enum for boundary condition types."""
49 dirichlet = _auto()
50 neumann = _auto()
51 locsys = _auto()
52 moment_euler_bernoulli = _auto()
53 beam_to_beam_contact = _auto()
54 beam_to_solid_volume_meshtying = _auto()
55 beam_to_solid_surface_meshtying = _auto()
56 beam_to_solid_surface_contact = _auto()
57 point_coupling = _auto()
58 point_coupling_penalty = _auto()
59 point_coupling_indirect = _auto()
61 def is_point_coupling_pairwise(self) -> bool:
62 """Check whether the point coupling condition should be applied pairwise.
64 Returns:
65 bool: True if the coupling should be applied individually between pairs of nodes,
66 rather than to the entire geometry set as a whole.
67 """
68 if self == self.point_coupling:
69 return False
70 elif self == self.point_coupling_penalty:
71 return True
72 else:
73 raise TypeError(f"Got unexpected coupling type: {self}")
76class CouplingDofType(_Enum):
77 """Enum for coupling types."""
79 fix = _auto()
80 joint = _auto()
83class ElementType(_Enum):
84 """Enum for element types."""
86 beam = _auto()
87 nurbs = _auto()
88 solid = _auto()
89 space_time_beam = _auto()
92class NodeType(_Enum):
93 """Enum for node types."""
95 node = _auto()
96 cosserat = _auto()
97 control_point = _auto()
98 space_time_cosserat = _auto()
101class DoubleNodes(_Enum):
102 """Enum for handing double nodes in Neumann conditions."""
104 remove = _auto()
105 keep = _auto()
108class BeamMe(object):
109 """A global object that stores options for the whole BeamMe application."""
111 def __init__(self):
112 self.set_default_values()
113 self.geo = Geometry
114 self.bc = BoundaryCondition
115 self.coupling_dof = CouplingDofType
116 self.element_type = ElementType
117 self.node_type = NodeType
118 self.double_nodes = DoubleNodes
120 def set_default_values(self):
121 """Set the configuration to the default values."""
122 # Set the epsilons for comparison of different types of values.
123 self.eps_quaternion = 1e-10
124 self.eps_knot_vector = 1e-10
125 self.eps_parameter_space = 1e-10
126 self.eps_pos = 1e-10
128 # Allow the rotation of beams when connected and the triads do not
129 # match.
130 self.allow_beam_rotation = True
133bme = BeamMe()