Coverage for src/beamme/core/conf.py: 98%
66 statements
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-11 12:17 +0000
« prev ^ index » next coverage.py v7.10.3, created at 2025-08-11 12:17 +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
28class Geometry(_Enum):
29 """Enum for geometry types."""
31 point = _auto()
32 line = _auto()
33 surface = _auto()
34 volume = _auto()
37class BoundaryCondition(_Enum):
38 """Enum for boundary condition types."""
40 dirichlet = _auto()
41 neumann = _auto()
42 locsys = _auto()
43 moment_euler_bernoulli = _auto()
44 beam_to_beam_contact = _auto()
45 beam_to_solid_volume_meshtying = _auto()
46 beam_to_solid_surface_meshtying = _auto()
47 beam_to_solid_surface_contact = _auto()
48 point_coupling = _auto()
49 point_coupling_penalty = _auto()
51 def is_point_coupling_pairwise(self) -> bool:
52 """Check whether the point coupling condition should be applied
53 pairwise.
55 Returns:
56 bool: True if the coupling should be applied individually between pairs of nodes,
57 rather than to the entire geometry set as a whole.
58 """
59 if self == self.point_coupling:
60 return False
61 elif self == self.point_coupling_penalty:
62 return True
63 else:
64 raise TypeError(f"Got unexpected coupling type: {self}")
67class CouplingDofType(_Enum):
68 """Enum for coupling types."""
70 fix = _auto()
71 joint = _auto()
74class DoubleNodes(_Enum):
75 """Enum for handing double nodes in Neumann conditions."""
77 remove = _auto()
78 keep = _auto()
81class GeometricSearchAlgorithm(_Enum):
82 """Enum for VTK value types."""
84 automatic = _auto()
85 brute_force_cython = _auto()
86 binning_cython = _auto()
87 boundary_volume_hierarchy_arborx = _auto()
90class VTKGeometry(_Enum):
91 """Enum for VTK geometry types (for now cells and points)."""
93 point = _auto()
94 cell = _auto()
97class VTKTensor(_Enum):
98 """Enum for VTK tensor types."""
100 scalar = _auto()
101 vector = _auto()
104class VTKType(_Enum):
105 """Enum for VTK value types."""
107 int = _auto()
108 float = _auto()
111class BeamMe(object):
112 """A global object that stores options for the whole BeamMe application."""
114 def __init__(self):
115 self.set_default_values()
117 # Geometry types.
118 self.geo = Geometry
120 # Boundary conditions types.
121 self.bc = BoundaryCondition
123 # Coupling types.
124 self.coupling_dof = CouplingDofType
126 # Handling of multiple nodes in Neumann bcs.
127 self.double_nodes = DoubleNodes
129 # Geometric search options.
130 self.geometric_search_algorithm = GeometricSearchAlgorithm
132 # VTK types.
133 # Geometry types, cell or point.
134 self.vtk_geo = VTKGeometry
135 # Tensor types, scalar or vector.
136 self.vtk_tensor = VTKTensor
137 # Data types, integer or float.
138 self.vtk_type = VTKType
140 def set_default_values(self):
141 """Set the configuration to the default values."""
143 # Set the epsilons for comparison of different types of values.
144 self.eps_quaternion = 1e-10
145 self.eps_pos = 1e-10
146 self.eps_knot_vector = 1e-10
148 # Allow the rotation of beams when connected and the triads do not
149 # match.
150 self.allow_beam_rotation = True
152 # Number of digits for node set output (this will be set in the
153 # Mesh.get_unique_geometry_sets() method.
154 self.vtk_node_set_format = "{:05}"
155 # Nan values for vtk data, since we currently can't set nan explicitly.
156 self.vtk_nan_int = -1
157 self.vtk_nan_float = 0.0
159 # Check for overlapping elements when creating an input file.
160 self.check_overlapping_elements = True
162 # Lines to be added to each created input file
163 self.input_file_header = [
164 "-" * 40,
165 "This input file was created with BeamMe.",
166 "Copyright (c) 2018-2025 BeamMe Authors",
167 "https://beamme-py.github.io/beamme/",
168 "-" * 40,
169 ]
172bme = BeamMe()