8.0
general documentation
Loading...
Searching...
No Matches
cs_restart.h
Go to the documentation of this file.
1#ifndef __CS_RESTART_H__
2#define __CS_RESTART_H__
3
4/*============================================================================
5 * Manage checkpoint / restart files
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2023 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30/*----------------------------------------------------------------------------
31 * Standard C library headers
32 *----------------------------------------------------------------------------*/
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "cs_defs.h"
39
40#include "cs_time_step.h"
41
42/*----------------------------------------------------------------------------*/
43
45
46/*============================================================================
47 * Macro definitions
48 *============================================================================*/
49
50/* Predefined checkpoint interval */
51
52#define CS_RESTART_INTERVAL_NONE -2
53#define CS_RESTART_INTERVAL_ONLY_AT_END -1
54#define CS_RESTART_INTERVAL_DEFAULT 0
55
56/* Error codes */
57
58#define CS_RESTART_SUCCESS 0
59#define CS_RESTART_ERR_FILE_NUM -1
60#define CS_RESTART_ERR_LOCATION -2
61#define CS_RESTART_ERR_VAL_TYPE -3
62#define CS_RESTART_ERR_N_VALS -4
63#define CS_RESTART_ERR_MODE -5
64#define CS_RESTART_ERR_EXISTS -6
65#define CS_RESTART_ERR_NO_MAP -7
67
68/*============================================================================
69 * Local type definitions
70 *============================================================================*/
71
73
80
81/* Datatype enumeration to transmit a data's type to a function */
82
89
90/*
91 Pointer associated with a restart file structure. The structure itself
92 is defined in "cs_restart.c", and is opaque outside that unit.
93*/
94
95typedef struct _cs_restart_t cs_restart_t;
96
97/*----------------------------------------------------------------------------*/
117/*----------------------------------------------------------------------------*/
118
119typedef int
121 void *context,
122 const char *sec_name,
123 int location_id,
124 int n_location_vals,
125 cs_restart_val_type_t val_type);
126
127/*----------------------------------------------------------------------------*/
147/*----------------------------------------------------------------------------*/
148
149typedef int
151 void *context,
152 const char *sec_name,
153 int location_id,
154 int n_location_vals,
155 cs_restart_val_type_t val_type,
156 void *val);
157
158/*----------------------------------------------------------------------------*/
175/*----------------------------------------------------------------------------*/
176
177typedef void
179 void *context,
180 const char *sec_name,
181 int location_id,
182 int n_location_vals,
183 cs_restart_val_type_t val_type,
184 const void *val);
185
186/*=============================================================================
187 * Global variables
188 *============================================================================*/
189
190/*============================================================================
191 * Public Fortran function prototypes
192 *============================================================================*/
193
194/*----------------------------------------------------------------------------
195 * Check if checkpointing is recommended at a given time.
196 *
197 * Fortran interface
198 *
199 * subroutine reqsui (iisuit)
200 * *****************
201 *
202 * integer iisuit : --> : 0 if no restart required, 1 otherwise
203 *----------------------------------------------------------------------------*/
204
205void CS_PROCF (reqsui, REQSUI)
206(
207 int *iisuit
208);
209
210/*----------------------------------------------------------------------------
211 * Indicate checkpointing has been done at a given time.
212 *
213 * This updates the status for future checks to determine
214 * if checkpointing is recommended at a given time.
215 *
216 * Fortran interface
217 *
218 * subroutine stusui
219 * *****************
220 *----------------------------------------------------------------------------*/
221
222void CS_PROCF (stusui, STUSUI)
223(
224 void
225);
226
227/*----------------------------------------------------------------------------
228 * Save output mesh for turbomachinery if needed
229 *
230 * Fortran interface
231 *
232 * subroutine trbsui
233 * *****************
234 *----------------------------------------------------------------------------*/
235
236void CS_PROCF (trbsui, TRBSUI)
237(
238 void
239);
240
241/*----------------------------------------------------------------------------
242 * Indicate if a restart directory is present.
243 *
244 * Fortran interface
245 *
246 * subroutine indsui (isuite)
247 * *****************
248 *
249 * integer isuite : --> : 1 for restart, 0 otherwise
250 *----------------------------------------------------------------------------*/
251
252void CS_PROCF (indsui, INDSUI)
253(
254 int *isuite
255);
256
257/*============================================================================
258 * Public function prototypes
259 *============================================================================*/
260
261/*----------------------------------------------------------------------------*/
275/*----------------------------------------------------------------------------*/
276
277void
279 double *t_interval,
280 double *wt_interval);
281
282/*----------------------------------------------------------------------------*/
293/*----------------------------------------------------------------------------*/
294
295void
297 double t_interval,
298 double wt_interval);
299
300/*----------------------------------------------------------------------------*/
318/*----------------------------------------------------------------------------*/
319
320void
322
323/*----------------------------------------------------------------------------*/
329/*----------------------------------------------------------------------------*/
330
331void
333
334/*----------------------------------------------------------------------------*/
340/*----------------------------------------------------------------------------*/
341
342void
344
345/*----------------------------------------------------------------------------*/
351/*----------------------------------------------------------------------------*/
352
353void
355
356/*----------------------------------------------------------------------------*/
362/*----------------------------------------------------------------------------*/
363
364void
366
367/*----------------------------------------------------------------------------*/
375/*----------------------------------------------------------------------------*/
376
377bool
379
380/*----------------------------------------------------------------------------*/
389/*----------------------------------------------------------------------------*/
390
391void
393
394/*----------------------------------------------------------------------------*/
400/*----------------------------------------------------------------------------*/
401
402int
404
405/*----------------------------------------------------------------------------*/
416/*----------------------------------------------------------------------------*/
417
419cs_restart_create(const char *name,
420 const char *path,
421 cs_restart_mode_t mode);
422
423/*----------------------------------------------------------------------------*/
429/*----------------------------------------------------------------------------*/
430
431void
433
434/*----------------------------------------------------------------------------*/
448/*----------------------------------------------------------------------------*/
449
450void
452 bool *match_cell,
453 bool *match_i_face,
454 bool *match_b_face,
455 bool *match_vertex);
456
457/*----------------------------------------------------------------------------*/
469/*----------------------------------------------------------------------------*/
470
471int
473 const char *location_name,
474 cs_gnum_t n_glob_ents,
475 cs_lnum_t n_ents,
476 const cs_gnum_t *ent_global_num);
477
478/*----------------------------------------------------------------------------*/
489/*----------------------------------------------------------------------------*/
490
491void
492cs_restart_add_location_ref(const char *location_name,
493 cs_gnum_t n_glob_ents,
494 cs_lnum_t n_ents,
495 const cs_gnum_t *ent_global_num);
496
497/*----------------------------------------------------------------------------*/
501/*----------------------------------------------------------------------------*/
502
503void
505
506/*----------------------------------------------------------------------------*/
520/*----------------------------------------------------------------------------*/
521
522void
523cs_restart_set_context(void *context);
524
525/*----------------------------------------------------------------------------*/
535/*----------------------------------------------------------------------------*/
536
539
540/*----------------------------------------------------------------------------*/
551/*----------------------------------------------------------------------------*/
552
555
556/*----------------------------------------------------------------------------*/
567/*----------------------------------------------------------------------------*/
568
571
572/*----------------------------------------------------------------------------*/
580/*----------------------------------------------------------------------------*/
581
582const char *
583cs_restart_get_name(const cs_restart_t *restart);
584
585/*----------------------------------------------------------------------------*/
595/*----------------------------------------------------------------------------*/
596
599 int location_id);
600
601/*----------------------------------------------------------------------------*/
607/*----------------------------------------------------------------------------*/
608
609void
610cs_restart_dump_index(const cs_restart_t *restart);
611
612/*----------------------------------------------------------------------------*/
625/*----------------------------------------------------------------------------*/
626
627int
629 const char *sec_name,
630 int location_id,
631 int n_location_vals,
632 cs_restart_val_type_t val_type);
633
634/*----------------------------------------------------------------------------*/
648/*----------------------------------------------------------------------------*/
649
650int
652 const char *sec_name,
653 int location_id,
654 int n_location_vals,
655 cs_restart_val_type_t val_type,
656 void *val);
657
658/*----------------------------------------------------------------------------*/
669/*----------------------------------------------------------------------------*/
670
671void
673 const char *sec_name,
674 int location_id,
675 int n_location_vals,
676 cs_restart_val_type_t val_type,
677 const void *val);
678
679/*----------------------------------------------------------------------------*/
691/*----------------------------------------------------------------------------*/
692
693int
695 const char *name,
696 cs_lnum_t *n_particles);
697
698/*----------------------------------------------------------------------------*/
710/*----------------------------------------------------------------------------*/
711
712int
714 int particles_location_id,
715 cs_lnum_t *particle_cell_id,
716 cs_real_t *particle_coords);
717
718/*----------------------------------------------------------------------------*/
738/*----------------------------------------------------------------------------*/
739
740int
742 const char *name,
743 bool number_by_coords,
744 cs_lnum_t n_particles,
745 const cs_lnum_t *particle_cell_id,
746 const cs_real_t *particle_coords);
747
748/*----------------------------------------------------------------------------*/
770/*----------------------------------------------------------------------------*/
771
772int
774 const char *sec_name,
775 int location_id,
776 int ref_location_id,
777 cs_lnum_t ref_id_base,
778 cs_lnum_t *ref_id);
779
780/*----------------------------------------------------------------------------*/
795/*----------------------------------------------------------------------------*/
796
797void
799 const char *sec_name,
800 int location_id,
801 int ref_location_id,
802 cs_lnum_t ref_id_base,
803 const cs_lnum_t *ref_id);
804
805/*----------------------------------------------------------------------------*/
821/*----------------------------------------------------------------------------*/
822
823int
825 const char *sec_name,
826 const char *old_name,
827 int location_id,
828 int n_location_vals,
829 cs_restart_val_type_t val_type,
830 void *val);
831
832/*----------------------------------------------------------------------------*/
851/*----------------------------------------------------------------------------*/
852
853int
855 const char *sec_name,
856 const char *old_name_x,
857 const char *old_name_y,
858 const char *old_name_z,
859 int location_id,
860 cs_real_3_t *val);
861
862/*----------------------------------------------------------------------------*/
884/*----------------------------------------------------------------------------*/
885
886int
888 const char *sec_name,
889 const char *old_name_xx,
890 const char *old_name_yy,
891 const char *old_name_zz,
892 const char *old_name_xy,
893 const char *old_name_yz,
894 const char *old_name_xz,
895 int location_id,
896 cs_real_6_t *val);
897
898/*----------------------------------------------------------------------------*/
920/*----------------------------------------------------------------------------*/
921
922int
924 const char *sec_name,
925 const char *old_name_xx,
926 const char *old_name_yy,
927 const char *old_name_zz,
928 const char *old_name_xy,
929 const char *old_name_yz,
930 const char *old_name_xz,
931 int location_id,
932 cs_real_66_t *val);
933
934/*----------------------------------------------------------------------------*/
938/*----------------------------------------------------------------------------*/
939
940void
942
943/*----------------------------------------------------------------------------*/
947/*----------------------------------------------------------------------------*/
948
949void
951
952/*----------------------------------------------------------------------------*/
958/*----------------------------------------------------------------------------*/
959
960int
962
963/*----------------------------------------------------------------------------*/
969/*----------------------------------------------------------------------------*/
970
971int
973
974/*----------------------------------------------------------------------------*/
987/*----------------------------------------------------------------------------*/
988
989void
990cs_restart_set_n_max_checkpoints(int n_checkpoints);
991
992/*----------------------------------------------------------------------------*/
996/*----------------------------------------------------------------------------*/
997
998void
1000
1001/*----------------------------------------------------------------------------*/
1005/*----------------------------------------------------------------------------*/
1006
1007void
1009
1010/*----------------------------------------------------------------------------*/
1011
1013
1014#endif /* __CS_RESTART_H__ */
cs_real_t cs_real_66_t[6][6]
6x6 matrix of floating-point values
Definition cs_defs.h:342
#define BEGIN_C_DECLS
Definition cs_defs.h:509
double cs_real_t
Floating-point value.
Definition cs_defs.h:319
#define CS_PROCF(x, y)
Definition cs_defs.h:523
cs_real_t cs_real_6_t[6]
vector of 6 floating-point values
Definition cs_defs.h:334
#define END_C_DECLS
Definition cs_defs.h:510
int cs_lnum_t
local mesh entity id
Definition cs_defs.h:313
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition cs_defs.h:332
void indsui(int *isuite)
Definition cs_restart.c:1836
void stusui(void)
Definition cs_restart.c:1800
void trbsui(void)
Definition cs_restart.c:1817
void reqsui(int *iisuit)
Definition cs_restart.c:1777
int cs_restart_is_from_ncfd(void)
Returns if restart is done from a NCFD checkpoint file.
Definition cs_restart.c:4075
cs_restart_mode_t
Definition cs_restart.h:74
@ CS_RESTART_MODE_WRITE
Definition cs_restart.h:77
@ CS_RESTART_MODE_READ
Definition cs_restart.h:76
void cs_restart_write_section_t(cs_restart_t *restart, void *context, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, const void *val)
Function pointer for modifying behavior when writing a section.
Definition cs_restart.h:178
cs_restart_val_type_t
Definition cs_restart.h:83
@ CS_TYPE_int
Definition cs_restart.h:85
@ CS_TYPE_cs_gnum_t
Definition cs_restart.h:86
@ CS_TYPE_cs_real_t
Definition cs_restart.h:87
@ CS_TYPE_char
Definition cs_restart.h:84
int cs_restart_read_real_6_t_compat(cs_restart_t *restart, const char *sec_name, const char *old_name_xx, const char *old_name_yy, const char *old_name_zz, const char *old_name_xy, const char *old_name_yz, const char *old_name_xz, int location_id, cs_real_6_t *val)
Read a cs_real_6_t tensor section from a restart file, when that section may have used a different na...
Definition cs_restart.c:3719
bool cs_restart_checkpoint_required(const cs_time_step_t *ts)
Check if checkpointing is recommended at a given time.
Definition cs_restart.c:1992
cs_lnum_t cs_restart_get_n_location_elts(const cs_restart_t *restart, int location_id)
Return local number of elements associated with a given restart location.
Definition cs_restart.c:2706
void cs_restart_checkpoint_get_intervals(int *nt_interval, double *t_interval, double *wt_interval)
Query checkpoint intervals.
Definition cs_restart.c:1864
const char * cs_restart_get_name(const cs_restart_t *restart)
Return name of restart file.
Definition cs_restart.c:2686
void cs_restart_set_context(void *context)
Associate a context to restart section check operations.
Definition cs_restart.c:2605
int cs_restart_present(void)
Check if we have a restart directory.
Definition cs_restart.c:2103
void cs_restart_check_base_location(const cs_restart_t *restart, bool *match_cell, bool *match_i_face, bool *match_b_face, bool *match_vertex)
Check the locations associated with a restart file.
Definition cs_restart.c:2383
void cs_restart_clear_locations_ref(void)
Clear reference location definitions with a private copy.
Definition cs_restart.c:2578
struct _cs_restart_t cs_restart_t
Definition cs_restart.h:95
int cs_restart_check_if_restart_from_ncfd(cs_restart_t *r)
Checks if restart is done from a NCFD checkpoint file.
Definition cs_restart.c:4046
int cs_restart_check_section(cs_restart_t *restart, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type)
Check the presence of a given section in a restart file.
Definition cs_restart.c:2767
void cs_restart_checkpoint_set_last_ts(int nt_last)
Define last forced checkpoint time step.
Definition cs_restart.c:1934
int cs_restart_read_section_t(cs_restart_t *restart, void *context, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, void *val)
Function pointer for modifying behavior when reading a section.
Definition cs_restart.h:150
void cs_restart_checkpoint_set_next_wt(double wt_next)
Define next forced checkpoint wall-clock time value.
Definition cs_restart.c:1976
void cs_restart_log_setup(void)
Log checkpoint/restart setup.
Definition cs_restart.c:3984
cs_restart_t * cs_restart_create(const char *name, const char *path, cs_restart_mode_t mode)
Initialize a restart file.
Definition cs_restart.c:2132
cs_restart_check_section_t * cs_restart_set_check_section_func(cs_restart_check_section_t *func)
Associate a function to restart section check operations.
Definition cs_restart.c:2623
int cs_restart_check_section_t(cs_restart_t *restart, void *context, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type)
Function pointer for modifying behavior when checking a section's presence.
Definition cs_restart.h:120
cs_restart_read_section_t * cs_restart_set_read_section_func(cs_restart_read_section_t *func)
Associate a function and its input to all restart section read operations.
Definition cs_restart.c:2645
void cs_restart_set_n_max_checkpoints(int n_checkpoints)
Set the number of checkpoint files to keep.
Definition cs_restart.c:4099
cs_restart_write_section_t * cs_restart_set_write_section_func(cs_restart_write_section_t *func)
Associate a function and its input to all restart section write operations.
Definition cs_restart.c:2667
int cs_restart_read_real_3_t_compat(cs_restart_t *restart, const char *sec_name, const char *old_name_x, const char *old_name_y, const char *old_name_z, int location_id, cs_real_3_t *val)
Read a cs_real_3_t vector section from a restart file, when that section may have used a different na...
Definition cs_restart.c:3605
void cs_restart_checkpoint_set_next_tv(double t_next)
Define next forced checkpoint time value.
Definition cs_restart.c:1962
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)
Write a section to a restart file.
Definition cs_restart.c:2843
int cs_restart_read_particles_info(cs_restart_t *restart, const char *name, cs_lnum_t *n_particles)
Read basic particles information from a restart file.
Definition cs_restart.c:2883
void cs_restart_destroy(cs_restart_t **restart)
Destroy structure associated with a restart file (and close the file).
Definition cs_restart.c:2327
void cs_restart_write_ids(cs_restart_t *restart, const char *sec_name, int location_id, int ref_location_id, cs_lnum_t ref_id_base, const cs_lnum_t *ref_id)
Write a referenced location id section to a restart file.
Definition cs_restart.c:3425
int cs_restart_read_real_66_t_compat(cs_restart_t *restart, const char *sec_name, const char *old_name_xx, const char *old_name_yy, const char *old_name_zz, const char *old_name_xy, const char *old_name_yz, const char *old_name_xz, int location_id, cs_real_66_t *val)
Read a cs_real_66_t tensor section from a restart file, when that section may have used a different n...
Definition cs_restart.c:3861
int cs_restart_read_section_compat(cs_restart_t *restart, const char *sec_name, const char *old_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, void *val)
Read a section from a restart file, when that section may have used a different name in a previous ve...
Definition cs_restart.c:3528
int cs_restart_add_location(cs_restart_t *restart, const char *location_name, cs_gnum_t n_glob_ents, cs_lnum_t n_ents, const cs_gnum_t *ent_global_num)
Add a location definition.
Definition cs_restart.c:2441
int cs_restart_read_particles(cs_restart_t *restart, int particles_location_id, cs_lnum_t *particle_cell_id, cs_real_t *particle_coords)
Read basic particles information from a restart file.
Definition cs_restart.c:3070
void cs_restart_multiwriters_destroy_all(void)
Destroy the multiwriter structure at the end of the computation.
Definition cs_restart.c:4180
void cs_restart_dump_index(const cs_restart_t *restart)
Print the index associated with a restart file in read mode.
Definition cs_restart.c:2728
int cs_restart_read_section(cs_restart_t *restart, const char *sec_name, int location_id, int n_location_vals, cs_restart_val_type_t val_type, void *val)
Read a section from a restart file.
Definition cs_restart.c:2800
void cs_restart_clean_multiwriters_history(void)
Remove all previous checkpoints which are not to be retained.
Definition cs_restart.c:4121
void cs_restart_add_location_ref(const char *location_name, cs_gnum_t n_glob_ents, cs_lnum_t n_ents, const cs_gnum_t *ent_global_num)
Add a reference location definition with a private copy.
Definition cs_restart.c:2536
int cs_restart_write_particles(cs_restart_t *restart, const char *name, bool number_by_coords, cs_lnum_t n_particles, const cs_lnum_t *particle_cell_id, const cs_real_t *particle_coords)
Write basic particles information to a restart file.
Definition cs_restart.c:3187
void cs_restart_checkpoint_set_interval(int nt_interval, double t_interval, double wt_interval)
Define default checkpoint interval.
Definition cs_restart.c:1890
void cs_restart_checkpoint_set_mesh_mode(int mode)
Define checkpoint behavior for mesh.
Definition cs_restart.c:1920
int cs_restart_read_ids(cs_restart_t *restart, const char *sec_name, int location_id, int ref_location_id, cs_lnum_t ref_id_base, cs_lnum_t *ref_id)
Read a referenced location id section from a restart file.
Definition cs_restart.c:3322
void cs_restart_checkpoint_done(const cs_time_step_t *ts)
Indicate checkpointing has been done at a given time.
Definition cs_restart.c:2064
void cs_restart_print_stats(void)
Print statistics associated with restart files.
Definition cs_restart.c:4023
void cs_restart_checkpoint_set_next_ts(int nt_next)
Define next forced checkpoint time step.
Definition cs_restart.c:1948
time step descriptor
Definition cs_time_step.h:64