Coverage for src/beamme/four_c/input_file_mappings.py: 100%
21 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 provides the mappings between BeamMe objects and 4C input files."""
24from typing import Any as _Any
26import numpy as _np
27import pyvista as _pv
29from beamme.core.conf import bme as _bme
30from beamme.core.mesh_representation import (
31 MESH_REPRESENTATION_MAPPINGS as _MESH_REPRESENTATION_MAPPINGS,
32)
33from beamme.four_c.four_c_types import BeamType as _BeamType
34from beamme.utils.data_structures import (
35 create_inverse_mapping as _create_inverse_mapping,
36)
38INPUT_FILE_MAPPINGS: dict[str, _Any] = {}
39INPUT_FILE_MAPPINGS["four_c_type_to_four_c_type"] = {
40 _BeamType.reissner: "BEAM3R",
41 _BeamType.kirchhoff: "BEAM3K",
42 _BeamType.euler_bernoulli: "BEAM3EB",
43}
44INPUT_FILE_MAPPINGS["four_c_type_to_requires_triads"] = {
45 "BEAM3R": True,
46 "BEAM3K": True,
47 "BEAM3EB": False,
48}
49INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"] = {
50 (_bme.element_type.beam, 2): "LINE2",
51 (_bme.element_type.beam, 3): "LINE3",
52 (_bme.element_type.beam, 4): "LINE4",
53 (_bme.element_type.beam, 5): "LINE5",
54 (_bme.element_type.nurbs, 9): "NURBS9",
55 (_bme.element_type.nurbs, 27): "NURBS27",
56 (_bme.element_type.solid, 8): "HEX8",
57 (_bme.element_type.solid, 20): "HEX20",
58 (_bme.element_type.solid, 27): "HEX27",
59 (_bme.element_type.solid, 4): "TET4",
60 (_bme.element_type.solid, 10): "TET10",
61 (_bme.element_type.solid, 6): "WEDGE6",
62 (_bme.element_type.solid, 1): "POINT1",
63}
64INPUT_FILE_MAPPINGS["four_c_cell_to_element_type_and_n_nodes"] = (
65 _create_inverse_mapping(
66 INPUT_FILE_MAPPINGS["element_type_and_n_nodes_to_four_c_cell"]
67 )
68)
69INPUT_FILE_MAPPINGS["four_c_cell_to_vtk_cell_type"] = {
70 "POINT1": _pv.CellType.VERTEX,
71 "HEX8": _pv.CellType.HEXAHEDRON,
72 "TET4": _pv.CellType.TETRA,
73 "TET10": _pv.CellType.QUADRATIC_TETRA,
74 "HEX20": _pv.CellType.QUADRATIC_HEXAHEDRON,
75 "HEX27": _pv.CellType.TRIQUADRATIC_HEXAHEDRON,
76 "WEDGE6": _pv.CellType.WEDGE,
77}
78INPUT_FILE_MAPPINGS["four_c_cell_to_vtk_connectivity_mapping"] = {
79 # Only list the non-standard mappings
80 "HEX20": _MESH_REPRESENTATION_MAPPINGS[
81 "element_type_and_n_nodes_to_connectivity_mapping_vtk_to_beamme"
82 ][(_bme.element_type.solid, 20)],
83 "HEX27": _MESH_REPRESENTATION_MAPPINGS[
84 "element_type_and_n_nodes_to_connectivity_mapping_vtk_to_beamme"
85 ][(_bme.element_type.solid, 27)],
86}
87INPUT_FILE_MAPPINGS["beam_vtk_mapping_to_four_c"] = {
88 2: _np.array([0, 1]),
89 3: _np.array([0, 2, 1]),
90 4: _np.array([0, 3, 1, 2]),
91 5: _np.array([0, 4, 1, 2, 3]),
92}
93INPUT_FILE_MAPPINGS["four_c_cell_to_connectivity_mapping_from_vtk"] = {
94 # Only list the non-standard mappings
95 "LINE3": INPUT_FILE_MAPPINGS["beam_vtk_mapping_to_four_c"][3],
96 "LINE4": INPUT_FILE_MAPPINGS["beam_vtk_mapping_to_four_c"][4],
97 "LINE5": INPUT_FILE_MAPPINGS["beam_vtk_mapping_to_four_c"][5],
98 "HEX20": _MESH_REPRESENTATION_MAPPINGS[
99 "element_type_and_n_nodes_to_connectivity_mapping_beamme_to_vtk"
100 ][(_bme.element_type.solid, 20)],
101 "HEX27": _MESH_REPRESENTATION_MAPPINGS[
102 "element_type_and_n_nodes_to_connectivity_mapping_beamme_to_vtk"
103 ][(_bme.element_type.solid, 27)],
104}
105INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_entry_name"] = {
106 _bme.geo.point: "DNODE",
107 _bme.geo.line: "DLINE",
108 _bme.geo.surface: "DSURFACE",
109 _bme.geo.volume: "DVOL",
110}
111INPUT_FILE_MAPPINGS["boundary_conditions"] = {
112 (_bme.bc.dirichlet, _bme.geo.point): "DESIGN POINT DIRICH CONDITIONS",
113 (_bme.bc.dirichlet, _bme.geo.line): "DESIGN LINE DIRICH CONDITIONS",
114 (_bme.bc.dirichlet, _bme.geo.surface): "DESIGN SURF DIRICH CONDITIONS",
115 (_bme.bc.dirichlet, _bme.geo.volume): "DESIGN VOL DIRICH CONDITIONS",
116 (_bme.bc.locsys, _bme.geo.point): "DESIGN POINT LOCSYS CONDITIONS",
117 (_bme.bc.locsys, _bme.geo.line): "DESIGN LINE LOCSYS CONDITIONS",
118 (_bme.bc.locsys, _bme.geo.surface): "DESIGN SURF LOCSYS CONDITIONS",
119 (_bme.bc.locsys, _bme.geo.volume): "DESIGN VOL LOCSYS CONDITIONS",
120 (_bme.bc.neumann, _bme.geo.point): "DESIGN POINT NEUMANN CONDITIONS",
121 (_bme.bc.neumann, _bme.geo.line): "DESIGN LINE NEUMANN CONDITIONS",
122 (_bme.bc.neumann, _bme.geo.surface): "DESIGN SURF NEUMANN CONDITIONS",
123 (_bme.bc.neumann, _bme.geo.volume): "DESIGN VOL NEUMANN CONDITIONS",
124 (
125 _bme.bc.moment_euler_bernoulli,
126 _bme.geo.point,
127 ): "DESIGN POINT MOMENT EB CONDITIONS",
128 (
129 _bme.bc.beam_to_solid_volume_meshtying,
130 _bme.geo.line,
131 ): "BEAM INTERACTION/BEAM TO SOLID VOLUME MESHTYING LINE",
132 (
133 _bme.bc.beam_to_solid_volume_meshtying,
134 _bme.geo.volume,
135 ): "BEAM INTERACTION/BEAM TO SOLID VOLUME MESHTYING VOLUME",
136 (
137 _bme.bc.beam_to_solid_surface_meshtying,
138 _bme.geo.line,
139 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE MESHTYING LINE",
140 (
141 _bme.bc.beam_to_solid_surface_meshtying,
142 _bme.geo.surface,
143 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE MESHTYING SURFACE",
144 (
145 _bme.bc.beam_to_solid_surface_contact,
146 _bme.geo.line,
147 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE CONTACT LINE",
148 (
149 _bme.bc.beam_to_solid_surface_contact,
150 _bme.geo.surface,
151 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE CONTACT SURFACE",
152 (_bme.bc.point_coupling, _bme.geo.point): "DESIGN POINT COUPLING CONDITIONS",
153 (
154 _bme.bc.beam_to_beam_contact,
155 _bme.geo.line,
156 ): "BEAM INTERACTION/BEAM TO BEAM CONTACT CONDITIONS",
157 (
158 _bme.bc.point_coupling_penalty,
159 _bme.geo.point,
160 ): "DESIGN POINT PENALTY COUPLING CONDITIONS",
161 (
162 _bme.bc.point_coupling_indirect,
163 _bme.geo.line,
164 ): "BEAM INTERACTION/BEAM TO BEAM POINT COUPLING CONDITIONS",
165 (
166 "DESIGN SURF MORTAR CONTACT CONDITIONS 3D",
167 _bme.geo.surface,
168 ): "DESIGN SURF MORTAR CONTACT CONDITIONS 3D",
169}
170INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_condition_name"] = {
171 _bme.geo.point: "DNODE-NODE TOPOLOGY",
172 _bme.geo.line: "DLINE-NODE TOPOLOGY",
173 _bme.geo.surface: "DSURF-NODE TOPOLOGY",
174 _bme.geo.volume: "DVOL-NODE TOPOLOGY",
175}
176INPUT_FILE_MAPPINGS["geometry_sets_condition_to_geometry_name"] = (
177 _create_inverse_mapping(
178 INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_condition_name"]
179 )
180)
181INPUT_FILE_MAPPINGS["four_c_node_type_to_beamme_node_type"] = {
182 "NODE": _bme.node_type.node,
183 "CP": _bme.node_type.control_point,
184}