Skip to content

Commit e897894

Browse files
Merge pull request #315 from davidrudlstorfer/purge_mentioning_of_dat
Purge all mentionings of dat
2 parents a5d319a + 2122148 commit e897894

20 files changed

+93
-100
lines changed

src/meshpy/abaqus/beam.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import numpy as _np
2626

2727
from meshpy.core.element_beam import Beam as _Beam
28-
from meshpy.core.material import MaterialBeam as _MaterialBeam
2928

3029

3130
def generate_abaqus_beam(beam_type: str):
@@ -69,19 +68,3 @@ def generate_abaqus_beam(beam_type: str):
6968
"n_dim": n_dim,
7069
},
7170
)
72-
73-
74-
class AbaqusBeamMaterial(_MaterialBeam):
75-
"""A class representing an Abaqus beam material."""
76-
77-
def __init__(self, name: str):
78-
"""Initialize the material. For now it is only supported to state the
79-
name of the resulting element set here. The material and cross-section
80-
lines in the input file have to be defined manually.
81-
82-
Args
83-
----
84-
name: str
85-
Name of the material, this will be the name of the resulting element set
86-
"""
87-
super().__init__(data=name)

src/meshpy/abaqus/input_file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def get_material_lines(self):
308308
# Create the element sets for the different materials.
309309
input_file_lines = []
310310
for material, elements in materials.items():
311-
material_name = material.get_dat_lines()[0]
311+
material_name = material.dump_to_list()[0]
312312
input_file_lines.extend(get_set_lines("Elset", elements, material_name))
313313
return input_file_lines
314314

src/meshpy/abaqus/material.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# The MIT License (MIT)
2+
#
3+
# Copyright (c) 2018-2025 MeshPy 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 functions to create Abaqus beam element classes to be
23+
used with MeshPy."""
24+
25+
from meshpy.core.material import MaterialBeam as _MaterialBeam
26+
27+
28+
class AbaqusBeamMaterial(_MaterialBeam):
29+
"""A class representing an Abaqus beam material."""
30+
31+
def __init__(self, name: str):
32+
"""Initialize the material. For now it is only supported to state the
33+
name of the resulting element set here. The material and cross-section
34+
lines in the input file have to be defined manually.
35+
36+
Args
37+
----
38+
name: str
39+
Name of the material, this will be the name of the resulting element set
40+
"""
41+
super().__init__(data=name)
42+
43+
def dump_to_list(self):
44+
"""Return a list with the (single) item representing this material."""
45+
return [self.data]

src/meshpy/core/base_mesh_item.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,12 @@ def __init__(self, data=None, comments=None):
4747
else:
4848
self.comments = comments
4949

50-
def get_dat_lines(self):
51-
"""Return the content of this object as a list.
52-
53-
If comments exist, also add those.
54-
"""
55-
56-
# Get data of object.
57-
data = self._get_dat()
58-
if isinstance(data, str):
59-
data = [data]
60-
61-
# Get comments if given.
62-
return_list = []
63-
if not len(self.comments) == 0:
64-
return_list.extend(self.comments)
65-
66-
# Return final list.
67-
return_list.extend(data)
68-
return return_list
69-
70-
def _get_dat(self):
71-
"""Return the content of this object as either a list or a str."""
72-
return self.data
73-
7450

7551
class BaseMeshItemFull(BaseMeshItem):
7652
"""Base class for all objects that are related to a mesh and are fully
7753
created in MeshPy."""
7854

7955

8056
class BaseMeshItemString(BaseMeshItem):
81-
"""Base class for all objects that are imported from a dat file as a plain
82-
string."""
57+
"""Base class for all objects that are imported from an input file as a
58+
plain string."""

src/meshpy/core/boundary_condition.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ def __init__(self, geometry_set, bc_type=None, **kwargs):
3737
3838
Args
3939
----
40-
geometry_set: GeometrySet, int
41-
Geometry that this boundary condition acts on. An integer can be
42-
given, in the case a dat file is imported. This integer is only
43-
temporary and will be replaced with the GeometrySet object.
40+
geometry_set: GeometrySet
41+
Geometry that this boundary condition acts on.
4442
bc_type: mpy.bc
4543
Type of the boundary condition.
4644
"""

src/meshpy/core/conf.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def set_default_values(self):
151151
self.git_date = None
152152

153153
# Precision for floats in output.
154-
self.dat_precision = "{:.12g}"
154+
self.output_precision = "{:.12g}"
155155

156156
# Set the epsilons for comparison of different types of values.
157157
self.eps_quaternion = 1e-10
@@ -166,10 +166,7 @@ def set_default_values(self):
166166
self.geometric_search_max_nodes_brute_force = 1000
167167
self.geometric_search_binning_n_bin = 10
168168

