16#include <Champ_Fonc_reprise_IJK.h>
17#include <Probleme_base.h>
18#include <EcritureLectureSpecial.h>
19#include <Champ_Generique_base.h>
20#include <Entree_complete.h>
21#include <LecFicDistribueBin.h>
22#include <EFichierBin.h>
23#include <Domaine_VF.h>
25#include <MD_Vector_std.h>
26#include <MD_Vector_tools.h>
27#include <Octree_Double.h>
28#include <Perf_counters.h>
31extern void convert_to(
const char *s,
double& ob);
41 Cerr<<
"Usage : Champ_Fonc_reprise_IJK fichier.xyz nom_pb nom_inco"<<finl;
48 s>>nom_pb>>nom_champ_inc;
54 ref_ch = pb.
get_champ(Motcle(nom_champ_inc));
55 if (sub_type(Champ_Inc_base,ref_ch.valeur()) && nom_champ_inc == Nom(
"vitesse"))
56 Cerr << nom_champ_inc <<
" is an unknown of problem " << nom_pb <<
" and is 'vitesse'!" << finl;
59 Cerr << nom_champ_inc <<
" is not 'vitesse' (this is the only unknown supported for now)!! " << nom_pb << finl;
65 statistics().
begin_count(
"Temporary counter",statistics().get_last_opened_counter_level()+1);
71 Cerr<<
"Error while opening the file of resumption : " <<nom_fic<<finl;
75 EFichier& fich = fic_rep;
79 Cerr <<
"Error in Champ_Fonc_reprise_IJK::reprendre" << finl;
80 Cerr <<
"The resumption file does not exist" << finl;
81 Cerr <<
"or could not be opened correctly." << finl;
95 vrai_champ_.typer(ref_ch->que_suis_je());
96 const Champ_Inc_base& ch_inc=ref_cast(Champ_Inc_base,ref_ch.valeur());
97 Champ_Inc_base& v_champ=vrai_champ_.valeur();
98 le_champ().associer_domaine_dis_base(pb.
domaine_dis());
110 Cerr <<
"End of resuming the file " << nom_fic <<
" after " << statistics().
get_time_since_last_open(
"Temporary counter") <<
" s" << finl;
111 statistics().
end_count(
"Temporary counter");
123static trustIdType lire_special(
Entree& fich,
const DoubleTab& coords, DoubleTab& val,
const double epsilon)
126 const int nb_dim = val.
nb_dim();
127 const int nb_comp = (nb_dim == 1) ? 1 : val.dimension(1);
137 ArrOfInt items_to_read;
139 Octree_Double octree;
149 const int buflines_max = 2048;
150 DoubleTab buffer(buflines_max, dim + nb_comp);
151 int bufptr = buflines_max;
154 double max_epsilon_needed = epsilon;
156 int error_too_many_matches = 0;
158 int error_duplicate_read = 0;
160 int count_items_read = 0;
163 trustIdType pourcent=0;
164 for (trustIdType i = 0; i < ntot; i++)
166 trustIdType tmp=(i*10)/(ntot-1);
167 if (tmp>pourcent || i==0)
170 Cerr<<
"\r"<<pourcent*10<<
"% of data has been found."<<flush;
172 if (bufptr == buflines_max)
175 trustIdType n = std::min<trustIdType>(buflines_max, ntot - i) * (dim + nb_comp);
176 assert(n <= buffer.size_array());
177 fich.
get(buffer.addr(), n);
179 const double x = buffer(bufptr, 0);
180 const double y = buffer(bufptr, 1);
181 const double z = (dim == 3) ? buffer(bufptr, 2) : 0.;
182 double eps = 1.0e-04;
183 if ((std::fabs(x - (-0.2 + 0.00625*0.5)) < eps) && (std::fabs(y - (-0.2 + 0.00625*0.5)) < eps) && (std::fabs(z) < eps))
184 Cerr <<
"tiens tiens ..." << finl;
188 if (nb_items_proches == 0)
190 Cerr <<
"pas ditems proches" << finl;
193 if (nb_items_proches > 0)
195 items.
resize_array(nb_items_proches, RESIZE_OPTIONS::NOCOPY_NOINIT);
197 for (
int j = 0; j < nb_items_proches; j++)
198 items[j] = floor_elements[index++];
202 if (nb_items_proches == 1)
204 const int flag = items_to_read[item_le_plus_proche];
208 items_to_read[item_le_plus_proche] = 2;
212 val(item_le_plus_proche) = buffer(bufptr, dim);
216 for (
int j = 0; j < nb_comp; j++)
217 val(item_le_plus_proche, j) = buffer(bufptr, dim + j);
227 error_duplicate_read++;
230 else if (nb_items_proches == 0)
233 Cerr <<
"pas ditems proches 2" << finl;
239 for (
int ii = 0; ii < nb_items_proches; ii++)
241 const int i_coord = items[ii];
242 if (i_coord == item_le_plus_proche)
245 for (
int j = 0; j < dim; j++)
247 double yy = coords(i_coord, j) - buffer(bufptr, j);
252 if (max_epsilon_needed > xx)
253 max_epsilon_needed = xx;
255 error_too_many_matches++;
262 bool err = (count_items_read != n_to_read) || (error_too_many_matches > 0) || (error_duplicate_read > 0);
266 error_too_many_matches =
static_cast<int>(
Process::mp_sum(error_too_many_matches));
267 error_duplicate_read =
static_cast<int>(
Process::mp_sum(error_duplicate_read));
268 max_epsilon_needed =
static_cast<int>(
Process::mp_min(max_epsilon_needed));
271 if (error_too_many_matches)
273 Cerr <<
"Error in EcritureLectureSpecial: error_too_many_matches = " << error_too_many_matches
274 <<
", epsilon is too large. Suggested value: " << max_epsilon_needed << finl;
275 if (max_epsilon_needed==0)
277 Cerr <<
"It could be because your mesh has two boundaries which match exactly." << finl;
278 Cerr <<
"It is possible to do calculation with this property but xyz restart process" << finl;
279 Cerr <<
"is impossible because it can't detect the differences between faces of the two boundaries..." << finl;
280 Cerr <<
"Try to do a classic restart with .sauv files." << finl;
283 else if (error_duplicate_read)
285 Cerr <<
"Error in EcritureLectureSpecial: error_duplicate_read = " << error_duplicate_read
286 <<
", probably epsilon too large. " << finl;
290 Cerr <<
"Error in EcritureLectureSpecial: Some items were not found: epsilon too small (or changed the mesh ?)" << finl;
313 trustIdType ntot = 0;
317 Cerr <<
"Champ_Fonc_reprise_IJK::reprendre_IJK: error, cannot read intno an array with no metadata" << finl;
321 if (nb_items_seq == 0)
329 Cerr <<
"Champ_Fonc_reprise_IJK::reprendre_IJK: Problem! Expected face descriptor."<< finl;
332 const DoubleTab& coords = zvf.
xv();
334 ntot += lire_special(fich, coords, val, epsilon);
338 Cerr <<
"Champ_Fonc_reprise_IJK::reprendre_IJK: Problem in the resumption. Not a MD_Vector_base." << finl;
342 if (ntot != nb_items_seq)
344 Cerr <<
"Champ_Fonc_reprise_IJK::reprendre_IJK: Internal error" << finl;
351 Cerr <<
"Champ_Fonc_reprise_IJK::reprendre_IJK: Problem in the resumption "<< finl;
352 Cerr <<
"The field wich is read, does not have same number of nodal values" << finl;
353 Cerr <<
"that the field created by the discretization " << finl;
356 Cerr <<
"Resume of the field " <<
nom_ <<
" performed." << finl;
int nb_valeurs_nodales() const override
Renvoie le nombre de degre de liberte par composante: le nombre de noeuds.
classe Champ_Fonc_base Classe de base des champs qui sont fonction d'une grandeur calculee
void mettre_a_jour(double temps) override
Mise a jour en temps du champ.
classe Champ_Fonc_reprise_IJK Cette classe permet de relire un champ de vitesse SEULEMENT sauvegarde ...
void mettre_a_jour(double) override
Mise a jour en temps du champ.
void reprendre_IJK(Entree &fich, Champ_base &chp)
void associer_domaine_dis_base(const Domaine_dis_base &) override
int fixer_nb_valeurs_nodales(int) override
virtual int fixer_nb_valeurs_temporelles(int)
Fixe le nombre de valeurs temporelles a conserver.
int nb_valeurs_nodales() const override
Returns the number of "real" geometric positions of the degrees of freedom, or -1 if not applicable (...
virtual DoubleTab & valeurs()=0
Champ_base()
Constructeur par defaut d'un Champ_base.
virtual const Domaine_dis_base & domaine_dis_base() const
double xv(int num_face, int k) const
int face_sommets(int i, int j) const
renvoie le numero du ieme sommet de la face num_face.
const Domaine & domaine() const
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::in)
Class defining operators and methods for all reading operation in an input flow (file,...
virtual int get(int *ob, std::streamsize n)
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
virtual void fixer_nb_comp(int i)
Fixe le nombre de composantes du champ.
const Nom & le_nom() const override
Renvoie le nom du champ.
void nommer(const Nom &) override
Donne un nom au champ.
virtual int nb_comp() const
static Objet_U & objet(const Nom &)
Voir Interprete_bloc::objet_global() BM: la classe Interprete n'est pas le meilleur endroit pour cett...
Base class for distributed vectors parallel descriptors.
int get_sequential_items_flags(ArrOfBit &flags, int line_size=1) const
virtual trustIdType nb_items_seq_tot() const
: Cette classe est un OWN_PTR mais l'objet pointe est partage entre plusieurs
const MD_Vector_base & valeur() const
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
const ArrOfInt_t & floor_elements() const
static int_t search_nodes_close_to(double x, double y, double z, const DoubleTab_t &coords, ArrOfInt_t &node_list, double epsilon)
Methode hors classe Cherche parmi les sommets de la liste node_list ceux qui sont a une.
void build_nodes(const DoubleTab_t &coords, const bool include_virtual, const double epsilon=0.)
construit un octree contenant les points de coordonnees coords.
int_t search_elements(double x, double y, double z, int_t &index) const
cherche les elements ou les points contenus dans l'octree_floor qui contient le point (x,...
void begin_count(const STD_COUNTERS &std_cnt, int counter_lvl=-100000)
double get_time_since_last_open(const STD_COUNTERS &name)
Give as a double the time (in second) elapsed in the operation tracked by the standard counter call n...
void end_count(const std::string &custom_count_name, int count_increment=1, long int quantity_increment=0)
End the count of a counter and update the counter values.
void create_custom_counter(std::string counter_description, int counter_level, std::string counter_family="None", bool is_comm=false, bool is_gpu=false)
Create a new counter and add it to the map of custom counters.
const Champ_base & get_champ(const Motcle &nom) const override
const Domaine_dis_base & domaine_dis() const
Renvoie le domaine discretise associe au probleme.
static double mp_min(double)
static double mp_sum(double)
Calcule la somme de x sur tous les processeurs du groupe courant.
static void barrier()
Synchronise tous les processeurs du groupe courant (attend que tous les processeurs soient arrives a ...
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
static int je_suis_maitre()
renvoie 1 si on est sur le processeur maitre du groupe courant (c'est a dire me() == 0),...
Classe de base des flux de sortie.
_SIZE_ size_array() const
void resize_array(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const
virtual const MD_Vector & get_md_vector() const