Coverage for src / beamme / core / conf.py: 98%
46 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-21 12:57 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-11-21 12:57 +0000
1# The MIT License (MIT)
2#
3# Copyright (c) 2018-2025 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-2025 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
63 pairwise.
65 Returns:
66 bool: True if the coupling should be applied individually between pairs of nodes,
67 rather than to the entire geometry set as a whole.
68 """
69 if self == self.point_coupling:
70 return False
71 elif self == self.point_coupling_penalty:
72 return True
73 else:
74 raise TypeError(f"Got unexpected coupling type: {self}")
77class CouplingDofType(_Enum):
78 """Enum for coupling types."""
80 fix = _auto()
81 joint = _auto()
84class DoubleNodes(_Enum):
85 """Enum for handing double nodes in Neumann conditions."""
87 remove = _auto()
88 keep = _auto()
91class BeamMe(object):
92 """A global object that stores options for the whole BeamMe application."""
94 def __init__(self):
95 self.set_default_values()
97 # Geometry types.
98 self.geo = Geometry
100 # Boundary conditions types.
101 self.bc = BoundaryCondition
103 # Coupling types.
104 self.coupling_dof = CouplingDofType
106 # Handling of multiple nodes in Neumann bcs.
107 self.double_nodes = DoubleNodes
109 def set_default_values(self):
110 """Set the configuration to the default values."""
112 # Set the epsilons for comparison of different types of values.
113 self.eps_quaternion = 1e-10
114 self.eps_pos = 1e-10
115 self.eps_knot_vector = 1e-10
117 # Allow the rotation of beams when connected and the triads do not
118 # match.
119 self.allow_beam_rotation = True
121 # Check for overlapping elements when creating an input file.
122 self.check_overlapping_elements = True
125bme = BeamMe()