169-
# Values for the formatting of the input file.
170-
self.dat_len_section = 80
171-
172-
# Import meshes as pure dat or import the geometry.
169+
# Import meshes as pure dict or import the geometry.
173170
self.import_mesh_full = False
174171

175172
# Number of digits for node set output (this will be set in the
@@ -179,7 +176,7 @@ def set_default_values(self):
179176
self.vtk_nan_int = -1
180177
self.vtk_nan_float = 0.0
181178

182-
# Check for overlapping elements when creating a dat file.
179+
# Check for overlapping elements when creating an input file.
183180
self.check_overlapping_elements = True
184181

185182
# Lines to be added to each created input file

src/meshpy/core/coupling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ def __init__(
6060
physical position.
6161
check_at_init: bool
6262
If the previous check should be performed at initialization. This is required
63-
when importing a coupling from a dat file as the nodes themselves are not build
63+
when importing a coupling from an input file as the nodes themselves are not build
6464
up when the coupling is read.
6565
"""
6666

6767
if isinstance(geometry, int):
68-
# This is the case if the boundary condition is read from an existing dat file
68+
# This is the case if the boundary condition is read from an existing input file
6969
pass
7070
elif isinstance(geometry, _GeometrySetBase):
7171
pass

src/meshpy/core/node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def dump_to_list(self):
122122
coordinate_string = " ".join(
123123
[
124124
(
125-
_mpy.dat_precision.format(component + 0)
125+
_mpy.output_precision.format(component + 0)
126126
if _np.abs(component) >= _mpy.eps_pos
127127
else "0"
128128
)
@@ -186,7 +186,7 @@ def dump_to_list(self):
186186
coordinate_string = " ".join(
187187
[
188188
(
189-
_mpy.dat_precision.format(component + 0)
189+
_mpy.output_precision.format(component + 0)
190190
if _np.abs(component) >= _mpy.eps_pos
191191
else "0"
192192
)

src/meshpy/core/rotation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,15 +324,15 @@ def __eq__(self, other):
324324
return object.__eq__(self, other)
325325

326326
def get_dat(self):
327-
"""Return a string with the triad components for the .dat line."""
327+
"""Return a string with the triad components for the input line."""
328328

329329
rotation_vector = self.get_rotation_vector()
330330

331331
# The zeros are added to avoid negative zeros in the input file.
332332
return " ".join(
333333
[
334334
(
335-
_mpy.dat_precision.format(component + 0)
335+
_mpy.output_precision.format(component + 0)
336336
if _np.abs(component) >= _mpy.eps_quaternion
337337
else "0"
338338
)

src/meshpy/four_c/input_file.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def __init__(self, *, yaml_file: _Optional[_Path] = None, cubit=None):
192192
if yaml_file is not None:
193193
self.read_yaml(yaml_file)
194194

195+
# TODO fix once cubit is converted to YAML
195196
# if cubit is not None:
196197
# self._read_dat_lines(cubit.get_dat_lines())
197198

@@ -385,7 +386,6 @@ def get_dict_to_dump(
385386
self,
386387
*,
387388
header: bool = True,
388-
dat_header: bool = True,
389389
add_script_to_header: bool = True,
390390
check_nox: bool = True,
391391
):
@@ -395,11 +395,9 @@ def get_dict_to_dump(
395395
Args:
396396
header:
397397
If the header should be exported to the input file files.
398-
dat_header:
399-
If header lines from the imported dat file should be exported.
400-
append_script_to_header:
398+
add_script_to_header:
401399
If true, a copy of the executing script will be added to the input
402-
file. This is only in affect when dat_header is True.
400+
file. This is only in affect when header is True.
403401
check_nox:
404402
If this is true, an error will be thrown if no nox file is set.
405403
"""
@@ -422,8 +420,6 @@ def get_dict_to_dump(
422420
# if header:
423421
# header_text, end_text = self._get_header(add_script_to_header)
424422
# lines.append(header_text)
425-
# if dat_header:
426-
# lines.extend(self.dat_header)
427423

428424
# Check if a file has to be created for the NOX xml information.
429425
if self.nox_xml is not None:
@@ -613,9 +609,7 @@ def get_number_of_coupling_conditions(key):
613609
)
614610
_dump_mesh_items(yaml_dict, section_name, bc_list)
615611

616-
# Add additional element sections (e.g. STRUCTURE KNOTVECTORS)
617-
# We only need to to this on the "real" elements as the imported ones already have their
618-
# dat sections.
612+
# Add additional element sections, e.g., for NURBS knot vectors.
619613
for element in self.elements:
620614
element.dump_element_specific_section(yaml_dict)
621615

@@ -707,7 +701,7 @@ def get_git_data(repo):
707701
f"// git date: {cubitpy_git_date}\n"
708702
)
709703

