diff --git a/src/meshpy/four_c/input_file.py b/src/meshpy/four_c/input_file.py index 778ce706..6aa5e662 100644 --- a/src/meshpy/four_c/input_file.py +++ b/src/meshpy/four_c/input_file.py @@ -102,7 +102,7 @@ def _get_yaml_geometry_sets( return geometry_sets_in_this_section -class InputFile(_Mesh): +class InputFile: """An item that represents a complete 4C input file.""" # 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): into this input file. """ - super().__init__() + self.mesh = _Mesh() # Everything that is not a full MeshPy object is stored here, e.g., parameters # and imported nodes/elements/materials/... @@ -311,7 +311,7 @@ def add(self, *args, **kwargs): self.add_section(args[0], **kwargs) return - super().add(*args, **kwargs) + self.mesh.add(*args, **kwargs) def add_section(self, section, *, option_overwrite=False): """Add a section to the object. @@ -428,7 +428,7 @@ def get_dict_to_dump( # Perform some checks on the mesh. if _mpy.check_overlapping_elements: - self.check_overlapping_elements() + self.mesh.check_overlapping_elements() # The base dictionary we use here is the one that already exists. # This one might already contain mesh sections - stored in pure @@ -578,27 +578,27 @@ def _dump_mesh_items(yaml_dict, section_name, data_list): item_dict_list.extend(item.dump_to_list()) # Add sets from couplings and boundary conditions to a temp container. - self.unlink_nodes() + self.mesh.unlink_nodes() start_indices_geometry_set = _get_global_start_geometry_set(yaml_dict) - mesh_sets = self.get_unique_geometry_sets( + mesh_sets = self.mesh.get_unique_geometry_sets( geometry_set_start_indices=start_indices_geometry_set ) # Assign global indices to all entries. start_index_nodes = _get_global_start_node(yaml_dict) - _set_i_global(self.nodes, start_index=start_index_nodes) + _set_i_global(self.mesh.nodes, start_index=start_index_nodes) start_index_elements = _get_global_start_element(yaml_dict) - _set_i_global_elements(self.elements, start_index=start_index_elements) + _set_i_global_elements(self.mesh.elements, start_index=start_index_elements) start_index_materials = _get_global_start_material(yaml_dict) - _set_i_global(self.materials, start_index=start_index_materials) + _set_i_global(self.mesh.materials, start_index=start_index_materials) start_index_functions = _get_global_start_function(yaml_dict) - _set_i_global(self.functions, start_index=start_index_functions) + _set_i_global(self.mesh.functions, start_index=start_index_functions) # Add material data to the input file. - _dump_mesh_items(yaml_dict, "MATERIALS", self.materials) + _dump_mesh_items(yaml_dict, "MATERIALS", self.mesh.materials) # Add the functions. - for function in self.functions: + for function in self.mesh.functions: yaml_dict[f"FUNCT{function.i_global}"] = function.dump_to_list() # If there are couplings in the mesh, set the link between the nodes @@ -606,8 +606,8 @@ def _dump_mesh_items(yaml_dict, section_name, data_list): # depending on the type of the connected beam element. def get_number_of_coupling_conditions(key): """Return the number of coupling conditions in the mesh.""" - if (key, _mpy.geo.point) in self.boundary_conditions.keys(): - return len(self.boundary_conditions[key, _mpy.geo.point]) + if (key, _mpy.geo.point) in self.mesh.boundary_conditions.keys(): + return len(self.mesh.boundary_conditions[key, _mpy.geo.point]) else: return 0 @@ -616,10 +616,10 @@ def get_number_of_coupling_conditions(key): + get_number_of_coupling_conditions(_mpy.bc.point_coupling_penalty) > 0 ): - self.set_node_links() + self.mesh.set_node_links() # Add the boundary conditions. - for (bc_key, geom_key), bc_list in self.boundary_conditions.items(): + for (bc_key, geom_key), bc_list in self.mesh.boundary_conditions.items(): if len(bc_list) > 0: section_name = ( bc_key @@ -629,7 +629,7 @@ def get_number_of_coupling_conditions(key): _dump_mesh_items(yaml_dict, section_name, bc_list) # Add additional element sections, e.g., for NURBS knot vectors. - for element in self.elements: + for element in self.mesh.elements: element.dump_element_specific_section(yaml_dict) # Add the geometry sets. @@ -638,8 +638,8 @@ def get_number_of_coupling_conditions(key): _dump_mesh_items(yaml_dict, self.geometry_set_names[geom_key], item) # Add the nodes and elements. - _dump_mesh_items(yaml_dict, "NODE COORDS", self.nodes) - _dump_mesh_items(yaml_dict, "STRUCTURE ELEMENTS", self.elements) + _dump_mesh_items(yaml_dict, "NODE COORDS", self.mesh.nodes) + _dump_mesh_items(yaml_dict, "STRUCTURE ELEMENTS", self.mesh.elements) return yaml_dict diff --git a/tests/test_cosserat_curve.py b/tests/test_cosserat_curve.py index 88ea5bd3..93116ce9 100644 --- a/tests/test_cosserat_curve.py +++ b/tests/test_cosserat_curve.py @@ -60,7 +60,8 @@ def create_beam_solid_input_file(get_corresponding_reference_file_path): yaml_file=get_corresponding_reference_file_path( reference_file_base_name="test_cosserat_curve_mesh" ) - ) + ).mesh + create_beam_mesh_helix( mesh, Beam3rHerm2Line3, diff --git a/tests/test_meshpy.py b/tests/test_meshpy.py index 0067d467..ff474a77 100644 --- a/tests/test_meshpy.py +++ b/tests/test_meshpy.py @@ -112,10 +112,10 @@ def test_meshpy_rotations(assert_results_equal): """Check if the Mesh function rotation gives the same results as rotating each node it self.""" - mesh_1 = InputFile() + mesh_1 = Mesh() create_test_mesh(mesh_1) - mesh_2 = InputFile() + mesh_2 = Mesh() create_test_mesh(mesh_2) # Set the seed for the pseudo random numbers