Coverage for src/beamme/core/conf.py: 98%
45 statements
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-29 11:30 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2025-09-29 11:30 +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()
60 def is_point_coupling_pairwise(self) -> bool:
61 """Check whether the point coupling condition should be applied
62 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 DoubleNodes(_Enum):
84 """Enum for handing double nodes in Neumann conditions."""
86 remove = _auto()
87 keep = _auto()
90class BeamMe(object):
91 """A global object that stores options for the whole BeamMe application."""
93 def __init__(self):
94 self.set_default_values()
96 # Geometry types.
97 self.geo = Geometry
99 # Boundary conditions types.
100 self.bc = BoundaryCondition
102 # Coupling types.
103 self.coupling_dof = CouplingDofType
105 # Handling of multiple nodes in Neumann bcs.
106 self.double_nodes = DoubleNodes
108 def set_default_values(self):
109 """Set the configuration to the default values."""
111 # Set the epsilons for comparison of different types of values.
112 self.eps_quaternion = 1e-10
113 self.eps_pos = 1e-10
114 self.eps_knot_vector = 1e-10
116 # Allow the rotation of beams when connected and the triads do not
117 # match.
118 self.allow_beam_rotation = True
120 # Check for overlapping elements when creating an input file.
121 self.check_overlapping_elements = True
124bme = BeamMe()