The aim of the database module is to provide a set of tools which allow the user to create a restart file that can be interrogated to allow a simulation to restart for any specified time step, simulation time and iteration number. The design of the database allows a variable to be saved at any number of iterations and time steps. The user has control over the name of the database from which a simulation should restart as well as the name of the database to be written at the end of the simulation. These two names can be set totally independently.
At the start of a simulation the user can specify in the inform the name of the input and output databases. If the same name is used for both the results of the simulation will be written at the end of the database if possible. If no input database name is given then the simulation will start from the initial values given in the inform. If no output database name is given the unextended name of the .geo file will be used. If the .geo file was call case01.geo then the database header file will be called case01.pdh and the database data file will be called case01.pdd.
In the inform the iteration number, simulation time and time step number from which the simulation is to restart can be set. Only one of the time step or simulation time will be used. The default is the time step but the setting of a simulation time in the inform will overwrite this default. The last setting of either time step or simulation time in the inform will be used. The default value of the time step number is -1, which indicates that the last time step in the data base should be read. Similarly the default iteration number is -1, which again signifies the last iteration number. If a positive time step number is specified then only records with this time step number can be read. If the simulation time is being used then only records with a smaller simulation time will be considered. The database module will look for a record which minimises the difference between the record's time and the sought time. If a positive iteration number is entered then the code will try to find an iteration not greater than the requested iteration number. If all iteration numbers are greater than the requested iteration number the selected record will have the smallest iteration number for the chosen time step.
Two routines are available for indicating which variables should be written to the database. These functions are called save_restart_variable and save_dbase_variable. The only difference between the two methods is the controlling logic for writing and reading from the database. The function save_restart_variable causes the variables to be written as a chain. This allows the matching of the iteration and time step to be performed on the chain rather than each individual variable and so is a little quicker. The routine save_dbase_variable writes each variable individually. The standard modules in PHYSICA only make use of save_restart_variable.