Coverage for src/beamme/four_c/element_solid.py: 86%
50 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-07-28 15:20 +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."""
24import copy as _copy
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)
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.
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.
60 Returns:
61 A type that defines a solid element block for 4C solid elements.
62 """
63 if element_technology is None:
64 element_technology = {}
65 else:
66 element_technology = _copy.deepcopy(element_technology)
68 base_type: type[_Element]
70 match solid_type:
71 case _ElementType.nurbs:
72 match n_nodes:
73 case 9:
74 base_type = _NURBSSurface
75 case 27:
76 base_type = _NURBSVolume
77 case _:
78 raise ValueError(
79 f"Unsupported number of nodes {n_nodes} for NURBS element!"
80 )
81 case _ElementType.solid:
82 match n_nodes:
83 case 1:
84 base_type = _VolumePoint
85 case 8:
86 base_type = _VolumeHEX8
87 case 20:
88 base_type = _VolumeHEX20
89 case 27:
90 base_type = _VolumeHEX27
91 case 4:
92 base_type = _VolumeTET4
93 case 10:
94 base_type = _VolumeTET10
95 case 6:
96 base_type = _VolumeWEDGE6
97 case _:
98 raise ValueError(
99 f"Unsupported number of nodes {n_nodes} for solid element!"
100 )
101 case _:
102 raise ValueError(f"Unsupported solid type {solid_type}!")
104 four_c_cell = _INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"][
105 solid_type, n_nodes
106 ]
107 data = _FourCElementData(
108 four_c_type=four_c_type,
109 four_c_cell=four_c_cell,
110 element_technology=element_technology,
111 )
112 return type(
113 "FourCSolidElementType",
114 (base_type,),
115 {"element_type": solid_type, "data": data},
116 )