16#include <Schema_Implicite_Multi_TimeStep_base.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Probleme_Couple.h>
19#include <communications.h>
20#include <Matrice_Morse.h>
21#include <Equation_base.h>
22#include <Probleme_base.h>
23#include <LecFicDiffuse.h>
24#include <Milieu_base.h>
40 Cerr <<
"A solver must be selected." << finl;
41 Cerr <<
"Syntax : " << finl
42 <<
"Solveur solver_name [ solver parameters ] " << finl;
47 Cerr <<
"diffusion_implicite option cannot be used with an implicit time scheme." << finl;
54static void Implicite_Multi_TimeStep_calcul_fac_sec(
double& residu_,
double& residu_old,
double& facsec_,
const double facsec_max_,
int& nb_ite_sans_accel_)
57 int nb_ite_sans_accel_max = 20000;
64 else if ((residu_old>rap*residu_)||(nb_ite_sans_accel_>nb_ite_sans_accel_max))
68 facsec_=std::min(facsec_,facsec_max_);
161 bool convergence_pb =
true;
162 bool convergence_eqn =
false;
178 DoubleTab stored_parameters;
184 Cout<<
"Solving equation "<<eqn.
que_suis_je()<<finl;
185 const DoubleTab& inut=futur;
188 convergence_eqn = le_solveur->iterer_eqn(eqn,inut, present,
dt_,ite, ok);
191 convergence_pb = convergence_pb&&convergence_eqn;
203 return (convergence_pb==
true);
231static void Implicite_Multi_TimeStep_recommencer_pb(
int nb_valeurs_passees,
Probleme_base& pb)
237 for (j=0; j<nb_valeurs_passees; j++)
249 int convergence_pb = 0;
260 while ((!convergence_pb)&&(compteur<
nb_ite_max))
264 convergence_pb =
Iterer_Pb(prob,compteur);
268 if ((!convergence_pb)&&(compteur==
nb_ite_max))
272 double rap = sqrt(2.);
277 Cerr<<
"We restart with dt_ =" <<
dt_ <<finl;
284 for(
int ii=0; ii<nb_eqn; ii++)
295 Cout<<
"The problem "<<prob.
que_suis_je()<<
" has converged after "<<compteur<<
" iterations."<<finl;
320 int convergence_pbc = 0;
334 while ((!convergence_pbc )&&(compteur<
nb_ite_max))
344 for(
int ii=0; ii<nb_eqn; ii++)
355 convergence_pbc = convergence_pbc * convergence_pb ;
359 if ((!convergence_pbc)&&(compteur==
nb_ite_max))
361 Cerr<<
"The process is restarted. " <<finl;
425 int compteur = 0, ok = 1;
427 bool convergence_eqn =
false;
429 DoubleTab stored_parameters;
446 while ((!convergence_eqn)&&(compteur<
nb_ite_max))
450 Cout<<
"==================================================================================" << finl;
452 Cout<<
"==================================================================================" << finl;
454 const DoubleTab& inut=futur;
456 convergence_eqn=le_solveur->iterer_eqn(eqn, inut, present,
dt_, compteur, ok);
482 nom_fichier+=
".dt_ev";
484 if (!test.ouvrir(nom_fichier))
486 Cerr <<
"*****************************************" << finl;
487 Cerr <<
"***************** WARNING ***************" << finl;
488 Cerr <<
"File " << nom_fichier <<
" does not exist." << finl;
489 Cerr <<
"In order to restart a calculation carried out with an implicit time scheme" << finl;
490 Cerr <<
"it is preferable to re-read the .dt_ev file to pick up some informations" << finl;
491 Cerr <<
"and in particular the facsec of the previous calculation." << finl;
492 Cerr <<
"TRUST will use facsec= " <<
facsec_ <<
"." << finl;
493 Cerr <<
"Else specify the facsec wanted value in your data file." << finl;
494 Cerr <<
"*****************************************" << finl;
501 double facsec_lu_old;
507 fichier.
ouvrir(nom_fichier);
521 fichier.
ouvrir(nom_fichier);
527 facsec_lu_old = facsec_lu;
529 fichier >> facsec_lu;
530 fichier >> residu_lu;
534 if (facsec_lu_old != facsec_lu)
542 envoyer_broadcast(facsec_lu, 0 );
543 envoyer_broadcast(residu_lu, 0 );
557 Cerr <<
"Facsec after reading in " << nom_fichier <<
" : " <<
facsec_ << finl;
558 Cerr <<
"Residu after reading in " << nom_fichier <<
" : " <<
residu_ << finl;
562 Cerr <<
"The readen facsec in " << nom_fichier <<
" : " << facsec_lu << finl;
563 Cerr <<
"is not used since it is lower than the facsec from the data set : " <<
facsec_ << finl;
571 Cerr<<
"Error in "<<
que_suis_je()<<
"::modifier_second_membre_full_impl()"<<finl;
572 Cerr<<
que_suis_je()<<
" is an implicit time scheme"<<finl;
573 Cerr<<
que_suis_je()<<
"::modifier_second_membre_full_impl() should not be used"<<finl;
579 Cerr<<
"Error in "<<
que_suis_je()<<
"::modifier_second_membre()"<<finl;
580 Cerr<<
que_suis_je()<<
" is an implicit time scheme"<<finl;
581 Cerr<<
que_suis_je()<<
"::modifier_second_membre() should not be used"<<finl;
588 bool authorized =
true;
590 authorized &= (bool) equation_name.
find(
"FT");
591 authorized &= (bool) equation_name.
find(
"Front_Tracking");
592 authorized &= (bool) equation_name.
find(
"QC");
593 authorized &= (bool) equation_name.
find(
"Quasi_Compressible");
597 Cerr<<
"Error in "<<
que_suis_je()<<
"::authorized_equation()"<<finl;
598 Cerr<<
"Equation "<<equation_name<<
" is not allowed with "<<
que_suis_je()<<
" time scheme"<<finl;
606 bool authorized =
true;
608 authorized &= (bool) equation_name.
find(
"FT");
609 authorized &= (bool) equation_name.
find(
"Front_Tracking");
610 authorized &= (bool) equation_name.
find(
"QC");
611 authorized &= (bool) equation_name.
find(
"Quasi_Compressible");
615 Cerr<<
"Error in "<<
que_suis_je()<<
"::authorized_equation()"<<finl;
616 Cerr<<
"Equation "<<equation_name<<
" is not allowed with "<<
que_suis_je()<<
" time scheme"<<finl;
DoubleTab & futur(int i=1) override
Returns field values at instant t+i.
DoubleTab & passe(int i=1) override
Returns field values at instant t-i.
DoubleTab & valeurs() override
Returns the array of field values at the current time.
double recuperer_temps_passe(int i=1) const
Returns the time of the i-th past field.
double recuperer_temps_futur(int i=1) const
Returns the time of the i-th future field.
const Probleme_U & probleme(int i) const
virtual int calculer_coeffs_echange(double temps)
Computes the exchange coefficients for thermally coupled problems.
virtual void imposer_cond_lim(Champ_Inc_base &, double)=0
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
ifstream & get_ifstream()
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,...
class Equation_base The role of an equation is the calculation of one or more fields....
virtual const Champ_Inc_base & inconnue() const =0
virtual Domaine_Cl_dis_base & domaine_Cl_dis()
Returns the discretized boundary condition domain associated with the equation.
Probleme_base & probleme()
Returns the problem associated with the equation.
This class implements the operators and virtual methods of the EFichier class as follows: The file to...
Matrice_Base class - Base class of the matrix hierarchy.
class Nom: a character string for naming TRUST objects.
virtual int find(const char *const n) const
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static const Nom & nom_du_cas()
Returns a constant reference to the case name. This method is static.
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Helper class to factorize the readOn method of Objet_U classes.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Probleme_Couple This is the historical coupling class of TRUST.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
virtual bool updateGivenFields()
WARNING:
class Probleme_base It is a Probleme_U that is not a coupling.
bool is_dilatable() const
bool updateGivenFields() override
WARNING:
void abortTimeStep() override
Aborts the resolution of the current time step.
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
bool initTimeStep(double dt) override
This method allocates and initializes the unknown and given fields for the future time step.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
static int je_suis_maitre()
Returns 1 if on the master processor of the current group (i.e. me() == 0), 0 otherwise.
bool initTimeStep(double dt) override
int nb_valeurs_temporelles_effectives() const
virtual int faire_un_pas_de_temps_pb_couple(Probleme_Couple &, int &ok)
int reprendre(Entree &) override
Restores an Objet_U from an input stream. Virtual method to override.
virtual void compute_coefficients(double time_step, const DoubleTab ×) const =0
int nb_valeurs_futures() const override
Returns the number of future temporal values.
void set_param(Param &) const override
double temps_defaut() const override
Returns the time that fields must return when valeurs() is called.
bool iterateTimeStep(bool &converged) override
Calculate the U(n+1) unknown for each equation (if solved) of the problem with the selected time sche...
void modifier_second_membre(const Equation_base &eqn, DoubleTab &secmem) override
void ajouter_inertie(Matrice_Base &mat_morse, DoubleTab &secmem, const Equation_base &eqn) const override
int mettre_a_jour() override
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
virtual void update_time_derivative(Equation_base &eqn, const DoubleTab &data)=0
double temps_futur(int i) const override
Returns the time at the i-th future value.
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
virtual void modifier_second_membre_full_impl(const Equation_base &eqn, DoubleTab &secmem)
virtual int nb_pas_dt_seuil() const =0
virtual void add_multi_timestep_data(const Equation_base &eqn, Matrice_Base &mat_morse, DoubleTab &secmem) const =0
void test_stationnaire(Probleme_base &)
virtual void mettre_a_jour_equation(Equation_base &eqn, const double temps)=0
virtual int nb_valeurs_passees() const =0
virtual void store_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters)=0
virtual void modify_equation_parameters(Equation_base &eqn, DoubleTab &stored_parameters)=0
virtual double changer_temps(Equation_base &eqn, const double temps)=0
void Initialiser_Champs(Probleme_base &)
int Iterer_Pb(Probleme_base &, int ite)
void authorized_equation(const Equation_base &eqn)
class Schema_Implicite_base Base class for all implicit time schemes.
void set_param(Param ¶m) const override
int diffusion_implicite() const
Returns 1 if the time scheme has been read with diffusion_implicite.
double temps_courant() const
Returns the current time.
double dt_
Computation time step.
virtual void ajouter_inertie(Matrice_Base &mat_morse, DoubleTab &secmem, const Equation_base &eqn) const
Probleme_base & pb_base()
double pas_de_temps() const
Returns the current time step (delta_t).
virtual bool initTimeStep(double dt)
int nb_pas_dt() const
Returns the number of time steps performed.
virtual int mettre_a_jour()
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
void update_critere_statio(const DoubleTab &tab_critere, Equation_base &equation)
Updates stationnaire_atteint_ and residu_ (criterion: residu_ < seuil_statio_).
Base class for output streams.