# Restart a Simulation

## Save Restart File for a Simulation

The restart file is written every dt_output_restart or as specified by the t_output_restart_file or dt_output_restart_wallclock. For example, it can be the same, less or more frequent than dt_output which is writing the particle output file. To avoid writing any restart files, set dt_output_restart value to -1. A file is created in each OUTPUT/rank folder with a name of this form: restart_rank[n]_[step_number].fdy. A binary format is used to save space.

A list of the created restart files during the simulation is available in OUTPUT/restart.txt. First column=step_number, second column=time.

It is possible to have both dt_output_restart and dt_output_restart_wallclock specified in which case restarts will be written when either of the conditions is met, for example, every 0.1 s of the simulation time and every two hours of wall-clock time.

## Restart Purge Option

By setting the restart_purge command to true, nanoFluidX will only save the last restart point that has been reached. Otherwise, all restart files will be preserved.

The restart_purge option can be used together with the restart_keep_count option, which specifies how many most recent restarts you want to preserve. If the restart_keep_count is not specified, the default number of preserved restart files is set to 1.

Using these options can save some HDD space.

If restart is true, the OUTPUT folder is not deleted, and the old output files are kept.

## Restart a Simulation

1. To restart a simulation, set the restart command to true in the Simulation parameters section.
2. To choose the step number of the restart, open OUTPUT/restart.txt and choose one value of the first column. Indicate this number in restart_from_step. In the OUTPUT/restart.txt file you would have:
100 0.01
200 0.02
300 0.03
To restart from the step 300, in the config file use:
restart		   true
restart_from_step	300

You can specify the restart folder using restart_from_dir. The folder should contain all of the necessary data for the restart to execute (OUTPUT folder, restart.txt, Used_casefile.cfg, and so on). Unless the folder is specified, the code will by default restart from the folder that has the name of the used .cfg file.

## Restart/Continue from Last Available Restart File

It is possible to continue the simulation from the last available restart file in several ways.
• Specify the following argument in the command line upon launching of the code:
-r true
• In the .cfg file, set restart true and omitting the restart_from_step command.
• In the .cfg file, set restart true and set restart_from_step -1.
Note: The command line argument takes precedence over the .cfg settings, that is, if the command line argument is -r false, then there will not be a continue run even if the .cfg has restart true.