You’ve mastered your domain. Let us handle the infrastructure.
Simulations often generate a large number of temporary or intermediate files that are only useful during runtime. These files can consume significant storage, especially when running multiple or large-scale simulations. To help manage storage usage and reduce associated costs, it is recommended to clean up unnecessary files once a simulation finishes.
All simulators allow the use of the on_finish_cleanup argument to specify
cleanup routines. This argument can be either:
The cleanup routine runs automatically after the simulation ends, making it easy to keep your workspace tidy and efficient.
Some simulators, like OpenFOAM, create per-process folders that are only useful during the run and safe to delete afterward. Here's how to define a cleanup script:
clean.sh
#!/bin/bash
echo "Cleaning up process folders..."
rm -rf processor*
Note: This clean.sh needs to be passed with your
input_files.
And then, in your simulation script:
# Run the simulation with a cleanup script
task = openfoam.run( \
input_dir="/Path/to/your/input_files",
commands=simulation_commands,
on_finish_cleanup="clean.sh",
on=cloud_machine)
If you prefer not to create a separate script, you can pass a list of shell commands directly:
# Run the simulation with inline cleanup commands
task = openfoam.run( \
input_dir="/Path/to/your/input_files",
commands=simulation_commands,
on_finish_cleanup=[
"echo 'Cleaning up temporary folders...'",
"rm -rf postProcessing/temp_data"
],
on=cloud_machine)