diff --git a/src/vasp/automatedPreprocessing/automated_preprocessing.py b/src/vasp/automatedPreprocessing/automated_preprocessing.py index 58d7d89..1cd4689 100755 --- a/src/vasp/automatedPreprocessing/automated_preprocessing.py +++ b/src/vasp/automatedPreprocessing/automated_preprocessing.py @@ -4,6 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later import sys +import datetime from pathlib import Path import vtk @@ -30,6 +31,21 @@ from vasp.simulations.simulation_common import load_mesh_and_data +def save_command_to_file(file_path): + """ + Save the command-line arguments to a file. + + Args: + file_path (str): Path to the file where the command-line arguments should be saved. + """ + # Join the command-line arguments into a single string + command = ' '.join(sys.argv) + + # Open the file in append mode and write the command + with open(file_path, 'a') as f: + f.write(command + '\n') + + def run_pre_processing(input_model, verbose_print, smoothing_method, smoothing_factor, smoothing_iterations, meshing_method, refine_region, has_multiple_inlets, add_flow_extensions, visualize, config_path, coarsening_factor, inlet_flow_extension_length, outlet_flow_extension_length, @@ -91,6 +107,10 @@ def run_pre_processing(input_model, verbose_print, smoothing_method, smoothing_f dir_path = input_model_path.parent print(f"\n--- Working on case: {case_name} \n") + # Get unique time stamp and save given command to file + time_stamp = datetime.datetime.now().strftime("%Y%m%d%H%M%S") + save_command_to_file(dir_path / f"commands_{time_stamp}.txt") + # Naming conventions base_path = dir_path / case_name file_name_centerlines = base_path.with_name(base_path.name + "_centerlines.vtp")