Page 1 of 1
Save new quantity for restart
Posted: Wed Apr 05, 2023 3:13 pm
by Boone11
Hi all,
I have created a new variable ("r") that is used in a home made model. I would like to store it at the end of a computation to use it to initialise a restart.
For the already existing quantities there is no issue. For instance for the streamwise velocity, in the cs_user_initialisation.f90 I use:
But for my new quantity "r" I do not know how to do. I cannot not compute it from existing quantities at the last iteration of the previous run. May you help me?
Thanks a lot!
Re: Save new quantity for restart
Posted: Thu Apr 06, 2023 7:15 pm
by Yvan Fournier
Hello,
I wanted to add a field keyword to determine if a field should be saved in a checkpoint, but cant't find a trace of this, so I guess it is still on my TODO/wish list...
Otherwise, you can use the cs_restart_write_section function, but you need to do this on an open restart file, and there is not user-defined function call at the appropriate call site.
So the easiest solution is probably to create your own additional restart file, using a
cs_restart_create...
cs_restart_write_section__
cs_restart_destroy
Sequence (I'll let you check the actual arguments in the code sources or on-line documentation).
Best regards,
Yvan
Re: Save new quantity for restart
Posted: Wed Apr 12, 2023 3:07 pm
by Boone11
Hi Yvan and thanks for your answer.
Practically, I should create a file named cs_restart.c, then write in it:
Code: Select all
/* Creation of the restart file */
cs_restart_create(const char * my_quantity1_file, const char * save_additional_quantities_directory, cs_restart_mode_t write)
/* Declaration of the used subroutines */
void cs_restart_write_section(cs_restart_t * restart, const char * sec_name, int location_id, int n_location_vals,
cs_restart_val_type_t val_type, const void * val )
void cs_restart_destroy ( cs_restart_t ** restart)
/* Main program */
/* Suppose 3 quantities to be stored */
cs_restart_write_section(restart1, sec_name, location_id, n_location_vals, CS_TYPE_cs_real_t, my_quantity1)
cs_restart_write_section(restart2, sec_name, location_id, n_location_vals, CS_TYPE_cs_real_t, my_quantity2)
cs_restart_write_section(restart3, sec_name, location_id, n_location_vals, CS_TYPE_cs_real_t, my_quantity3)
cs_restart_destroy ( cs_restart_t ** restart1)
cs_restart_destroy ( cs_restart_t ** restart2)
cs_restart_destroy ( cs_restart_t ** restart3)
Does it seems correct to you?
Could you explain in more detail what '
section name', '
id of corresponding location', and '
number of values per location (interlaced)' refer to for the cs_restart_write_section subroutine?
Is there an example of user restart that I can use?
Thanks again!