9.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-2026 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 "base/cs_defs.h"
35#include "base/cs_field.h"
36#include "base/cs_map.h"
37#include "base/cs_restart.h"
38
39/*=============================================================================
40 * Macro definitions
41 *============================================================================*/
42
43/*============================================================================
44 * Type definitions
45 *============================================================================*/
46
48/*-------------------*/
49
50typedef enum {
51
67
68/*=============================================================================
69 * Public function prototypes
70 *============================================================================*/
71
72/*----------------------------------------------------------------------------
73 * Read field metadata from checkpoint.
74 *
75 * Old ids associated to each field are determined for future use.
76 * Note that when reading legacy files (code_saturne version 3.3 and below),
77 * the old id will actually be the old scalar id (-1 for others).
78 *
79 * parameters:
80 * r <-> associated restart file pointer
81 * old_field_map --> name to id map of fields in restart file
82 *----------------------------------------------------------------------------*/
83
84void
86 cs_map_name_to_id_t **old_field_map);
87
88/*----------------------------------------------------------------------------
89 * Write field metadata to checkpoint.
90 *
91 * parameters:
92 * r <-> associated restart file pointer
93 *----------------------------------------------------------------------------*/
94
95void
97
98/*----------------------------------------------------------------------------
99 * Read variables from checkpoint.
100 *
101 * parameters:
102 * r <-> associated restart file pointer
103 * old_field_map <-- name to id map of fields in restart file
104 * t_id_flag <-- -1: all time values; 0: current values;
105 * > 0: previous values
106 * read_flag <-- optional flag to track fields read, or null;
107 * set to sum of 2^time_id for fields read (size: n_fields)
108 *----------------------------------------------------------------------------*/
109
110void
112 const cs_map_name_to_id_t *old_field_map,
113 int t_id_flag,
114 int read_flag[]);
115
116/*----------------------------------------------------------------------------
117 * Write variables to checkpoint.
118 *
119 * parameters:
120 * r <-> associated restart file pointer
121 * t_id_flag <-- -1: all time values; 0: current values;
122 * > 0: previous values
123 * write_flag <-- optional flag to track fields written, or null;
124 * set to sum of 2^time_id for fields written (size: n_fields)
125*----------------------------------------------------------------------------*/
126
127void
129 int t_id_flag,
130 int write_flag[]);
131
132/*----------------------------------------------------------------------------*/
138/*----------------------------------------------------------------------------*/
139
140void
142
143/*----------------------------------------------------------------------------*/
149/*----------------------------------------------------------------------------*/
150
151void
153
154/*----------------------------------------------------------------------------
155 * Read fields depending on others from checkpoint.
156 *
157 * Old ids associate to each field are determined for future use.
158 * Note that when reading legacy files (code_saturne version 3.3 and below),
159 * the old id will actually be the old scalar id (-1 for others).
160 *
161 * parameters:
162 * r <-> associated restart file pointer
163 * old_field_map <-- name to id map of fields in restart file
164 * key <-- key for field association
165 * read_flag <-- optional flag to track fields read, or null;
166 * set to sum of 2^time_id for fields read, -1 for fields
167 * failed to read (size: n_fields)
168 *----------------------------------------------------------------------------*/
169
170void
172 const cs_map_name_to_id_t *old_field_map,
173 const char *key,
174 int read_flag[]);
175
176/*----------------------------------------------------------------------------
177 * Write fields depending on others to checkpoint.
178 *
179 * Write field metadata to main checkpoint.
180 *
181 * parameters:
182 * r <-> associated restart file pointer
183 * key <-- key for field association
184 * write_flag <-- optional flag to track fields written, or null;
185 * set to sum of 2^time_id for fields written (size: n_fields)
186 *
187 * returns:
188 * number of fields written
189 *----------------------------------------------------------------------------*/
190
191int
193 const char *key,
194 int write_flag[]);
195
196/*----------------------------------------------------------------------------
197 * Read boundary condition coefficients for all fields from checkpoint.
198 *
199 * parameters:
200 * r <-> associated restart file pointer
201 *----------------------------------------------------------------------------*/
202
203void
205
206/*----------------------------------------------------------------------------
207 * Write boundary condition coefficients for all fields to checkpoint.
208 *
209 * parameters:
210 * r <-> associated restart file pointer
211 *----------------------------------------------------------------------------*/
212
213void
215
216/*----------------------------------------------------------------------------
217 * Read field values from checkpoint.
218 *
219 * If the values are not found using the default rules based on the
220 * field's name, its name itself, or a "restart_rename" keyed string value,
221 * an old name may be used for compatibility with older files.
222 * For cell-based fields, the old name base is appended automatically with
223 * "_ce_phase01", except for scalars, where the name uses a different scheme,
224 * based on "scalaire_ce_%04" % s_num;
225 *
226 * parameters:
227 * r <-> associated restart file pointer
228 * f_id <-- field id
229 * t_id <-- time id (0 for current, 1 for previous, ...)
230 *
231 * returns:
232 * CS_RESTART_SUCCESS in case of success, CS_RESTART_ERR_... otherwise
233 *----------------------------------------------------------------------------*/
234
235int
237 int f_id,
238 int t_id);
239
240/*----------------------------------------------------------------------------
241 * Write field values to checkpoint.
242 *
243 * parameters:
244 * r <-> associated restart file pointer
245 * f_id <-- field id
246 * t_id <-- time id (0 for current, 1 for previous, ...)
247 *----------------------------------------------------------------------------*/
248
249void
251 int f_id,
252 int t_id);
253
254/*----------------------------------------------------------------------------
255 * Read restart time step info.
256 *
257 * parameters:
258 * r <-> associated restart file pointer
259 *----------------------------------------------------------------------------*/
260
261void
263
264/*----------------------------------------------------------------------------
265 * Loop over all fields and save them in the restart file which id is
266 * passed in argument if it matches their "restart_file" key value.
267 *
268 * parameters:
269 * r <-> associated restart file pointer
270 * r_id <-- value of the key "restart_file"
271 *----------------------------------------------------------------------------*/
272
273void
275 cs_restart_file_t r_id);
276
277/*----------------------------------------------------------------------------
278 * Loop over all fields and read them in the restart file which id is
279 * passed in argument if it matches their "restart_file" key value.
280 *
281 * parameters:
282 * r <-> associated restart file pointer
283 * r_id <-- value of the key "restart_file"
284 *----------------------------------------------------------------------------*/
285
286void
288 cs_restart_file_t r_id);
289
290/*----------------------------------------------------------------------------*/
291/*
292 * \brief Set restart file values for fields when those values cannot
293 * be determined at field definition time.
294 *
295 * This is needed when the need for restart data depends on various
296 * combinations of settings.
297 */
298/*----------------------------------------------------------------------------*/
299
300void
302
303/*----------------------------------------------------------------------------*/
304/*
305 * \brief Initialize fields read status array
306 */
307/*----------------------------------------------------------------------------*/
308
309void
311
312/*----------------------------------------------------------------------------*/
313/*
314 * \brief Finalize fields read status array
315 */
316/*----------------------------------------------------------------------------*/
317
318void
320
321/*----------------------------------------------------------------------------*/
322/*
323 * \brief Get checkpoint read status for a field based on its id.
324 *
325 * If some time values were read and others not available, the returned
326 * value is that of the contiguous number of time values successfully read
327 * (i.e. if time values 0 and 2 were read, but not 1, only the firs value,
328 * 0 is considered usable, so the returned value would be 1).
329 *
330 * \param[in] f_id field id
331 *
332 * \returns number of time values read for field.
333 */
334/*----------------------------------------------------------------------------*/
335
336int
338
339/*----------------------------------------------------------------------------*/
340
341#endif /* CS_RESTART_DEFAULT_H */
struct _cs_map_name_to_id_t cs_map_name_to_id_t
Definition: cs_map.h:42
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:91
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.cpp:1970
void cs_restart_write_notebook_variables(cs_restart_t *r)
Write notebook parameters to main checkpoint.
Definition: cs_restart_default.cpp:2356
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.cpp:1748
void cs_restart_initialize_fields_read_status(void)
Initialize fields read status array.
Definition: cs_restart_default.cpp:3358
void cs_restart_read_notebook_variables(cs_restart_t *r)
Read notebook parameters from main checkpoint.
Definition: cs_restart_default.cpp:2293
cs_restart_file_t
Definition: cs_restart_default.h:50
@ CS_RESTART_MAIN
Definition: cs_restart_default.h:53
@ CS_RESTART_AUXILIARY
Definition: cs_restart_default.h:54
@ CS_RESTART_LES_INFLOW
Definition: cs_restart_default.h:62
@ CS_RESTART_N_RESTART_FILES
Definition: cs_restart_default.h:64
@ CS_RESTART_1D_WALL_THERMAL
Definition: cs_restart_default.h:60
@ CS_RESTART_LAGR_STAT
Definition: cs_restart_default.h:58
@ CS_RESTART_DISABLED
Definition: cs_restart_default.h:52
@ CS_RESTART_RAD_TRANSFER
Definition: cs_restart_default.h:55
@ CS_RESTART_LAGR
Definition: cs_restart_default.h:57
@ CS_RESTART_IBM
Definition: cs_restart_default.h:63
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.cpp:3247
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.cpp:3398
void cs_restart_write_bc_coeffs(cs_restart_t *r)
Write boundary condition coefficients for all fields to checkpoint.
Definition: cs_restart_default.cpp:2825
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.cpp:2412
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.cpp:3111
void cs_restart_read_bc_coeffs(cs_restart_t *r)
Read boundary condition coefficients for all fields from checkpoint.
Definition: cs_restart_default.cpp:2678
void cs_restart_write_variables(cs_restart_t *r, int t_id_flag, int write_flag[])
Write variables to checkpoint.
Definition: cs_restart_default.cpp:2158
void cs_restart_read_time_step_info(cs_restart_t *r)
Read restart time step info.
Definition: cs_restart_default.cpp:3137
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.cpp:3301
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.cpp:2943
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.cpp:2584
void cs_restart_finalize_fields_read_status(void)
Finalize fields read status array.
Definition: cs_restart_default.cpp:3377
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.cpp:3212
void cs_restart_write_field_info(cs_restart_t *r)
Write field metadata to main checkpoint.
Definition: cs_restart_default.cpp:1888