8.3
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
54typedef enum {
55
71
72/*=============================================================================
73 * Public function prototypes
74 *============================================================================*/
75
76/*----------------------------------------------------------------------------
77 * Read field metadata from checkpoint.
78 *
79 * Old ids associated to each field are determined for future use.
80 * Note that when reading legacy files (code_saturne version 3.3 and below),
81 * the old id will actually be the old scalar id (-1 for others).
82 *
83 * parameters:
84 * r <-> associated restart file pointer
85 * old_field_map --> name to id map of fields in restart file
86 *----------------------------------------------------------------------------*/
87
88void
90 cs_map_name_to_id_t **old_field_map);
91
92/*----------------------------------------------------------------------------
93 * Write field metadata to checkpoint.
94 *
95 * parameters:
96 * r <-> associated restart file pointer
97 *----------------------------------------------------------------------------*/
98
99void
101
102/*----------------------------------------------------------------------------
103 * Read variables from checkpoint.
104 *
105 * parameters:
106 * r <-> associated restart file pointer
107 * old_field_map <-- name to id map of fields in restart file
108 * t_id_flag <-- -1: all time values; 0: current values;
109 * > 0: previous values
110 * read_flag <-- optional flag to track fields read, or null;
111 * set to sum of 2^time_id for fields read (size: n_fields)
112 *----------------------------------------------------------------------------*/
113
114void
116 const cs_map_name_to_id_t *old_field_map,
117 int t_id_flag,
118 int read_flag[]);
119
120/*----------------------------------------------------------------------------
121 * Write variables to checkpoint.
122 *
123 * parameters:
124 * r <-> associated restart file pointer
125 * t_id_flag <-- -1: all time values; 0: current values;
126 * > 0: previous values
127 * write_flag <-- optional flag to track fields written, or null;
128 * set to sum of 2^time_id for fields written (size: n_fields)
129*----------------------------------------------------------------------------*/
130
131void
133 int t_id_flag,
134 int write_flag[]);
135
136/*----------------------------------------------------------------------------*/
142/*----------------------------------------------------------------------------*/
143
144void
146
147/*----------------------------------------------------------------------------*/
153/*----------------------------------------------------------------------------*/
154
155void
157
158/*----------------------------------------------------------------------------
159 * Read fields depending on others from checkpoint.
160 *
161 * Old ids associate to each field are determined for future use.
162 * Note that when reading legacy files (code_saturne version 3.3 and below),
163 * the old id will actually be the old scalar id (-1 for others).
164 *
165 * parameters:
166 * r <-> associated restart file pointer
167 * old_field_map <-- name to id map of fields in restart file
168 * key <-- key for field association
169 * read_flag <-- optional flag to track fields read, or null;
170 * set to sum of 2^time_id for fields read, -1 for fields
171 * failed to read (size: n_fields)
172 *----------------------------------------------------------------------------*/
173
174void
176 const cs_map_name_to_id_t *old_field_map,
177 const char *key,
178 int read_flag[]);
179
180/*----------------------------------------------------------------------------
181 * Write fields depending on others to checkpoint.
182 *
183 * Write field metadata to main checkpoint.
184 *
185 * parameters:
186 * r <-> associated restart file pointer
187 * key <-- key for field association
188 * write_flag <-- optional flag to track fields written, or null;
189 * set to sum of 2^time_id for fields written (size: n_fields)
190 *
191 * returns:
192 * number of fields written
193 *----------------------------------------------------------------------------*/
194
195int
197 const char *key,
198 int write_flag[]);
199
200/*----------------------------------------------------------------------------
201 * Read boundary condition coefficients for all fields from checkpoint.
202 *
203 * parameters:
204 * r <-> associated restart file pointer
205 *----------------------------------------------------------------------------*/
206
207void
209
210/*----------------------------------------------------------------------------
211 * Write boundary condition coefficients for all fields to checkpoint.
212 *
213 * parameters:
214 * r <-> associated restart file pointer
215 *----------------------------------------------------------------------------*/
216
217void
219
220/*----------------------------------------------------------------------------
221 * Read field values from checkpoint.
222 *
223 * If the values are not found using the default rules based on the
224 * field's name, its name itself, or a "restart_rename" keyed string value,
225 * an old name may be used for compatibility with older files.
226 * For cell-based fields, the old name base is appended automatically with
227 * "_ce_phase01", except for scalars, where the name uses a different scheme,
228 * based on "scalaire_ce_%04" % s_num;
229 *
230 * parameters:
231 * r <-> associated restart file pointer
232 * f_id <-- field id
233 * t_id <-- time id (0 for current, 1 for previous, ...)
234 *
235 * returns:
236 * CS_RESTART_SUCCESS in case of success, CS_RESTART_ERR_... otherwise
237 *----------------------------------------------------------------------------*/
238
239int
241 int f_id,
242 int t_id);
243
244/*----------------------------------------------------------------------------
245 * Write field values to checkpoint.
246 *
247 * parameters:
248 * r <-> associated restart file pointer
249 * f_id <-- field id
250 * t_id <-- time id (0 for current, 1 for previous, ...)
251 *----------------------------------------------------------------------------*/
252
253void
255 int f_id,
256 int t_id);
257
258/*----------------------------------------------------------------------------
259 * Read restart time step info.
260 *
261 * parameters:
262 * r <-> associated restart file pointer
263 *----------------------------------------------------------------------------*/
264
265void
267
268/*----------------------------------------------------------------------------
269 * Loop over all fields and save them in the restart file which id is
270 * passed in argument if it matches their "restart_file" key value.
271 *
272 * parameters:
273 * r <-> associated restart file pointer
274 * r_id <-- value of the key "restart_file"
275 *----------------------------------------------------------------------------*/
276
277void
279 cs_restart_file_t r_id);
280
281/*----------------------------------------------------------------------------
282 * Loop over all fields and read them in the restart file which id is
283 * passed in argument if it matches their "restart_file" key value.
284 *
285 * parameters:
286 * r <-> associated restart file pointer
287 * r_id <-- value of the key "restart_file"
288 *----------------------------------------------------------------------------*/
289
290void
292 cs_restart_file_t r_id);
293
294/*----------------------------------------------------------------------------*/
295/*
296 * \brief Set restart file values for fields when those values cannot
297 * be determined at field definition time.
298 *
299 * This is needed when the need for restart data depends on various
300 * combinations of settings.
301 */
302/*----------------------------------------------------------------------------*/
303
304void
306
307/*----------------------------------------------------------------------------*/
308/*
309 * \brief Initialize fields read status array
310 */
311/*----------------------------------------------------------------------------*/
312
313void
315
316/*----------------------------------------------------------------------------*/
317/*
318 * \brief Finalize fields read status array
319 */
320/*----------------------------------------------------------------------------*/
321
322void
324
325/*----------------------------------------------------------------------------*/
326/*
327 * \brief Get checkpoint read status for a field based on its id
328 *
329 * \param[in] f_id field id
330 *
331 * \returns 0 if field read action failed, 1 otherwise
332 */
333/*----------------------------------------------------------------------------*/
334
335int
337
338/*----------------------------------------------------------------------------*/
339
341
342#endif /* __CS_RESTART_DEFAULT_H__ */
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
#define END_C_DECLS
Definition: cs_defs.h:543
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.cpp:1989
void cs_restart_write_notebook_variables(cs_restart_t *r)
Write notebook parameters to main checkpoint.
Definition: cs_restart_default.cpp: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.cpp:1767
void cs_restart_initialize_fields_read_status(void)
Initialize fields read status array.
Definition: cs_restart_default.cpp:3352
void cs_restart_read_notebook_variables(cs_restart_t *r)
Read notebook parameters from main checkpoint.
Definition: cs_restart_default.cpp: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:68
@ 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
@ CS_RESTART_IBM
Definition: cs_restart_default.h:67
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: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.cpp:3387
void cs_restart_write_bc_coeffs(cs_restart_t *r)
Write boundary condition coefficients for all fields to checkpoint.
Definition: cs_restart_default.cpp: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.cpp: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.cpp:3119
void cs_restart_read_bc_coeffs(cs_restart_t *r)
Read boundary condition coefficients for all fields from checkpoint.
Definition: cs_restart_default.cpp: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.cpp:2159
void cs_restart_read_time_step_info(cs_restart_t *r)
Read restart time step info.
Definition: cs_restart_default.cpp: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.cpp: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.cpp: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.cpp:2587
void cs_restart_finalize_fields_read_status(void)
Finalize fields read status array.
Definition: cs_restart_default.cpp: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.cpp:3220
void cs_restart_write_field_info(cs_restart_t *r)
Write field metadata to main checkpoint.
Definition: cs_restart_default.cpp:1907