Coverage for src/beamme/core/conf.py: 99%

71 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-30 18:48 +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.""" 

23 

24from enum import Enum as _Enum 

25from enum import auto as _auto 

26 

27 

28class Geometry(_Enum): 

29 """Enum for geometry types.""" 

30 

31 point = _auto() 

32 line = _auto() 

33 surface = _auto() 

34 volume = _auto() 

35 

36 

37class BoundaryCondition(_Enum): 

38 """Enum for boundary condition types.""" 

39 

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() 

50 

51 def is_point_coupling_pairwise(self) -> bool: 

52 """Check whether the point coupling condition should be applied 

53 pairwise. 

54 

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}") 

65 

66 

67class BeamType(_Enum): 

68 """Enum for beam types.""" 

69 

70 reissner = _auto() 

71 kirchhoff = _auto() 

72 euler_bernoulli = _auto() 

73 

74 

75class CouplingDofType(_Enum): 

76 """Enum for coupling types.""" 

77 

78 fix = _auto() 

79 joint = _auto() 

80 

81 

82class DoubleNodes(_Enum): 

83 """Enum for handing double nodes in Neumann conditions.""" 

84 

85 remove = _auto() 

86 keep = _auto() 

87 

88 

89class GeometricSearchAlgorithm(_Enum): 

90 """Enum for VTK value types.""" 

91 

92 automatic = _auto() 

93 brute_force_cython = _auto() 

94 binning_cython = _auto() 

95 boundary_volume_hierarchy_arborx = _auto() 

96 

97 

98class VTKGeometry(_Enum): 

99 """Enum for VTK geometry types (for now cells and points).""" 

100 

101 point = _auto() 

102 cell = _auto() 

103 

104 

105class VTKTensor(_Enum): 

106 """Enum for VTK tensor types.""" 

107 

108 scalar = _auto() 

109 vector = _auto() 

110 

111 

112class VTKType(_Enum): 

113 """Enum for VTK value types.""" 

114 

115 int = _auto() 

116 float = _auto() 

117 

118 

119class BeamMe(object): 

120 """A global object that stores options for the whole BeamMe application.""" 

121 

122 def __init__(self): 

123 self.set_default_values() 

124 

125 # Geometry types. 

126 self.geo = Geometry 

127 

128 # Boundary conditions types. 

129 self.bc = BoundaryCondition 

130 

131 # Beam types. 

132 self.beam = BeamType 

133 

134 # Coupling types. 

135 self.coupling_dof = CouplingDofType 

136 

137 # Handling of multiple nodes in Neumann bcs. 

138 self.double_nodes = DoubleNodes 

139 

140 # Geometric search options. 

141 self.geometric_search_algorithm = GeometricSearchAlgorithm 

142 

143 # VTK types. 

144 # Geometry types, cell or point. 

145 self.vtk_geo = VTKGeometry 

146 # Tensor types, scalar or vector. 

147 self.vtk_tensor = VTKTensor 

148 # Data types, integer or float. 

149 self.vtk_type = VTKType 

150 

151 def set_default_values(self): 

152 """Set the configuration to the default values.""" 

153 

154 # Set the epsilons for comparison of different types of values. 

155 self.eps_quaternion = 1e-10 

156 self.eps_pos = 1e-10 

157 self.eps_knot_vector = 1e-10 

158 

159 # Allow the rotation of beams when connected and the triads do not 

160 # match. 

161 self.allow_beam_rotation = True 

162 

163 # Number of digits for node set output (this will be set in the 

164 # Mesh.get_unique_geometry_sets() method. 

165 self.vtk_node_set_format = "{:05}" 

166 # Nan values for vtk data, since we currently can't set nan explicitly. 

167 self.vtk_nan_int = -1 

168 self.vtk_nan_float = 0.0 

169 

170 # Check for overlapping elements when creating an input file. 

171 self.check_overlapping_elements = True 

172 

173 # Lines to be added to each created input file 

174 self.input_file_header = [ 

175 "-" * 40, 

176 "This input file was created with BeamMe.", 

177 "Copyright (c) 2018-2025 BeamMe Authors", 

178 "https://beamme-py.github.io/beamme/", 

179 "-" * 40, 

180 ] 

181 

182 

183mpy = BeamMe()