Create a new main restart file outside Code_Saturne

Questions and remarks about code_saturne usage
Forum rules
Please read the forum usage recommendations before posting.
Post Reply
seby2
Posts: 8
Joined: Wed Sep 12, 2018 8:51 am

Create a new main restart file outside Code_Saturne

Post by seby2 »

Hello,

I want to restart a calculation from a MED file containing previous results of a calculation. Restarting a calculation needs a restart file (not a MED file). So I would like to create my own main restart file containing the datas of the mesh and associated fields in order to restart a calculation from a MED file containing a mesh and fields interpolated on it. I did not find how to do this operation in the documentation or in this forum.

I read in the user's guide that the "cs_io_dump" tool allows to extract informations about the mesh and the fields from the main restart file. Is that possible to perform the reverse operation, that is to say write a mesh and fields into a main restart file ?

Thank you.

Seb
C.FLAG.
Posts: 32
Joined: Fri Apr 08, 2016 2:19 pm

Re: Create a new main restart file outside Code_Saturne

Post by C.FLAG. »

Hi,

It might be simpler to read the interpolated fields using MED / HDF5 in cs_user_initialisation (.c or .f90). Unfortunately, I don't have any such example at hand. For HDF5, https://support.hdfgroup.org/HDF5/Tutor/rdwt.html might help.

Regards,
Cédric

EDIT: for reading a MED file, http://docs.salome-platform.org/latest/ ... er_en.html might help, python code can be called in cs_user_scripts.py
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: Create a new main restart file outside Code_Saturne

Post by Yvan Fournier »

Hello,

Actually, Code_Saturne can be built with MEDCoupling support, and reading MED and projecting their results using MEDCoupling is now a feature in version 5.2 or master, but documentation might be missing.

/user_examples/cs_user_boundary_conditions-medcoupling_remapper_2d.c shows how you can used MEDCoupling to map boundary conditions. This could be adapted to mapping to initial conditions in cs_user_initialization.

Best regards,

Yvan
seby2
Posts: 8
Joined: Wed Sep 12, 2018 8:51 am

Re: Create a new main restart file outside Code_Saturne

Post by seby2 »

Thank you for your answers.

I understand the solutions that you propose. I do not want to modifiy fields or the mesh at the initialisation of a computation but I want to modify them during the calculation at each time step. I think cs_user_initialisation allows to define only initial conditions of the global computation, right ?
My problem is still present.

Regards,
Seb
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: Create a new main restart file outside Code_Saturne

Post by Yvan Fournier »

Hello,

I do not understand what you need to do. Your initial question was about restarts. The restart files are not read at each time step either, but at computation initialization, just before calling cs_user_initialize (note that initialization is called before the time loop for both initial ad restarted computations).

If you need to modify fields at each time step, you can do it in cs_user_extra_operations, but this is not recommended for solved variables, as this goes against the time scheme.

Regards,

Yvan
seby2
Posts: 8
Joined: Wed Sep 12, 2018 8:51 am

Re: Create a new main restart file outside Code_Saturne

Post by seby2 »

hello,

Thank you.
This is my problem. Actually, I have a MED file containing a mesh and the associated fields corresponding to a computation performed by Code_Saturne. I know the exact physical time corresponding to these fields but I do not have the restart file. I want to rebuild the restart file knowing the mesh, the fields of the solution at a given physical time in order to continue the computation.
I do not know if I can start a computation from a time different to 0 and considering the fields I have as initial conditions.

Regards,
Seb
Yvan Fournier
Posts: 4077
Joined: Mon Feb 20, 2012 3:25 pm

Re: Create a new main restart file outside Code_Saturne

Post by Yvan Fournier »

Hello,

The code will ignore the starting time, but this simply amounts to a shift in the time relative to the reference, so should not be important. You may also try to change the values of cs_glob_time_step in cs_user_initialize.c or cs_user_parameters.c if necessary (though this is not recommended). In this case use the cs_get_glob_time_step() function to access a writable pointer to that structure.

Best regards,

Yvan
seby2
Posts: 8
Joined: Wed Sep 12, 2018 8:51 am

Re: Create a new main restart file outside Code_Saturne

Post by seby2 »

Hello,

Yes, you are right!
Actually, there is no problem. I did not think the time is relative. Now you say that, it seems to be obvious. :D
Thank you.

Regards,
Seb
Post Reply