8.2
general documentation
cs_restart_default.h
Go to the documentation of this file.
1 #ifndef __CS_RESTART_DEFAULT_H__
2 #define __CS_RESTART_DEFAULT_H__
3 
4 /*============================================================================
5  * Checkpoint/restart handling for default application.
6  *============================================================================*/
7 
8 /*
9  This file is part of code_saturne, a general-purpose CFD tool.
10 
11  Copyright (C) 1998-2024 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  * Local headers
32  *----------------------------------------------------------------------------*/
33 
34 #include "cs_defs.h"
35 #include "cs_field.h"
36 #include "cs_map.h"
37 #include "cs_restart.h"
38 
39 /*----------------------------------------------------------------------------*/
40 
42 
43 /*=============================================================================
44  * Macro definitions
45  *============================================================================*/
46 
47 /*============================================================================
48  * Type definitions
49  *============================================================================*/
50 
52 /*-------------------*/
53 
54 typedef enum {
55 
70 
71 /*=============================================================================
72  * Public function prototypes
73  *============================================================================*/
74 
75 /*----------------------------------------------------------------------------
76  * Read field metadata from checkpoint.
77  *
78  * Old ids associated to each field are determined for future use.
79  * Note that when reading legacy files (code_saturne version 3.3 and below),
80  * the old id will actually be the old scalar id (-1 for others).
81  *
82  * parameters:
83  * r <-> associated restart file pointer
84  * old_field_map --> name to id map of fields in restart file
85  *----------------------------------------------------------------------------*/
86 
87 void
89  cs_map_name_to_id_t **old_field_map);
90 
91 /*----------------------------------------------------------------------------
92  * Write field metadata to checkpoint.
93  *
94  * parameters:
95  * r <-> associated restart file pointer
96  *----------------------------------------------------------------------------*/
97 
98 void
100 
101 /*----------------------------------------------------------------------------
102  * Read variables from checkpoint.
103  *
104  * parameters:
105  * r <-> associated restart file pointer
106  * old_field_map <-- name to id map of fields in restart file
107  * t_id_flag <-- -1: all time values; 0: current values;
108  * > 0: previous values
109  * read_flag <-- optional flag to track fields read, or NULL;
110  * set to sum of 2^time_id for fields read (size: n_fields)
111  *----------------------------------------------------------------------------*/
112 
113 void
115  const cs_map_name_to_id_t *old_field_map,
116  int t_id_flag,
117  int read_flag[]);
118 
119 /*----------------------------------------------------------------------------
120  * Write variables to checkpoint.
121  *
122  * parameters:
123  * r <-> associated restart file pointer
124  * t_id_flag <-- -1: all time values; 0: current values;
125  * > 0: previous values
126  * write_flag <-- optional flag to track fields written, or NULL;
127  * set to sum of 2^time_id for fields written (size: n_fields)
128 *----------------------------------------------------------------------------*/
129 
130 void
132  int t_id_flag,
133  int write_flag[]);
134 
135 /*----------------------------------------------------------------------------*/
141 /*----------------------------------------------------------------------------*/
142 
143 void
145 
146 /*----------------------------------------------------------------------------*/
152 /*----------------------------------------------------------------------------*/
153 
154 void
156 
157 /*----------------------------------------------------------------------------
158  * Read fields depending on others from checkpoint.
159  *
160  * Old ids associate to each field are determined for future use.
161  * Note that when reading legacy files (code_saturne version 3.3 and below),
162  * the old id will actually be the old scalar id (-1 for others).
163  *
164  * parameters:
165  * r <-> associated restart file pointer
166  * old_field_map <-- name to id map of fields in restart file
167  * key <-- key for field association
168  * read_flag <-- optional flag to track fields read, or NULL;
169  * set to sum of 2^time_id for fields read, -1 for fields
170  * failed to read (size: n_fields)
171  *----------------------------------------------------------------------------*/
172 
173 void
175  const cs_map_name_to_id_t *old_field_map,
176  const char *key,
177  int read_flag[]);
178 
179 /*----------------------------------------------------------------------------
180  * Write fields depending on others to checkpoint.
181  *
182  * Write field metadata to main checkpoint.
183  *
184  * parameters:
185  * r <-> associated restart file pointer
186  * key <-- key for field association
187  * write_flag <-- optional flag to track fields written, or NULL;
188  * set to sum of 2^time_id for fields written (size: n_fields)
189  *
190  * returns:
191  * number of fields written
192  *----------------------------------------------------------------------------*/
193 
194 int
196  const char *key,
197  int write_flag[]);
198 
199 /*----------------------------------------------------------------------------
200  * Read boundary condition coefficients for all fields from checkpoint.
201  *
202  * parameters:
203  * r <-> associated restart file pointer
204  *----------------------------------------------------------------------------*/
205 
206 void
208 
209 /*----------------------------------------------------------------------------
210  * Write boundary condition coefficients for all fields to checkpoint.
211  *
212  * parameters:
213  * r <-> associated restart file pointer
214  *----------------------------------------------------------------------------*/
215 
216 void
218 
219 /*----------------------------------------------------------------------------
220  * Read field values from checkpoint.
221  *
222  * If the values are not found using the default rules based on the
223  * field's name, its name itself, or a "restart_rename" keyed string value,
224  * an old name may be used for compatibility with older files.
225  * For cell-based fields, the old name base is appended automatically with
226  * "_ce_phase01", except for scalars, where the name uses a different scheme,
227  * based on "scalaire_ce_%04" % s_num;
228  *
229  * parameters:
230  * r <-> associated restart file pointer
231  * f_id <-- field id
232  * t_id <-- time id (0 for current, 1 for previous, ...)
233  *
234  * returns:
235  * CS_RESTART_SUCCESS in case of success, CS_RESTART_ERR_... otherwise
236  *----------------------------------------------------------------------------*/
237 
238 int
240  int f_id,
241  int t_id);
242 
243 /*----------------------------------------------------------------------------
244  * Write field values to checkpoint.
245  *
246  * parameters:
247  * r <-> associated restart file pointer
248  * f_id <-- field id
249  * t_id <-- time id (0 for current, 1 for previous, ...)
250  *----------------------------------------------------------------------------*/
251 
252 void
254  int f_id,
255  int t_id);
256 
257 /*----------------------------------------------------------------------------
258  * Read restart time step info.
259  *
260  * parameters:
261  * r <-> associated restart file pointer
262  *----------------------------------------------------------------------------*/
263 
264 void
266 
267 /*----------------------------------------------------------------------------
268  * Loop over all fields and save them in the restart file which id is
269  * passed in argument if it matches their "restart_file" key value.
270  *
271  * parameters:
272  * r <-> associated restart file pointer
273  * r_id <-- value of the key "restart_file"
274  *----------------------------------------------------------------------------*/
275 
276 void
278  cs_restart_file_t r_id);
279 
280 /*----------------------------------------------------------------------------
281  * Loop over all fields and read them in the restart file which id is
282  * passed in argument if it matches their "restart_file" key value.
283  *
284  * parameters:
285  * r <-> associated restart file pointer
286  * r_id <-- value of the key "restart_file"
287  *----------------------------------------------------------------------------*/
288 
289 void
291  cs_restart_file_t r_id);
292 
293 /*----------------------------------------------------------------------------*/
294 /*
295  * \brief Set restart file values for fields when those values cannot
296  * be determined at field definition time.
297  *
298  * This is needed when the need for restart data depends on various
299  * combinations of settings.
300  */
301 /*----------------------------------------------------------------------------*/
302 
303 void
305 
306 /*----------------------------------------------------------------------------*/
307 /*
308  * \brief Initialize fields read status array
309  */
310 /*----------------------------------------------------------------------------*/
311 
312 void
314 
315 /*----------------------------------------------------------------------------*/
316 /*
317  * \brief Finalize fields read status array
318  */
319 /*----------------------------------------------------------------------------*/
320 
321 void
323 
324 /*----------------------------------------------------------------------------*/
325 /*
326  * \brief Get checkpoint read status for a field based on its id
327  *
328  * \param[in] f_id field id
329  *
330  * \returns 0 if field read action failed, 1 otherwise
331  */
332 /*----------------------------------------------------------------------------*/
333 
334 int
335 cs_restart_get_field_read_status(const int f_id);
336 
337 /*----------------------------------------------------------------------------*/
338 
340 
341 #endif /* __CS_RESTART_DEFAULT_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:528
#define END_C_DECLS
Definition: cs_defs.h:529
struct _cs_map_name_to_id_t cs_map_name_to_id_t
Definition: cs_map.h:48
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:95
void cs_restart_read_variables(cs_restart_t *r, const cs_map_name_to_id_t *old_field_map, int t_id_flag, int read_flag[])
Read variables from checkpoint.
Definition: cs_restart_default.c:1989
void cs_restart_write_notebook_variables(cs_restart_t *r)
Write notebook parameters to main checkpoint.
Definition: cs_restart_default.c:2357
void cs_restart_read_field_info(cs_restart_t *r, cs_map_name_to_id_t **old_field_map)
Read field metadata from checkpoint.
Definition: cs_restart_default.c:1767
void cs_restart_initialize_fields_read_status(void)
Initialize fields read status array.
Definition: cs_restart_default.c:3352
void cs_restart_read_notebook_variables(cs_restart_t *r)
Read notebook parameters from main checkpoint.
Definition: cs_restart_default.c:2294
cs_restart_file_t
Definition: cs_restart_default.h:54
@ CS_RESTART_MAIN
Definition: cs_restart_default.h:57
@ CS_RESTART_AUXILIARY
Definition: cs_restart_default.h:58
@ CS_RESTART_LES_INFLOW
Definition: cs_restart_default.h:66
@ CS_RESTART_N_RESTART_FILES
Definition: cs_restart_default.h:67
@ CS_RESTART_1D_WALL_THERMAL
Definition: cs_restart_default.h:64
@ CS_RESTART_LAGR_STAT
Definition: cs_restart_default.h:62
@ CS_RESTART_DISABLED
Definition: cs_restart_default.h:56
@ CS_RESTART_RAD_TRANSFER
Definition: cs_restart_default.h:59
@ CS_RESTART_LAGR
Definition: cs_restart_default.h:61
void cs_restart_read_fields(cs_restart_t *r, cs_restart_file_t r_id)
Loop over all fields and read them in the restart file which id is passed in argument if it matches t...
Definition: cs_restart_default.c:3255
int cs_restart_get_field_read_status(const int f_id)
Get checkpoint read status for a field based on its id.
Definition: cs_restart_default.c:3387
void cs_restart_write_bc_coeffs(cs_restart_t *r)
Write boundary condition coefficients for all fields to checkpoint.
Definition: cs_restart_default.c:2837
void cs_restart_read_linked_fields(cs_restart_t *r, const cs_map_name_to_id_t *old_field_map, const char *key, int read_flag[])
Read fields depending on others from checkpoint.
Definition: cs_restart_default.c:2413
void cs_restart_write_field_vals(cs_restart_t *r, int f_id, int t_id)
Write field values to checkpoint.
Definition: cs_restart_default.c:3119
void cs_restart_read_bc_coeffs(cs_restart_t *r)
Read boundary condition coefficients for all fields from checkpoint.
Definition: cs_restart_default.c:2681
void cs_restart_write_variables(cs_restart_t *r, int t_id_flag, int write_flag[])
Write variables to checkpoint.
Definition: cs_restart_default.c:2159
void cs_restart_read_time_step_info(cs_restart_t *r)
Read restart time step info.
Definition: cs_restart_default.c:3145
void cs_restart_set_auxiliary_field_options(void)
Set restart file values for fields when those values cannot be determined at field definition time.
Definition: cs_restart_default.c:3297
int cs_restart_read_field_vals(cs_restart_t *r, int f_id, int t_id)
Read field values from checkpoint.
Definition: cs_restart_default.c:2951
int cs_restart_write_linked_fields(cs_restart_t *r, const char *key, int write_flag[])
Write fields depending on others to checkpoint.
Definition: cs_restart_default.c:2587
void cs_restart_finalize_fields_read_status(void)
Finalize fields read status array.
Definition: cs_restart_default.c:3371
void cs_restart_write_fields(cs_restart_t *r, cs_restart_file_t r_id)
Loop over all fields and save them in the restart file which id is passed in argument if it matches t...
Definition: cs_restart_default.c:3220
void cs_restart_write_field_info(cs_restart_t *r)
Write field metadata to main checkpoint.
Definition: cs_restart_default.c:1907