programmer's documentation
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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-2014 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 #include "cs_time_step.h"
40 
41 /*----------------------------------------------------------------------------*/
42 
44 
45 /*============================================================================
46  * Macro definitions
47  *============================================================================*/
48 
49 /* Error codes */
50 
51 #define CS_RESTART_SUCCESS 0 /* Success */
52 #define CS_RESTART_ERR_FILE_NUM -1 /* No restart file for the given number */
53 #define CS_RESTART_ERR_LOCATION -2 /* Undefined location / incorrect size */
54 #define CS_RESTART_ERR_VAL_TYPE -3 /* Unknown or unexpected value type */
55 #define CS_RESTART_ERR_N_VALS -4 /* Number of values does not match */
56 #define CS_RESTART_ERR_MODE -5 /* Incompatible access mode */
57 #define CS_RESTART_ERR_EXISTS -6 /* Section not available */
58 
59 /*============================================================================
60  * Local type definitions
61  *============================================================================*/
62 
63 /* Read or write mode */
64 
65 typedef enum {
66 
67  CS_RESTART_MODE_READ, /* Read mode */
68  CS_RESTART_MODE_WRITE /* Write mode */
69 
71 
72 /* Datatype enumeration to transmit a data's type to a function */
73 
74 typedef enum {
80 
81 /*
82  Pointer associated with a restart file structure. The structure itself
83  is defined in "cs_restart.c", and is opaque outside that unit.
84 */
85 
86 typedef struct _cs_restart_t cs_restart_t;
87 
88 /*=============================================================================
89  * Global variables
90  *============================================================================*/
91 
92 /*============================================================================
93  * Public Fortran function prototypes
94  *============================================================================*/
95 
96 /*----------------------------------------------------------------------------
97  * Indicate if a restart directory is present.
98  *
99  * Fortran interface
100  *
101  * subroutine dflsui (ntsuit, ttsuit, wtsuit)
102  * *****************
103  *
104  * integer ntsuit : <-- : > 0: checkpoint time step interval
105  * : : 0: default interval
106  * : : -1: checkpoint at end
107  * : : -2: no checkpoint
108  * double precision ttsuit : <-- : if> 0, checkpoint time interval
109  * double precision wtsuit : <-- : if> 0, checkpoint wall time interval
110  *----------------------------------------------------------------------------*/
111 
112 void CS_PROCF (dflsui, DFLSUI)
113 (
114  cs_int_t *ntsuit,
115  cs_real_t *ttsuit,
116  cs_real_t *wtsuit
117 );
118 
119 /*----------------------------------------------------------------------------
120  * Check if checkpointing is recommended at a given time.
121  *
122  * Fortran interface
123  *
124  * subroutine reqsui (iisuit)
125  * *****************
126  *
127  * integer iisuit : --> : 0 if no restart required, 1 otherwise
128  *----------------------------------------------------------------------------*/
129 
130 void CS_PROCF (reqsui, RESSUI)
131 (
132  cs_int_t *iisuit
133 );
134 
135 /*----------------------------------------------------------------------------
136  * Indicate checkpointing has been done at a given time.
137  *
138  * This updates the status for future checks to determine
139  * if checkpointing is recommended at a given time.
140  *
141  * Fortran interface
142  *
143  * subroutine stusui
144  * *****************
145  *----------------------------------------------------------------------------*/
146 
147 void CS_PROCF (stusui, STUSUI)
148 (
149  void
150 );
151 
152 /*----------------------------------------------------------------------------
153  * Indicate if a restart directory is present.
154  *
155  * Fortran interface
156  *
157  * subroutine indsui (isuite)
158  * *****************
159  *
160  * integer isuite : --> : 1 for restart, 0 otherwise
161  *----------------------------------------------------------------------------*/
162 
163 void CS_PROCF (indsui, INDSUI)
164 (
165  cs_int_t *isuite
166 );
167 
168 /*----------------------------------------------------------------------------
169  * Open a restart file
170  *
171  * Fortran interface
172  *
173  * subroutine opnsui (nomsui, lngnom, ireawr, numsui, ierror)
174  * *****************
175  *
176  * character* nomsui : <-- : Restart file name
177  * integer lngnom : <-- : Restart file name length
178  * integer ireawr : <-- : 1: read; 2: write
179  * integer numsui : --> : Number of opened restart file
180  * integer ierror : --> : 0: success; < 0: error code
181  *----------------------------------------------------------------------------*/
182 
183 void CS_PROCF (opnsui, OPNSUI)
184 (
185  const char *nomsui,
186  const cs_int_t *lngnom,
187  const cs_int_t *ireawr,
188  cs_int_t *numsui,
189  cs_int_t *ierror
190  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
191  by many Fortran compilers) */
192 );
193 
194 /*----------------------------------------------------------------------------
195  * Close a restart file
196  *
197  * Fortran interface
198  *
199  * subroutine clssui (numsui)
200  * *****************
201  *
202  * integer numsui : <-> : Number of restart file to close
203  * integer ierror : --> : 0: success; < 0: error code
204  *----------------------------------------------------------------------------*/
205 
206 void CS_PROCF (clssui, CLSSUI)
207 (
208  const cs_int_t *numsui,
209  cs_int_t *ierror
210 );
211 
212 /*----------------------------------------------------------------------------
213  * Check the locations associated with a restart file.
214  *
215  * For each type of entity, return 1 if the associated number of entities
216  * matches the current value (and so that we consider the mesh locations are
217  * the same), 0 otherwise.
218  *
219  * Fortran interface
220  *
221  * subroutine tstsui (numsui, indcel, indfac, indfbr, indsom)
222  * *****************
223  *
224  * integer numsui : <-- : Restart file number
225  * integer indcel : --> : Matching cells flag
226  * integer indfac : --> : Matching interior faces flag
227  * integer indfbr : --> : Matching boundary faces flag
228  * integer indsom : --> : Matching vertices flag
229  *----------------------------------------------------------------------------*/
230 
231 void CS_PROCF (tstsui, TSTSUI)
232 (
233  const cs_int_t *numsui,
234  cs_int_t *indcel,
235  cs_int_t *indfac,
236  cs_int_t *indfbr,
237  cs_int_t *indsom
238 );
239 
240 /*----------------------------------------------------------------------------
241  * Print index associated with a restart file in read mode
242  *
243  * Fortran interface
244  *
245  * SUBROUTINE INFSUI (NUMSUI)
246  * *****************
247  *
248  * INTEGER NUMSUI : <-- : Restart file number
249  *----------------------------------------------------------------------------*/
250 
251 void CS_PROCF (infsui, INFSUI)
252 (
253  const cs_int_t *numsui
254 );
255 
256 /*----------------------------------------------------------------------------
257  * Read a section from a restart file
258  *
259  * Fortran interface
260  *
261  * subroutine lecsui (numsui, nomrub, lngnom, itysup, nbvent, irtype, tabvar)
262  * *****************
263  *
264  * integer numsui : <-- : Restart file number
265  * character* nomrub : <-- : Section name
266  * integer lngnom : <-- : Section name length
267  * integer itysup : <-- : Location type:
268  * : : 0: scalar (no location)
269  * : : 1: cells
270  * : : 2: interior faces
271  * : : 3: boundary faces
272  * : : 4: vertices (if available)
273  * integer nbvent : <-- : N. values per location entity
274  * integer irtype : <-- : 1 for integers, 2 for double precision
275  * (?) tabvar : <-> : Array of values to read
276  * integer ierror : --> : 0: success, < 0: error code
277  *----------------------------------------------------------------------------*/
278 
279 void CS_PROCF (lecsui, LECSUI)
280 (
281  const cs_int_t *numsui,
282  const char *nomrub,
283  const cs_int_t *lngnom,
284  const cs_int_t *itysup,
285  const cs_int_t *nbvent,
286  const cs_int_t *irtype,
287  void *tabvar,
288  cs_int_t *ierror
289  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
290  by many Fortran compilers) */
291 );
292 
293 /*----------------------------------------------------------------------------
294  * Write a section to a restart file
295  *
296  * Fortran interface
297  *
298  * subroutine ecrsui (numsui, nomrub, lngnom, itysup, nbvent, irtype, tabvar)
299  * *****************
300  *
301  * integer numsui : <-- : Restart file number
302  * character* nomrub : <-- : Section name
303  * integer lngnom : <-- : Section name length
304  * integer itysup : <-- : Location type:
305  * : : 0: scalar (no location)
306  * : : 1: cells
307  * : : 2: interior faces
308  * : : 3: boundary faces
309  * : : 4: vertices (if available)
310  * integer nbvent : <-- : N. values per location entity
311  * integer irtype : <-- : 1 for integers, 2 for double precision
312  * (?) tabvar : <-- : Array of values to write
313  *----------------------------------------------------------------------------*/
314 
315 void CS_PROCF (ecrsui, ECRSUI)
316 (
317  const cs_int_t *numsui,
318  const char *nomrub,
319  const cs_int_t *lngnom,
320  const cs_int_t *itysup,
321  const cs_int_t *nbvent,
322  const cs_int_t *irtype,
323  const void *tabvar
324  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
325  by many Fortran compilers) */
326 );
327 
328 /*----------------------------------------------------------------------------
329  * Read basic particles information from a restart file.
330  *
331  * Fortran interface
332  *
333  * subroutine lipsui (numsui, nomrub, lngnom, itysup, nbvent, irtype, tabvar)
334  * *****************
335  *
336  * integer numsui : <-- : Restart file number
337  * character* nomrub : <-- : Particles location name
338  * integer lngnom : <-- : Particles location name length
339  * integer nbpart : --> : Number of particles
340  * integer itysup : --> : Particles location id,
341  * or -1 in case of error
342  *----------------------------------------------------------------------------*/
343 
344 void CS_PROCF (lipsui, LIPSUI)
345 (
346  const cs_int_t *numsui,
347  const char *nomrub,
348  const cs_int_t *lngnom,
349  cs_int_t *nbpart,
350  cs_int_t *itysup
351  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
352  by many Fortran compilers) */
353 );
354 
355 /*----------------------------------------------------------------------------
356  * Read basic particles information from a restart file.
357  *
358  * Fortran interface
359  *
360  * subroutine lepsui (numsui, nomrub, lngnom, inmcoo, nbpart, ipcell,
361  * *****************
362  * coopar, itysup, ierror)
363  *
364  * integer numsui : <-- : Restart file number
365  * integer ipcell : --> : Particle -> cell number
366  * double precision coopar : --> : Particle coordinate
367  * integer ipsup : <-- : Particles location id
368  * integer ierror : --> : 0: success, < 0: error code
369  *----------------------------------------------------------------------------*/
370 
371 void CS_PROCF (lepsui, LEPSUI)
372 (
373  const cs_int_t *numsui,
374  cs_int_t *ipcell,
375  cs_real_t *coopar,
376  const cs_int_t *itysup,
377  cs_int_t *ierror
378  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
379  by many Fortran compilers) */
380 );
381 
382 /*----------------------------------------------------------------------------
383  * Write basic particles information to a restart file.
384  *
385  * This includes defining a matching location and associated global numbering,
386  * then writing particle coordinates and cell ids.
387  *
388  * Fortran interface
389  *
390  * subroutine ecpsui (numsui, nomrub, lngnom, inmcoo, nbpart, ipcell,
391  * *****************
392  * coopar, itysup, ierror)
393  *
394  * integer numsui : <-- : Restart file number
395  * character* nomrub : <-- : Particles location name
396  * integer lngnom : <-- : Particles location name length
397  * integer inmcoo : <-- : Number by coords
398  * integer nbpart : <-- : Number of particles
399  * integer ipcell : <-- : Particle -> cell number
400  * double precision coopar : <-- : Particle coordinates
401  * integer ipsup : --> : Particles location id
402  *----------------------------------------------------------------------------*/
403 
404 void CS_PROCF (ecpsui, ECPSUI)
405 (
406  const cs_int_t *numsui,
407  const char *nomrub,
408  const cs_int_t *lngnom,
409  const cs_int_t *inmcoo,
410  const cs_int_t *nbpart,
411  const cs_int_t *ipcell,
412  const cs_real_t *coopar,
413  cs_int_t *itysup
414  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
415  by many Fortran compilers) */
416 );
417 
418 /*----------------------------------------------------------------------------
419  * Read a referenced location id section from a restart file.
420  *
421  * The section read from file contains the global ids matching the local
422  * element ids of a given location. Global id's are transformed to local
423  * ids by this function.
424  *
425  * In case global ids read do not match those of local elements,
426  * id_base - 1 is assigned to the corresponding local ids.
427  *
428  * Fortran interface
429  *
430  * subroutine leisui (numsui, nomrub, lngnom, itysup, irfsup, idbase, tabid, &
431  * *****************
432  * ierror)
433  *
434  * integer numsui : <-- : Restart file number
435  * character* nomrub : <-- : Section name
436  * integer lngnom : <-- : Section name length
437  * integer itysup : <-- : Location type:
438  * : : 0: scalar (no location)
439  * : : 1: cells
440  * : : 2: interior faces
441  * : : 3: boundary faces
442  * : : 4: vertices (if available)
443  * integer irfsup : <-- : Referenced location type:
444  * : : 0: scalar (no location)
445  * : : 1: cells
446  * : : 2: interior faces
447  * : : 3: boundary faces
448  * : : 4: vertices (if available)
449  * integer idbase : <-- : base of referenced entity id numbers
450  * : : (usually 0 or 1)
451  * (?) tabid : <-> : Array of ids to read
452  * integer ierror : --> : 0: success, < 0: error code
453  *----------------------------------------------------------------------------*/
454 
455 void CS_PROCF (leisui, LEISUI)
456 (
457  const cs_int_t *numsui,
458  const char *nomrub,
459  const cs_int_t *lngnom,
460  const cs_int_t *itysup,
461  const cs_int_t *irfsup,
462  const cs_int_t *idbase,
463  void *tabid,
464  cs_int_t *ierror
465  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
466  by many Fortran compilers) */
467  );
468 
469 /*----------------------------------------------------------------------------
470  * Write a referenced location id section to a restart file.
471  *
472  * The section written to file contains the global ids matching the
473  * local element ids of a given location.
474  *
475  * Fortran interface
476  *
477  * subroutine ecisui (numsui, nomrub, lngnom, itysup, irfsup, idbase, tabid, &
478  * *****************
479  * ierror)
480  *
481  * integer numsui : <-- : Restart file number
482  * character* nomrub : <-- : Section name
483  * integer lngnom : <-- : Section name length
484  * integer itysup : <-- : Location type:
485  * : : 0: scalar (no location)
486  * : : 1: cells
487  * : : 2: interior faces
488  * : : 3: boundary faces
489  * : : 4: vertices (if available)
490  * integer irfsup : <-- : Referenced location type:
491  * : : 0: scalar (no location)
492  * : : 1: cells
493  * : : 2: interior faces
494  * : : 3: boundary faces
495  * : : 4: vertices (if available)
496  * integer idbase : <-- : base of referenced entity id numbers
497  * : : (usually 0 or 1)
498  * (?) tabid : <-- : Array of ids to write
499  * integer ierror : --> : 0: success, < 0: error code
500  *----------------------------------------------------------------------------*/
501 
502 void CS_PROCF (ecisui, ECISUI)
503 (
504  const cs_int_t *numsui,
505  const char *nomrub,
506  const cs_int_t *lngnom,
507  const cs_int_t *itysup,
508  const cs_int_t *irfsup,
509  const cs_int_t *idbase,
510  const cs_int_t *tabid
511  CS_ARGF_SUPP_CHAINE /* (possible 'length' arguments added
512  by many Fortran compilers) */
513 );
514 
515 /*============================================================================
516  * Public function prototypes
517  *============================================================================*/
518 
519 /*----------------------------------------------------------------------------
520  * Define default checkpoint interval.
521  *
522  * parameters
523  * nt_interval <-- if > 0 time step interval for checkpoint
524  * if 0, default of 4 checkpoints per run
525  * if -1, checkpoint at end
526  * if -2, no checkpointing
527  * t_interval <-- if > 0, time value interval for checkpoint
528  * wt_interval <-- if > 0, wall-clock interval for checkpoints
529  *----------------------------------------------------------------------------*/
530 
531 void
532 cs_restart_checkpoint_set_defaults(int nt_interval,
533  double t_interval,
534  double wt_interval);
535 
536 /*----------------------------------------------------------------------------
537  * Define next forced checkpoint time step
538  *
539  * parameters
540  * nt_next <-- next time step for forced checkpoint
541  *----------------------------------------------------------------------------*/
542 
543 void
545 
546 /*----------------------------------------------------------------------------
547  * Define next forced checkpoint time value
548  *
549  * parameters
550  * t_next <-- next time value for forced checkpoint
551  *----------------------------------------------------------------------------*/
552 
553 void
554 cs_restart_checkpoint_set_next_tv(double t_next);
555 
556 /*----------------------------------------------------------------------------
557  * Define next forced checkpoint wall-clock time value
558  *
559  * parameters
560  * wt_next <-- next wall-clock time value for forced checkpoint
561  *----------------------------------------------------------------------------*/
562 
563 void
564 cs_restart_checkpoint_set_next_wt(double wt_next);
565 
566 /*----------------------------------------------------------------------------
567  * Check if checkpointing is recommended at a given time.
568  *
569  * parameters
570  * ts <-- time step status structure
571  *
572  * returns:
573  * true if checkpointing is recommended, 0 otherwise
574  *----------------------------------------------------------------------------*/
575 
576 bool
578 
579 /*----------------------------------------------------------------------------
580  * Indicate checkpointing has been done at a given time.
581  *
582  * This updates the status for future checks to determine
583  * if checkpointing is recommended at a given time.
584  *
585  * parameters
586  * ts <-- time step status structure
587  *----------------------------------------------------------------------------*/
588 
589 void
591 
592 /*----------------------------------------------------------------------------
593  * Check if we have a restart directory.
594  *
595  * returns:
596  * 1 if a restart directory is present, 0 otherwise.
597  *----------------------------------------------------------------------------*/
598 
599 int
600 cs_restart_present(void);
601 
602 /*----------------------------------------------------------------------------
603  * Initialize a restart file
604  *
605  * parameters:
606  * name <-- file name
607  * path <-- optional directory name for output
608  * (directory automatically created if necessary)
609  * mode <-- read or write
610  *
611  * returns:
612  * pointer to initialized restart file structure
613  *----------------------------------------------------------------------------*/
614 
615 cs_restart_t *
616 cs_restart_create(const char *name,
617  const char *path,
618  cs_restart_mode_t mode);
619 
620 /*----------------------------------------------------------------------------
621  * Destroy structure associated with a restart file (and close the file).
622  *
623  * parameters:
624  * restart <-- pointer to restart file structure
625  *
626  * returns:
627  * NULL pointer
628  *----------------------------------------------------------------------------*/
629 
630 cs_restart_t *
631 cs_restart_destroy(cs_restart_t *restart);
632 
633 /*----------------------------------------------------------------------------
634  * Check the locations associated with a restart file.
635  *
636  * For each type of entity, the corresponding flag is set to true if the
637  * associated number of entities matches the current value (and so that we
638  * consider the mesh locations are the same), false otherwise.
639  *
640  * parameters:
641  * restart <-- associated restart file pointer
642  * match_cell <-- matching cells flag
643  * match_i_face <-- matching interior faces flag
644  * match_b_face <-- matching boundary faces flag
645  * match_vertex <-- matching vertices flag
646  *----------------------------------------------------------------------------*/
647 
648 void
649 cs_restart_check_base_location(const cs_restart_t *restart,
650  bool *match_cell,
651  bool *match_i_face,
652  bool *match_b_face,
653  bool *match_vertex);
654 
655 /*----------------------------------------------------------------------------
656  * Add a location definition.
657  *
658  * parameters:
659  * restart <-- associated restart file pointer
660  * location_name <-- name associated with the location
661  * n_glob_ents <-- global number of entities
662  * n_ents <-- local number of entities
663  * ent_global_num <-- global entity numbers, or NULL
664  *
665  * returns:
666  * the location id assigned, or -1 in case of error
667  *----------------------------------------------------------------------------*/
668 
669 int
670 cs_restart_add_location(cs_restart_t *restart,
671  const char *location_name,
672  cs_gnum_t n_glob_ents,
673  cs_lnum_t n_ents,
674  const cs_gnum_t *ent_global_num);
675 
676 /*----------------------------------------------------------------------------
677  * Print the index associated with a restart file in read mode
678  *
679  * parameters:
680  * restart <-- associated restart file pointer
681  *----------------------------------------------------------------------------*/
682 
683 void
684 cs_restart_dump_index(const cs_restart_t *restart);
685 
686 /*----------------------------------------------------------------------------
687  * Check the presence of a given section in a restart file.
688  *
689  * parameters:
690  * restart <-- associated restart file pointer
691  * sec_name <-- section name
692  * location_id <-- id of corresponding location
693  * n_location_vals <-- number of values per location (interlaced)
694  * val_type <-- value type
695  *
696  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
697  * or error code (CS_RESTART_ERR_xxx) in case of error
698  *----------------------------------------------------------------------------*/
699 
700 int
701 cs_restart_check_section(cs_restart_t *restart,
702  const char *sec_name,
703  int location_id,
704  int n_location_vals,
705  cs_restart_val_type_t val_type);
706 
707 /*----------------------------------------------------------------------------
708  * Read a section from a restart file.
709  *
710  * parameters:
711  * restart <-- associated restart file pointer
712  * sec_name <-- section name
713  * location_id <-- id of corresponding location
714  * n_location_vals <-- number of values per location (interlaced)
715  * val_type <-- value type
716  * val --> array of values
717  *
718  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
719  * or error code (CS_RESTART_ERR_xxx) in case of error
720  *----------------------------------------------------------------------------*/
721 
722 int
723 cs_restart_read_section(cs_restart_t *restart,
724  const char *sec_name,
725  int location_id,
726  int n_location_vals,
727  cs_restart_val_type_t val_type,
728  void *val);
729 
730 /*----------------------------------------------------------------------------
731  * Write a section to a restart file.
732  *
733  * parameters:
734  * restart <-- associated restart file pointer
735  * sec_name <-- section name
736  * location_id <-- id of corresponding location
737  * n_location_vals <-- number of values per location (interlaced)
738  * val_type <-- value type
739  * val <-- array of values
740  *----------------------------------------------------------------------------*/
741 
742 void
743 cs_restart_write_section(cs_restart_t *restart,
744  const char *sec_name,
745  int location_id,
746  int n_location_vals,
747  cs_restart_val_type_t val_type,
748  const void *val);
749 
750 /*----------------------------------------------------------------------------
751  * Read basic particles information from a restart file.
752  *
753  * This includes building a matching location and associated global numbering.
754  *
755  * parameters:
756  * restart <-- associated restart file pointer
757  * name <-- name of particles set
758  * n_particles --> number of particles, or NULL
759  *
760  * returns:
761  * the location id assigned to the particles, or -1 in case of error
762  *----------------------------------------------------------------------------*/
763 
764 int
765 cs_restart_read_particles_info(cs_restart_t *restart,
766  const char *name,
767  cs_lnum_t *n_particles);
768 
769 /*----------------------------------------------------------------------------
770  * Read basic particles information from a restart file.
771  *
772  * parameters:
773  * restart <-- associated restart file pointer
774  * particles_location_id <-- location id of particles set
775  * particle_cell_id --> local cell id to which particles belong
776  * particle_coords --> local particle coordinates (interleaved)
777  *
778  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
779  * or error code (CS_RESTART_ERR_xxx) in case of error
780  *----------------------------------------------------------------------------*/
781 
782 int
783 cs_restart_read_particles(cs_restart_t *restart,
784  int particles_location_id,
785  cs_lnum_t *particle_cell_id,
786  cs_real_t *particle_coords);
787 
788 /*----------------------------------------------------------------------------
789  * Write basic particles information to a restart file.
790  *
791  * This includes defining a matching location and associated global numbering,
792  * then writing particle coordinates and cell ids.
793  *
794  * parameters:
795  * restart <-- associated restart file pointer
796  * name <-- name of particles set
797  * number_by_coords <-- if true, numbering is based on current coordinates;
798  * otherwise, it is simply based on local numbers,
799  * plus the sum of particles on lower MPI ranks
800  * n_particles <-- local number of particles
801  * particle_cell_num <-- local cell number (1 to n) to which particles
802  * belong; 0 for untracked particles
803  * particle_coords <-- local particle coordinates (interleaved)
804  *
805  * returns:
806  * the location id assigned to the particles
807  *----------------------------------------------------------------------------*/
808 
809 int
810 cs_restart_write_particles(cs_restart_t *restart,
811  const char *name,
812  bool number_by_coords,
813  cs_lnum_t n_particles,
814  const cs_lnum_t *particle_cell_num,
815  const cs_real_t *particle_coords);
816 
817 /*----------------------------------------------------------------------------
818  * Read a referenced location id section from a restart file.
819  *
820  * The section read from file contains the global ids matching the local
821  * element ids of a given location. Global id's are transformed to local
822  * ids by this function.
823  *
824  * In case global referenced ids read do not match those of local elements,
825  * id_base - 1 is assigned to the corresponding local ids.
826  *
827  * parameters:
828  * restart <-- associated restart file pointer
829  * sec_name <-- section name
830  * location_id <-- id of location on which id_ref is defined
831  * ref_location_id <-- id of referenced location
832  * ref_id_base <-- base of location entity id numbers (usually 0 or 1)
833  * ref_id --> array of location entity ids
834  *
835  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
836  * or error code (CS_RESTART_ERR_xxx) in case of error
837  *----------------------------------------------------------------------------*/
838 
839 int
840 cs_restart_read_ids(cs_restart_t *restart,
841  const char *sec_name,
842  int location_id,
843  int ref_location_id,
844  cs_lnum_t ref_id_base,
845  cs_lnum_t *ref_id);
846 
847 /*----------------------------------------------------------------------------
848  * Write a referenced location id section to a restart file.
849  *
850  * The section written to file contains the global ids matching the
851  * local element ids of a given location.
852  *
853  * parameters:
854  * restart <-- associated restart file pointer
855  * sec_name <-- section name
856  * location_id <-- id of location on which id_ref is defined
857  * ref_location_id <-- id of referenced location
858  * ref_id_base <-- base of location entity id numbers (usually 0 or 1)
859  * ref_id <-- array of location entity ids
860  *----------------------------------------------------------------------------*/
861 
862 void
863 cs_restart_write_ids(cs_restart_t *restart,
864  const char *sec_name,
865  int location_id,
866  int ref_location_id,
867  cs_lnum_t ref_id_base,
868  const cs_lnum_t *ref_id);
869 
870 /*----------------------------------------------------------------------------
871  * Read a section from a restart file, when that section may have used a
872  * different name in a previous version.
873  *
874  * parameters:
875  * restart <-- associated restart file pointer
876  * sec_name <-- section name
877  * location_id <-- id of corresponding location
878  * n_location_vals <-- number of values per location (interlaced)
879  * val_type <-- value type
880  * val --> array of values
881  *
882  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
883  * or error code (CS_RESTART_ERR_xxx) in case of error
884  *----------------------------------------------------------------------------*/
885 
886 int
887 cs_restart_read_section_compat(cs_restart_t *restart,
888  const char *sec_name,
889  const char *old_name,
890  int location_id,
891  int n_location_vals,
892  cs_restart_val_type_t val_type,
893  void *val);
894 
895 /*----------------------------------------------------------------------------
896  * Read a cs_real_t section from a restart file, when that section may
897  * have used a different name in a previous version.
898  *
899  * parameters:
900  * restart <-- associated restart file pointer
901  * sec_name <-- section name
902  * location_id <-- id of corresponding location
903  * n_location_vals <-- number of values per location (interlaced)
904  * val --> array of values
905  *
906  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
907  * or error code (CS_RESTART_ERR_xxx) in case of error
908  *----------------------------------------------------------------------------*/
909 
910 int
911 cs_restart_read_real_t_compat(cs_restart_t *restart,
912  const char *sec_name,
913  const char *old_name,
914  int location_id,
915  int n_location_vals,
916  cs_real_t *val);
917 
918 /*----------------------------------------------------------------------------
919  * Read a cs_real_3_t vector section from a restart file, when that
920  * section may have used a different name and been non-interleaved
921  * in a previous version.
922  *
923  * This file assumes a mesh-base location (i.e. location_id > 0)
924  *
925  * parameters:
926  * restart <-- associated restart file pointer
927  * sec_name <-- section name
928  * old_name_x <-- old name, x component
929  * old_name_y <-- old name, y component
930  * old_name_y <-- old name, z component
931  * location_id <-- id of corresponding location
932  * val --> array of values
933  *
934  * returns: 0 (CS_RESTART_SUCCESS) in case of success,
935  * or error code (CS_RESTART_ERR_xxx) in case of error
936  *----------------------------------------------------------------------------*/
937 
938 int
939 cs_restart_read_real_3_t_compat(cs_restart_t *restart,
940  const char *sec_name,
941  const char *old_name_x,
942  const char *old_name_y,
943  const char *old_name_z,
944  int location_id,
945  cs_real_3_t *val);
946 
947 /*----------------------------------------------------------------------------
948  * Print statistics associated with restart files
949  *----------------------------------------------------------------------------*/
950 
951 void
953 
954 /*----------------------------------------------------------------------------
955  * Return pointer to restart file based on Fortran id
956  *
957  * parameters:
958  * r_num <-- associated fortran restart number
959  *
960  * returns:
961  * pointer to restart file, or NULL
962  *----------------------------------------------------------------------------*/
963 
964 cs_restart_t *
965 cs_restart_by_fortran_id(int r_num);
966 
967 /*----------------------------------------------------------------------------*/
968 
970 
971 #endif /* __CS_RESTART_H__ */
Definition: cs_restart.h:78
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)
Definition: cs_restart.c:2840
time step descriptor
Definition: cs_time_step.h:51
unsigned long cs_gnum_t
global mesh entity number
Definition: cs_defs.h:280
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_num, const cs_real_t *particle_coords)
Definition: cs_restart.c:3493
void cs_restart_dump_index(const cs_restart_t *restart)
Definition: cs_restart.c:2680
void cs_restart_checkpoint_done(const cs_time_step_t *ts)
Definition: cs_restart.c:2307
void cs_restart_checkpoint_set_defaults(int nt_interval, double t_interval, double wt_interval)
Definition: cs_restart.c:2186
void cs_restart_print_stats(void)
Definition: cs_restart.c:3948
cs_restart_t * cs_restart_create(const char *name, const char *path, cs_restart_mode_t mode)
Definition: cs_restart.c:2368
Definition: cs_restart.h:76
void ecpsui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, const cs_int_t *inmcoo, const cs_int_t *nbpart, const cs_int_t *ipcell, const cs_real_t *coopar, cs_int_t *itysup CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1781
#define BEGIN_C_DECLS
Definition: cs_defs.h:405
int cs_int_t
Fortran-compatible integer.
Definition: cs_defs.h:295
void indsui(cs_int_t *isuite)
Definition: cs_restart.c:1267
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)
Definition: cs_restart.c:3063
cs_restart_mode_t
Definition: cs_restart.h:65
int cs_restart_read_real_t_compat(cs_restart_t *restart, const char *sec_name, const char *old_name, int location_id, int n_location_vals, cs_real_t *val)
#define CS_ARGF_SUPP_CHAINE
Definition: cs_defs.h:434
Definition: cs_restart.h:75
void reqsui(cs_int_t *iisuit)
Definition: cs_restart.c:1225
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)
Definition: cs_restart.c:3828
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)
Definition: cs_restart.c:3879
void ecrsui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, const cs_int_t *itysup, const cs_int_t *nbvent, const cs_int_t *irtype, const void *tabvar CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1592
bool cs_restart_checkpoint_required(const cs_time_step_t *ts)
Definition: cs_restart.c:2245
void lepsui(const cs_int_t *numsui, cs_int_t *ipcell, cs_real_t *coopar, const cs_int_t *itysup, cs_int_t *ierror CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1718
int cs_restart_present(void)
Definition: cs_restart.c:2344
void infsui(const cs_int_t *numsui)
Definition: cs_restart.c:1473
Definition: cs_restart.h:77
void stusui(void)
Definition: cs_restart.c:1248
void cs_restart_checkpoint_set_next_ts(int nt_next)
Definition: cs_restart.c:2203
int cs_restart_read_particles_info(cs_restart_t *restart, const char *name, cs_lnum_t *n_particles)
Definition: cs_restart.c:3197
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)
Definition: cs_restart.c:3626
cs_real_t cs_real_3_t[3]
vector of 3 floating-point values
Definition: cs_defs.h:307
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)
Definition: cs_restart.c:2718
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:292
Definition: cs_restart.h:68
void clssui(const cs_int_t *numsui, cs_int_t *ierror)
Definition: cs_restart.c:1368
void cs_restart_checkpoint_set_next_wt(double wt_next)
Definition: cs_restart.c:2229
void dflsui(cs_int_t *ntsuit, cs_real_t *ttsuit, cs_real_t *wtsuit)
Definition: cs_restart.c:1204
cs_restart_val_type_t
Definition: cs_restart.h:74
#define END_C_DECLS
Definition: cs_defs.h:406
cs_restart_t * cs_restart_by_fortran_id(int r_num)
Definition: cs_restart.c:3973
double cs_real_t
Definition: cs_defs.h:296
void cs_restart_checkpoint_set_next_tv(double t_next)
Definition: cs_restart.c:2216
int cs_restart_read_particles(cs_restart_t *restart, int particles_location_id, cs_lnum_t *particle_cell_id, cs_real_t *particle_coords)
Definition: cs_restart.c:3380
void opnsui(const char *nomsui, const cs_int_t *lngnom, const cs_int_t *ireawr, cs_int_t *numsui, cs_int_t *ierror CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1290
cs_restart_t * cs_restart_destroy(cs_restart_t *restart)
Definition: cs_restart.c:2479
#define CS_PROCF(x, y)
Definition: cs_defs.h:419
void lecsui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, const cs_int_t *itysup, const cs_int_t *nbvent, const cs_int_t *irtype, void *tabvar, cs_int_t *ierror CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1517
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)
Definition: cs_restart.c:2533
void leisui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, const cs_int_t *itysup, const cs_int_t *irfsup, const cs_int_t *idbase, void *tabid, cs_int_t *ierror CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1875
void ecisui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, const cs_int_t *itysup, const cs_int_t *irfsup, const cs_int_t *idbase, const cs_int_t *tabid CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1963
void lipsui(const cs_int_t *numsui, const char *nomrub, const cs_int_t *lngnom, cs_int_t *nbpart, cs_int_t *itysup CS_ARGF_SUPP_CHAINE)
Definition: cs_restart.c:1655
Definition: cs_restart.h:67
void tstsui(const cs_int_t *numsui, cs_int_t *indcel, cs_int_t *indfac, cs_int_t *indfbr, cs_int_t *indsom)
Definition: cs_restart.c:1417
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)
Definition: cs_restart.c:2591
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)
Definition: cs_restart.c:3727