Coverage for src/beamme/four_c/element_solid.py: 86%

50 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-08 11:03 +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 file implements solid elements for 4C.""" 

23 

24import copy as _copy 

25 

26from beamme.core.conf import ElementType as _ElementType 

27from beamme.core.element import Element as _Element 

28from beamme.core.element_volume import VolumeHEX8 as _VolumeHEX8 

29from beamme.core.element_volume import VolumeHEX20 as _VolumeHEX20 

30from beamme.core.element_volume import VolumeHEX27 as _VolumeHEX27 

31from beamme.core.element_volume import VolumePoint as _VolumePoint 

32from beamme.core.element_volume import VolumeTET4 as _VolumeTET4 

33from beamme.core.element_volume import VolumeTET10 as _VolumeTET10 

34from beamme.core.element_volume import VolumeWEDGE6 as _VolumeWEDGE6 

35from beamme.core.nurbs_patch import NURBSSurface as _NURBSSurface 

36from beamme.core.nurbs_patch import NURBSVolume as _NURBSVolume 

37from beamme.four_c.element_data import FourCElementData as _FourCElementData 

38from beamme.four_c.input_file_mappings import ( 

39 INPUT_FILE_MAPPINGS as _INPUT_FILE_MAPPINGS, 

40) 

41 

42 

43def get_four_c_solid( 

44 solid_type: _ElementType, 

45 four_c_type: str, 

46 n_nodes: int, 

47 *, 

48 element_technology: dict | None = None, 

49) -> type[_Element]: 

50 """Return a type that defines a solid element block for 4C solid elements. 

51 

52 Args: 

53 solid_type: Type of solid element. Supported values are: 

54 - solid 

55 - nurbs 

56 four_c_type: The 4C type of the solid element. 

57 n_nodes: The number of nodes of the solid element. 

58 element_technology: Dictionary specifying element technologies. Will be deep copied. 

59 

60 Returns: 

61 A type that defines a solid element block for 4C solid elements. 

62 """ 

63 

64 if element_technology is None: 

65 element_technology = {} 

66 else: 

67 element_technology = _copy.deepcopy(element_technology) 

68 

69 base_type: type[_Element] 

70 

71 match solid_type: 

72 case _ElementType.nurbs: 

73 match n_nodes: 

74 case 9: 

75 base_type = _NURBSSurface 

76 case 27: 

77 base_type = _NURBSVolume 

78 case _: 

79 raise ValueError( 

80 f"Unsupported number of nodes {n_nodes} for NURBS element!" 

81 ) 

82 case _ElementType.solid: 

83 match n_nodes: 

84 case 1: 

85 base_type = _VolumePoint 

86 case 8: 

87 base_type = _VolumeHEX8 

88 case 20: 

89 base_type = _VolumeHEX20 

90 case 27: 

91 base_type = _VolumeHEX27 

92 case 4: 

93 base_type = _VolumeTET4 

94 case 10: 

95 base_type = _VolumeTET10 

96 case 6: 

97 base_type = _VolumeWEDGE6 

98 case _: 

99 raise ValueError( 

100 f"Unsupported number of nodes {n_nodes} for solid element!" 

101 ) 

102 case _: 

103 raise ValueError(f"Unsupported solid type {solid_type}!") 

104 

105 four_c_cell = _INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"][ 

106 solid_type, n_nodes 

107 ] 

108 data = _FourCElementData( 

109 four_c_type=four_c_type, 

110 four_c_cell=four_c_cell, 

111 element_technology=element_technology, 

112 ) 

113 return type( 

114 "FourCSolidElementType", 

115 (base_type,), 

116 {"element_type": solid_type, "data": data}, 

117 )