Skip to content

Commit ff2e7e4

Browse files
Review suggestions
1 parent 542b410 commit ff2e7e4

8 files changed

+47
-53
lines changed

src/meshpy/core/conf.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,11 @@ def set_default_values(self):
181181

182182
# Lines to be added to each created input file
183183
self.input_file_meshpy_header = [
184-
"-" * 77,
184+
"-" * 40,
185185
"This input file was created with MeshPy.",
186-
"Copyright (c) 2018-2025",
187-
" Ivo Steinbrecher",
188-
" Institute for Mathematics and Computer-Based Simulation",
189-
" Universitaet der Bundeswehr Muenchen",
190-
" https://www.unibw.de/imcs-en",
191-
"-" * 77,
186+
"Copyright (c) 2018-2025 MeshPy Authors",
187+
"https://imcs-compsim.github.io/meshpy/",
188+
"-" * 40,
192189
]
193190

194191

src/meshpy/four_c/input_file.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ def write_input_file(
351351
file_path: _Path,
352352
*,
353353
nox_xml_file: _Optional[str] = None,
354-
add_application_script: _Optional[bool] = False,
354+
add_header_default: bool = True,
355+
add_footer_application_script: bool = True,
355356
**kwargs,
356357
):
357358
"""Write the input file to disk.
@@ -362,10 +363,11 @@ def write_input_file(
362363
nox_xml_file:
363364
(optional) If this argument is given, the xml file will be created
364365
with this name, in the same directory as the input file.
365-
add_application_script:
366-
(optional) If this argument is set to True, the script that
367-
created this input file will be added to the input file as a
368-
comment.
366+
add_header_default:
367+
Prepend the default MeshPy header comment to the input file.
368+
add_footer_application_script:
369+
Append the application script which creates the input files as a
370+
comment at the end of the input file.
369371
"""
370372

