Skip to content

Commit 272d02f

Browse files
Remove inheritance of InputFile on Mesh
1 parent 4cf5402 commit 272d02f

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/meshpy/four_c/input_file.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _get_yaml_geometry_sets(
102102
return geometry_sets_in_this_section
103103

104104

105-
class InputFile(_Mesh):
105+
class InputFile:
106106
"""An item that represents a complete 4C input file."""
107107

108108
# Define the names of sections and boundary conditions in the input file.
@@ -180,7 +180,7 @@ def __init__(self, *, yaml_file: _Optional[_Path] = None, cubit=None):
180180
into this input file.
181181
"""
182182

183-
super().__init__()
183+
self.mesh = _Mesh()
184184

185185
# Everything that is not a full MeshPy object is stored here, e.g., parameters
186186
# and imported nodes/elements/materials/...
@@ -311,7 +311,7 @@ def add(self, *args, **kwargs):
311311
self.add_section(args[0], **kwargs)
312312
return
313313

314-
super().add(*args, **kwargs)
314+
self.mesh.add(*args, **kwargs)
315315

316316
def add_section(self, section, *, option_overwrite=False):
317317
"""Add a section to the object.
@@ -428,7 +428,7 @@ def get_dict_to_dump(
428428

429429
# Perform some checks on the mesh.
430430
if _mpy.check_overlapping_elements:
431-
self.check_overlapping_elements()
431+
self.mesh.check_overlapping_elements()
432432

433433
# The base dictionary we use here is the one that already exists.
434434
# This one might already contain mesh sections - stored in pure
@@ -578,36 +578,36 @@ def _dump_mesh_items(yaml_dict, section_name, data_list):
578578
item_dict_list.extend(item.dump_to_list())
579579

580580
# Add sets from couplings and boundary conditions to a temp container.
581-
self.unlink_nodes()
581+
self.mesh.unlink_nodes()
582582
start_indices_geometry_set = _get_global_start_geometry_set(yaml_dict)
583-
mesh_sets = self.get_unique_geometry_sets(
583+
mesh_sets = self.mesh.get_unique_geometry_sets(
584584
geometry_set_start_indices=start_indices_geometry_set
585585
)
586586

587587
# Assign global indices to all entries.
588588
start_index_nodes = _get_global_start_node(yaml_dict)
589-
_set_i_global(self.nodes, start_index=start_index_nodes)
589+
_set_i_global(self.mesh.nodes, start_index=start_index_nodes)
590590
start_index_elements = _get_global_start_element(yaml_dict)
591-
_set_i_global_elements(self.elements, start_index=start_index_elements)
591+
_set_i_global_elements(self.mesh.elements, start_index=start_index_elements)
592592
start_index_materials = _get_global_start_material(yaml_dict)
593-
_set_i_global(self.materials, start_index=start_index_materials)
593+
_set_i_global(self.mesh.materials, start_index=start_index_materials)
594594
start_index_functions = _get_global_start_function(yaml_dict)
595-
_set_i_global(self.functions, start_index=start_index_functions)
595+
_set_i_global(self.mesh.functions, start_index=start_index_functions)
596596

597597
# Add material data to the input file.
598-
_dump_mesh_items(yaml_dict, "MATERIALS", self.materials)
598+
_dump_mesh_items(yaml_dict, "MATERIALS", self.mesh.materials)
599599

600600
# Add the functions.
601-
for function in self.functions:
601+
for function in self.mesh.functions:
602602
yaml_dict[f"FUNCT{function.i_global}"] = function.dump_to_list()
603603

604604
# If there are couplings in the mesh, set the link between the nodes
605605
# and elements, so the couplings can decide which DOFs they couple,
606606
# depending on the type of the connected beam element.
607607
def get_number_of_coupling_conditions(key):
608608
"""Return the number of coupling conditions in the mesh."""
609-
if (key, _mpy.geo.point) in self.boundary_conditions.keys():
610-
return len(self.boundary_conditions[key, _mpy.geo.point])
609+
if (key, _mpy.geo.point) in self.mesh.boundary_conditions.keys():
610+
return len(self.mesh.boundary_conditions[key, _mpy.geo.point])
611611
else:
612612
return 0
613613

@@ -616,10 +616,10 @@ def get_number_of_coupling_conditions(key):
616616
+ get_number_of_coupling_conditions(_mpy.bc.point_coupling_penalty)
617617
> 0
618618
):
619-
self.set_node_links()
619+
self.mesh.set_node_links()
620620

621621
# Add the boundary conditions.
622-
for (bc_key, geom_key), bc_list in self.boundary_conditions.items():
622+
for (bc_key, geom_key), bc_list in self.mesh.boundary_conditions.items():
623623
if len(bc_list) > 0:
624624
section_name = (
625625
bc_key
@@ -629,7 +629,7 @@ def get_number_of_coupling_conditions(key):
629629
_dump_mesh_items(yaml_dict, section_name, bc_list)
630630

631631
# Add additional element sections, e.g., for NURBS knot vectors.
632-
for element in self.elements:
632+
for element in self.mesh.elements:
633633
element.dump_element_specific_section(yaml_dict)
634634

635635
# Add the geometry sets.
@@ -638,8 +638,8 @@ def get_number_of_coupling_conditions(key):
638638
_dump_mesh_items(yaml_dict, self.geometry_set_names[geom_key], item)
639639

640640
# Add the nodes and elements.
641-
_dump_mesh_items(yaml_dict, "NODE COORDS", self.nodes)
642-
_dump_mesh_items(yaml_dict, "STRUCTURE ELEMENTS", self.elements)
641+
_dump_mesh_items(yaml_dict, "NODE COORDS", self.mesh.nodes)
642+
_dump_mesh_items(yaml_dict, "STRUCTURE ELEMENTS", self.mesh.elements)
643643

644644
return yaml_dict
645645

tests/test_cosserat_curve.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ def create_beam_solid_input_file(get_corresponding_reference_file_path):
6060
yaml_file=get_corresponding_reference_file_path(
6161
reference_file_base_name="test_cosserat_curve_mesh"
6262
)
63-
)
63+
).mesh
64+
6465
create_beam_mesh_helix(
6566
mesh,
6667
Beam3rHerm2Line3,

tests/test_meshpy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ def test_meshpy_rotations(assert_results_equal):
112112
"""Check if the Mesh function rotation gives the same results as rotating
113113
each node it self."""
114114

115-
mesh_1 = InputFile()
115+
mesh_1 = Mesh()
116116
create_test_mesh(mesh_1)
117117

118-
mesh_2 = InputFile()
118+
mesh_2 = Mesh()
119119
create_test_mesh(mesh_2)
120120

121121
# Set the seed for the pseudo random numbers

0 commit comments

Comments
 (0)