710-
string_line = "// " + "".join(["-" for _i in range(_mpy.dat_len_section - 3)])
704+
string_line = "// " + "".join(["-"] * 80)
711705

712706
# If needed, append the contents of the script.
713707
if add_script:

src/meshpy/four_c/run_four_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def run_four_c(
5454
Args
5555
----
5656
input_file: str
57-
Path to the dat file on the filesystem
57+
Path to the input file on the filesystem
5858
output_dir: str
5959
Directory where the simulation should be performed (will be created if
6060
it does not exist)

tests/conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ def _get_corresponding_reference_file_path(
231231
reference_file_base_name: Basename of reference file, if none is
232232
provided the current test name is utilized
233233
additional_identifier: Additional identifier for reference file, by default none
234-
extension: Extension of reference file, by default ".dat"
234+
extension: Extension of reference file, by default ".4C.yaml"
235235
236236
Returns:
237237
Path to reference file.
@@ -305,9 +305,6 @@ def _assert_results_equal(
305305
elif reference.suffix in [".vtk", ".vtu"]:
306306
compare_vtk_files(reference, result, rtol, atol)
307307
return
308-
elif reference.suffix == ".dat":
309-
# Do nothing here as the mechanism below will compare the dat files.
310-
pass
311308
else:
312309
raise NotImplementedError(
313310
f"Comparison is not yet implemented for {reference.suffix} files."

tests/test_abaqus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@
2424
import numpy as np
2525
import pytest
2626

27-
from meshpy.abaqus.beam import AbaqusBeamMaterial, generate_abaqus_beam
27+
from meshpy.abaqus.beam import generate_abaqus_beam
2828
from meshpy.abaqus.input_file import AbaqusBeamNormalDefinition, AbaqusInputFile
29+
from meshpy.abaqus.material import AbaqusBeamMaterial
2930
from meshpy.core.geometry_set import GeometrySet
3031
from meshpy.core.mesh import Mesh
3132
from meshpy.core.rotation import Rotation

tests/test_create_cubit_input.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ def test_create_cubit_input_tutorial(
6464
"""Test the creation of the solid input file for the tutorial."""
6565

6666
# Create the tube for the tutorial.
67-
result_path = tmp_path / "tutorial.dat"
67+
result_path = tmp_path / "tutorial.4C.yaml"
6868
create_tube_tutorial(result_path)
6969

7070
tutorial_path = (
71-
reference_file_directory.parents[1] / "tutorial" / "4C_input_solid_tutorial.dat"
71+
reference_file_directory.parents[1]
72+
/ "tutorial"
73+
/ "4C_input_solid_tutorial.4C.yaml"
7274
)
7375
assert_results_equal(tutorial_path, result_path, **ASSERT_RESULTS_EQUAL_TOL)
7476

tests/test_four_c.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def test_four_c_material_numbering(
5252
assert_results_equal, get_corresponding_reference_file_path
5353
):
5454
"""Test that materials can be added as strings to an input file (as is done
55-
when importing dat files) and that the numbering with other added materials
56-
does not lead to materials with double IDs."""
55+
when importing input files) and that the numbering with other added
56+
materials does not lead to materials with double IDs."""
5757

5858
input_file = InputFile()
5959
input_file.add(
@@ -331,9 +331,9 @@ def test_four_c_locsys_condition(
331331
):
332332
"""Test case for point locsys condition for beams.
333333
334-
The testcase is adapted from to beam3r_herm2line3_static_locsys.dat.
335-
However it has a simpler material, and an additional line locsys
336-
condition.
334+
The testcase is adapted from to
335+
beam3r_herm2line3_static_locsys.4C.yaml. However it has a simpler
336+
material, and an additional line locsys condition.
337337
"""
338338

339339
# Create the input file with function and material.

tests/test_four_c_simulation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ def test_four_c_simulation_honeycomb_sphere(
143143
):
144144
"""Create the same honeycomb mesh as defined in 4C/tests/input_files/beam3r
145145
_herm2lin3_static_point_coupling_BTSPH_contact_stent_honeycomb_stretch_r01_
146-
circ10.dat The honeycomb beam is in contact with a rigid sphere, the sphere
147-
is moved compared to the original test file, since there are some problems
148-
with the contact convergence.
146+
circ10.4C.yaml The honeycomb beam is in contact with a rigid sphere, the
147+
sphere is moved compared to the original test file, since there are some
148+
problems with the contact convergence.
149149
150150
The sphere is imported as an existing mesh.
151151
"""

0 commit comments

Comments
 (0)