371373
# Check if a xml file needs to be written.
@@ -385,6 +387,12 @@ def write_input_file(
385387
xml_file.write(self.nox_xml)
386388

387389
with open(file_path, "w") as input_file:
390+
# write MeshPy header
391+
if add_header_default:
392+
input_file.writelines(
393+
"# " + line + "\n" for line in _mpy.input_file_meshpy_header
394+
)
395+
388396
_yaml.dump(
389397
self.get_dict_to_dump(**kwargs),
390398
input_file,
@@ -393,7 +401,7 @@ def write_input_file(
393401
)
394402

395403
# Add the application script to the input file.
396-
if add_application_script:
404+
if add_footer_application_script:
397405
application_path = _Path(_sys.argv[0]).resolve()
398406
application_script_lines = self._get_application_script(
399407
application_path
@@ -403,14 +411,14 @@ def write_input_file(
403411
def get_dict_to_dump(
404412
self,
405413
*,
406-
information_header: bool = False,
414+
add_header_information: bool = True,
407415
check_nox: bool = True,
408416
):
409417
"""Return the dictionary representation of this input file for dumping
410418
to a yaml file.
411419
412420
Args:
413-
information_header:
421+
add_header_information:
414422
If the information header should be exported to the input file
415423
Contains creation date, git details of MeshPy, CubitPy and
416424
original application which created the input file if available.
@@ -429,7 +437,7 @@ def get_dict_to_dump(
429437
yaml_dict = _copy.deepcopy(self.sections)
430438

431439
# Add information header to the input file
432-
if information_header:
440+
if add_header_information:
433441
yaml_dict["TITLE"] = self._get_header()
434442

435443
# Check if a file has to be created for the NOX xml information.
@@ -688,10 +696,12 @@ def _get_git_data(repo_path: _Path) -> _Tuple[_Optional[str], _Optional[str]]:
688696
application_path.parent
689697
)
690698
if application_git_sha is not None and application_git_date is not None:
691-
header["MeshPy"]["Application"] = {
692-
"git_sha": application_git_sha,
693-
"git_date": application_git_date,
694-
}
699+
header["MeshPy"]["Application"].update(
700+
{
701+
"git_sha": application_git_sha,
702+
"git_date": application_git_date,
703+
}
704+
)
695705

696706
# MeshPy information
697707
meshpy_git_sha, meshpy_git_date = _get_git_data(

tests/conftest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def _assert_results_equal(
278278
result: Union[Path, str, dict, InputFile],
279279
rtol: Optional[float] = None,
280280
atol: Optional[float] = None,
281+
input_file_kwargs: dict = {"add_header_information": False, "check_nox": False},
281282
**kwargs,
282283
) -> None:
283284
"""Comparison between reference and result with relative or absolute
@@ -290,6 +291,8 @@ def _assert_results_equal(
290291
result: The result data.
291292
rtol: The relative tolerance.
292293
atol: The absolute tolerance.
294+
input_file_kwargs: Dictionary which contains the settings when
295+
dumping the input file.
293296
"""
294297

295298
# Per default we do a string comparison of the objects. Some data types, e.g.,
@@ -341,7 +344,7 @@ def get_dictionary(data) -> dict:
341344

342345
return yaml.safe_load(
343346
yaml.dump(
344-
data.get_dict_to_dump(check_nox=False),
347+
data.get_dict_to_dump(**input_file_kwargs),
345348
Dumper=_MeshPyDumper,
346349
width=float("inf"),
347350
)

tests/reference-files/test_abaqus_frame_normal.inp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
** -----------------------------------------------------------------------------
1+
** ----------------------------------------
22
** This input file was created with MeshPy.
3-
** Copyright (c) 2018-2025
4-
** Ivo Steinbrecher
5-
** Institute for Mathematics and Computer-Based Simulation
6-
** Universitaet der Bundeswehr Muenchen
7-
** https://www.unibw.de/imcs-en
8-
** -----------------------------------------------------------------------------
3+
** Copyright (c) 2018-2025 MeshPy Authors
4+
** https://imcs-compsim.github.io/meshpy/
5+
** ----------------------------------------
96
*Node
107
1, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00
118
2, 2.50000000000000e-01, 0.00000000000000e+00, 0.00000000000000e+00

tests/reference-files/test_abaqus_frame_normal_and_extra_node.inp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
** -----------------------------------------------------------------------------
1+
** ----------------------------------------
22
** This input file was created with MeshPy.
3-
** Copyright (c) 2018-2025
4-
** Ivo Steinbrecher
5-
** Institute for Mathematics and Computer-Based Simulation
6-
** Universitaet der Bundeswehr Muenchen
7-
** https://www.unibw.de/imcs-en
8-
** -----------------------------------------------------------------------------
3+
** Copyright (c) 2018-2025 MeshPy Authors
4+
** https://imcs-compsim.github.io/meshpy/
5+
** ----------------------------------------
96
*Node
107
1, 0.00000000000000e+00, 0.00000000000000e+00, 0.00000000000000e+00
118
2, 2.50000000000000e-01, 0.00000000000000e+00, 0.00000000000000e+00

tests/reference-files/test_abaqus_helix_normal.inp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
** -----------------------------------------------------------------------------
1+
** ----------------------------------------
22
** This input file was created with MeshPy.
3-
** Copyright (c) 2018-2025
4-
** Ivo Steinbrecher
5-
** Institute for Mathematics and Computer-Based Simulation
6-
** Universitaet der Bundeswehr Muenchen
7-
** https://www.unibw.de/imcs-en
8-
** -----------------------------------------------------------------------------
3+
** Copyright (c) 2018-2025 MeshPy Authors
4+
** https://imcs-compsim.github.io/meshpy/
5+
** ----------------------------------------
96
*Node
107
1, 5.00000000000000e-01, 0.00000000000000e+00, 0.00000000000000e+00
118
2, 4.45503262094184e-01, 2.26995249869773e-01, 5.00000000000000e-02

tests/reference-files/test_abaqus_helix_normal_and_extra_node.inp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
** -----------------------------------------------------------------------------
1+
** ----------------------------------------
22
** This input file was created with MeshPy.
3-
** Copyright (c) 2018-2025
4-
** Ivo Steinbrecher
5-
** Institute for Mathematics and Computer-Based Simulation
6-
** Universitaet der Bundeswehr Muenchen
7-
** https://www.unibw.de/imcs-en
8-
** -----------------------------------------------------------------------------
3+
** Copyright (c) 2018-2025 MeshPy Authors
4+
** https://imcs-compsim.github.io/meshpy/
5+
** ----------------------------------------
96
*Node
107
1, 5.00000000000000e-01, 0.00000000000000e+00, 0.00000000000000e+00
118
2, 4.45503262094184e-01, 2.26995249869773e-01, 5.00000000000000e-02

tests/test_meshpy.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,10 +1256,6 @@ def test_meshpy_beam_to_solid_conditions(
12561256
assert_results_equal(
12571257
get_corresponding_reference_file_path(additional_identifier=test_type),
12581258
input_file,
1259-
input_file_kwargs={
1260-
"check_nox": False,
1261-
"header": False,
1262-
},
12631259
)
12641260

12651261

0 commit comments

Comments
 (0)