Coverage for src/beamme/four_c/input_file_mappings.py: 100%
19 statements
« prev ^ index » next coverage.py v7.14.1, created at 2026-06-08 11:03 +0000
« 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 provides the mappings between BeamMe objects and 4C input
23files."""
25from typing import Any as _Any
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["four_c_cell_to_connectivity_mapping_from_vtk"] = {
88 # Only list the non-standard mappings
89 "LINE3": [0, 2, 1],
90 "LINE4": [0, 3, 1, 2],
91 "LINE5": [0, 4, 1, 2, 3],
92 "HEX20": _MESH_REPRESENTATION_MAPPINGS[
93 "element_type_and_n_nodes_to_connectivity_mapping_beamme_to_vtk"
94 ][(_bme.element_type.solid, 20)],
95 "HEX27": _MESH_REPRESENTATION_MAPPINGS[
96 "element_type_and_n_nodes_to_connectivity_mapping_beamme_to_vtk"
97 ][(_bme.element_type.solid, 27)],
98}
99INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_entry_name"] = {
100 _bme.geo.point: "DNODE",
101 _bme.geo.line: "DLINE",
102 _bme.geo.surface: "DSURFACE",
103 _bme.geo.volume: "DVOL",
104}
105INPUT_FILE_MAPPINGS["boundary_conditions"] = {
106 (_bme.bc.dirichlet, _bme.geo.point): "DESIGN POINT DIRICH CONDITIONS",
107 (_bme.bc.dirichlet, _bme.geo.line): "DESIGN LINE DIRICH CONDITIONS",
108 (_bme.bc.dirichlet, _bme.geo.surface): "DESIGN SURF DIRICH CONDITIONS",
109 (_bme.bc.dirichlet, _bme.geo.volume): "DESIGN VOL DIRICH CONDITIONS",
110 (_bme.bc.locsys, _bme.geo.point): "DESIGN POINT LOCSYS CONDITIONS",
111 (_bme.bc.locsys, _bme.geo.line): "DESIGN LINE LOCSYS CONDITIONS",
112 (_bme.bc.locsys, _bme.geo.surface): "DESIGN SURF LOCSYS CONDITIONS",
113 (_bme.bc.locsys, _bme.geo.volume): "DESIGN VOL LOCSYS CONDITIONS",
114 (_bme.bc.neumann, _bme.geo.point): "DESIGN POINT NEUMANN CONDITIONS",
115 (_bme.bc.neumann, _bme.geo.line): "DESIGN LINE NEUMANN CONDITIONS",
116 (_bme.bc.neumann, _bme.geo.surface): "DESIGN SURF NEUMANN CONDITIONS",
117 (_bme.bc.neumann, _bme.geo.volume): "DESIGN VOL NEUMANN CONDITIONS",
118 (
119 _bme.bc.moment_euler_bernoulli,
120 _bme.geo.point,
121 ): "DESIGN POINT MOMENT EB CONDITIONS",
122 (
123 _bme.bc.beam_to_solid_volume_meshtying,
124 _bme.geo.line,
125 ): "BEAM INTERACTION/BEAM TO SOLID VOLUME MESHTYING LINE",
126 (
127 _bme.bc.beam_to_solid_volume_meshtying,
128 _bme.geo.volume,
129 ): "BEAM INTERACTION/BEAM TO SOLID VOLUME MESHTYING VOLUME",
130 (
131 _bme.bc.beam_to_solid_surface_meshtying,
132 _bme.geo.line,
133 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE MESHTYING LINE",
134 (
135 _bme.bc.beam_to_solid_surface_meshtying,
136 _bme.geo.surface,
137 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE MESHTYING SURFACE",
138 (
139 _bme.bc.beam_to_solid_surface_contact,
140 _bme.geo.line,
141 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE CONTACT LINE",
142 (
143 _bme.bc.beam_to_solid_surface_contact,
144 _bme.geo.surface,
145 ): "BEAM INTERACTION/BEAM TO SOLID SURFACE CONTACT SURFACE",
146 (_bme.bc.point_coupling, _bme.geo.point): "DESIGN POINT COUPLING CONDITIONS",
147 (
148 _bme.bc.beam_to_beam_contact,
149 _bme.geo.line,
150 ): "BEAM INTERACTION/BEAM TO BEAM CONTACT CONDITIONS",
151 (
152 _bme.bc.point_coupling_penalty,
153 _bme.geo.point,
154 ): "DESIGN POINT PENALTY COUPLING CONDITIONS",
155 (
156 _bme.bc.point_coupling_indirect,
157 _bme.geo.line,
158 ): "BEAM INTERACTION/BEAM TO BEAM POINT COUPLING CONDITIONS",
159 (
160 "DESIGN SURF MORTAR CONTACT CONDITIONS 3D",
161 _bme.geo.surface,
162 ): "DESIGN SURF MORTAR CONTACT CONDITIONS 3D",
163}
164INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_condition_name"] = {
165 _bme.geo.point: "DNODE-NODE TOPOLOGY",
166 _bme.geo.line: "DLINE-NODE TOPOLOGY",
167 _bme.geo.surface: "DSURF-NODE TOPOLOGY",
168 _bme.geo.volume: "DVOL-NODE TOPOLOGY",
169}
170INPUT_FILE_MAPPINGS["geometry_sets_condition_to_geometry_name"] = (
171 _create_inverse_mapping(
172 INPUT_FILE_MAPPINGS["geometry_sets_geometry_to_condition_name"]
173 )
174)
175INPUT_FILE_MAPPINGS["four_c_node_type_to_beamme_node_type"] = {
176 "NODE": _bme.node_type.node,
177 "CP": _bme.node_type.control_point,
178}