My Project
programmer's 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-2019 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 /*----------------------------------------------------------------------------
136  * Read fields depending on others from checkpoint.
137  *
138  * Old ids associate to each field are determined for future use.
139  * Note that when reading legacy files (Code_Saturne version 3.3 and below),
140  * the old id will actually be the old scalar id (-1 for others).
141  *
142  * parameters:
143  * r <-> associated restart file pointer
144  * old_field_map <-- name to id map of fields in restart file
145  * key <-- key for field association
146  * read_flag <-- optional flag to track fields read, or NULL;
147  * set to sum of 2^time_id for fields read, -1 for fields
148  * failed to read (size: n_fields)
149  *----------------------------------------------------------------------------*/
150 
151 void
153  const cs_map_name_to_id_t *old_field_map,
154  const char *key,
155  int read_flag[]);
156 
157 /*----------------------------------------------------------------------------
158  * Write fields depending on others to checkpoint.
159  *
160  * Write field metadata to main checkpoint.
161  *
162  * parameters:
163  * r <-> associated restart file pointer
164  * key <-- key for field association
165  * write_flag <-- optional flag to track fields written, or NULL;
166  * set to sum of 2^time_id for fields written (size: n_fields)
167  *
168  * returns:
169  * number of fields written
170  *----------------------------------------------------------------------------*/
171 
172 int
174  const char *key,
175  int write_flag[]);
176 
177 /*----------------------------------------------------------------------------
178  * Read boundary condition coefficients for all fields from checkpoint.
179  *
180  * parameters:
181  * r <-> associated restart file pointer
182  *----------------------------------------------------------------------------*/
183 
184 void
186 
187 /*----------------------------------------------------------------------------
188  * Write boundary condition coefficients for all fields to checkpoint.
189  *
190  * parameters:
191  * r <-> associated restart file pointer
192  *----------------------------------------------------------------------------*/
193 
194 void
196 
197 /*----------------------------------------------------------------------------
198  * Read field values from checkpoint.
199  *
200  * If the values are not found using the default rules based on the
201  * field's name, its name itself, or a "restart_rename" keyed string value,
202  * an old name may be used for compatibility with older files.
203  * For cell-based fields, the old name base is appended automatically with
204  * "_ce_phase01", except for scalars, where the name uses a different scheme,
205  * based on "scalaire_ce_%04" % s_num;
206  *
207  * parameters:
208  * r <-> associated restart file pointer
209  * f_id <-- field id
210  * t_id <-- time id (0 for current, 1 for previous, ...)
211  *
212  * returns:
213  * CS_RESTART_SUCCESS in case of success, CS_RESTART_ERR_... otherwise
214  *----------------------------------------------------------------------------*/
215 
216 int
218  int f_id,
219  int t_id);
220 
221 /*----------------------------------------------------------------------------
222  * Write field values to checkpoint.
223  *
224  * parameters:
225  * r <-> associated restart file pointer
226  * f_id <-- field id
227  * t_id <-- time id (0 for current, 1 for previous, ...)
228  *----------------------------------------------------------------------------*/
229 
230 void
232  int f_id,
233  int t_id);
234 
235 /*----------------------------------------------------------------------------
236  * Read restart time step info.
237  *
238  * parameters:
239  * r <-> associated restart file pointer
240  *----------------------------------------------------------------------------*/
241 
242 void
244 
245 /*----------------------------------------------------------------------------
246  * Loop over all fields and save them in the restart file which id is
247  * passed in argument if it matches their "restart_file" key value.
248  *
249  * parameters:
250  * r <-> associated restart file pointer
251  * r_id <-- value of the key "restart_file"
252  *----------------------------------------------------------------------------*/
253 
254 void
256  cs_restart_file_t r_id);
257 
258 /*----------------------------------------------------------------------------
259  * Loop over all fields and read them in the restart file which id is
260  * passed in argument if it matches their "restart_file" key value.
261  *
262  * parameters:
263  * r <-> associated restart file pointer
264  * r_id <-- value of the key "restart_file"
265  *----------------------------------------------------------------------------*/
266 
267 void
269  cs_restart_file_t r_id);
270 
271 /*----------------------------------------------------------------------------*/
272 
274 
275 #endif /* __CS_RESTART_DEFAULT_H__ */
CS_RESTART_AUXILIARY
Definition: cs_restart_default.h:58
f_id
void const int * f_id
Definition: cs_gui.h:292
cs_defs.h
cs_restart_file_t
cs_restart_file_t
Definition: cs_restart_default.h:54
CS_RESTART_LAGR_STAT
Definition: cs_restart_default.h:62
CS_RESTART_N_RESTART_FILES
Definition: cs_restart_default.h:67
cs_restart_read_variables
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:1794
cs_restart_write_linked_fields
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:2262
END_C_DECLS
#define END_C_DECLS
Definition: cs_defs.h:468
CS_RESTART_MAIN
Definition: cs_restart_default.h:57
CS_RESTART_LAGR
Definition: cs_restart_default.h:61
BEGIN_C_DECLS
#define BEGIN_C_DECLS
Definition: cs_defs.h:467
cs_restart_write_field_vals
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:2721
cs_restart_write_field_info
void cs_restart_write_field_info(cs_restart_t *r)
Write field metadata to main checkpoint.
Definition: cs_restart_default.c:1712
cs_map.h
cs_map_name_to_id_t
struct _cs_map_name_to_id_t cs_map_name_to_id_t
Definition: cs_map.h:48
cs_restart_read_bc_coeffs
void cs_restart_read_bc_coeffs(cs_restart_t *r)
Read boundary condition coefficients for all fields from checkpoint.
Definition: cs_restart_default.c:2356
cs_field.h
CS_RESTART_DISABLED
Definition: cs_restart_default.h:56
cs_restart_t
struct _cs_restart_t cs_restart_t
Definition: cs_restart.h:87
cs_restart_read_fields
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:2827
CS_RESTART_LES_INFLOW
Definition: cs_restart_default.h:66
cs_restart_read_time_step_info
void cs_restart_read_time_step_info(cs_restart_t *r)
Read restart time step info.
Definition: cs_restart_default.c:2747
cs_restart_write_fields
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:2802
CS_RESTART_1D_WALL_THERMAL
Definition: cs_restart_default.h:64
cs_restart_read_linked_fields
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:2088
cs_restart_write_bc_coeffs
void cs_restart_write_bc_coeffs(cs_restart_t *r)
Write boundary condition coefficients for all fields to checkpoint.
Definition: cs_restart_default.c:2512
cs_restart_read_field_info
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:1572
cs_restart.h
cs_restart_write_variables
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:1952
CS_RESTART_RAD_TRANSFER
Definition: cs_restart_default.h:59
cs_restart_read_field_vals
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:2626