TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
Save_Restart.h
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef Save_Restart_included
17#define Save_Restart_included
18
19#include <Sortie_Fichier_base.h>
20#include <Sortie_Brute.h>
21#include <TRUST_Deriv.h>
22#include <TRUST_Ref.h>
23
24class Probleme_base;
25
27{
28public:
30
31 void allocation() const;
32 int allocate_file_size(long int& size) const;
33 inline const char* reprise_format_temps() const;
34
35 inline bool& reprise_effectuee() { return restart_done_; }
36 inline bool reprise_effectuee() const { return restart_done_; }
37
38 void preparer_calcul() ;
39
40 void sauver_xyz(int) const;
41
42 bool is_restart_in_progress() const { return restart_in_progress_; }
43 void set_restart_in_progress(const bool res) { restart_in_progress_ = res; }
44
45 int is_sauvegarde_simple() const { return simple_restart_; }
46 const Nom& checkpoint_filename() const { return checkpoint_filename_; }
47 const Nom& restart_filename() const { return restart_filename_; }
48 const Nom& checkpoint_format() const { return checkpoint_format_; }
49 const Nom& yaml_filename() const { return yaml_fname_; }
50
51 void lire_sauvegarde_reprise(Entree& is, Motcle& motlu) ;
52 int sauver() const;
53 void finir();
54
55private:
56
57 void lire_reprise(Entree& is, Motcle& motlu) ;
58 void lire_sauvegarde(Entree& is, Motcle& motlu) ;
59 void lire_pdi_sauvegarde_reprise(Entree& is, Motcle& motlu, Nom& restart_file_name, Nom& yaml_fname);
60
61 void setTinitFromLastTime(double last_time);
62 void prepare_PDI_restart(int resume_last_time);
63 void checkVersion(const Nom& nomfic);
64
65 OBS_PTR(Probleme_base) pb_base_;
66
67 mutable OWN_PTR(Sortie_Fichier_base) ficsauv_;
68
69 mutable Sortie_Brute* osauv_hdf_ = nullptr; // !! DEPRECATED !! TO DELETE !!
70
71 Nom checkpoint_filename_; // Name of the file for save
72 Nom restart_filename_; // Name of the file for restart
73 Nom checkpoint_format_; // Format for the save restart
74 Nom yaml_fname_; // The name of the yaml file that will be used to initialize PDI (can be provided by the (advanced)user, or is automatically generated)
75 bool restart_done_ = false; // Has a restart been done?
76 int simple_restart_ = 0; // Do we only save the last time step (simple restart) or do we save them all ?
77 int restart_version_ = 155; // Version number, for example 155 (1.5.5) -> used to manage old restart files
78 bool restart_in_progress_ = false; //true variable only during the time step during which a resumption of computation is carried out
79 mutable bool ficsauv_created_ = false; // flag to know if the checkpoint file has been created (useful for PDI)
80 mutable bool config_file_created_ = false; // flag to know if the file describing the configuration of the checkpoint has been created (useful for PDI)
81 // for PDI:
82 // communicator used to read the checkpoint file
83 // (useful if the current node partition is different than the one for checkpoint)
84 OWN_PTR(Comm_Group) restartComm_;
85
86 static long int File_size_; // Espace disque pris par les sauvegarde XYZ
87 static int Bad_allocate_; // 1 si allocation reussi, 0 sinon
88 static int Nb_pb_total_; // Nombre total de probleme
89 static int Num_pb_; // numero du probleme
90 mutable Nom error_; // Erreur d'allocation
91
92};
93
94// Method which may be called from anywhere:
95inline const char* time_format_from(const int reprise_version)
96{
97 // Depuis la 155 le format de la balise temps est en scientifique
98 // pour eviter des erreurs (incoherence entre temps)
99 if (reprise_version<155)
100 return "%f";
101 else
102 return "%e";
103}
104
105inline const char* Save_Restart::reprise_format_temps() const
106{
107 return time_format_from(restart_version_);
108}
109
110#endif /* Save_Restart_included */
: Cette classe decrit un groupe de processeurs sur lesquels
Definition Comm_Group.h:40
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Probleme_base C'est un Probleme_U qui n'est pas un couplage.
bool & reprise_effectuee()
const Nom & yaml_filename() const
const Nom & restart_filename() const
void preparer_calcul()
int sauver() const
Ecriture sur fichier en vue d'une reprise (sauvegarde).
const Nom & checkpoint_format() const
void sauver_xyz(int) const
void allocation() const
bool reprise_effectuee() const
void assoscier_pb_base(const Probleme_base &)
void lire_sauvegarde_reprise(Entree &is, Motcle &motlu)
int allocate_file_size(long int &size) const
Verifie que la place necessaire existe sur le disque dur.
bool is_restart_in_progress() const
const char * reprise_format_temps() const
void set_restart_in_progress(const bool res)
int is_sauvegarde_simple() const
const Nom & checkpoint_filename() const
This derived class of Sortie stacks whatever it receives in an internal binary buffer.