16#include <Schema_Euler_Implicite.h>
17#include <Domaine_Cl_dis_base.h>
18#include <Probleme_Couple.h>
19#include <communications.h>
20#include <Equation_base.h>
21#include <Probleme_base.h>
22#include <LecFicDiffuse.h>
23#include <Milieu_base.h>
39 dt_gf_ = le_solveur->get_default_growth_factor();
42 Cerr <<
"A solver must be selected." << finl;
43 Cerr <<
"Syntax : " << finl
44 <<
"Solveur solver_name [ solver parameters ] " << finl;
51 Cerr <<
"diffusion_implicite option cannot be used with an implicit time scheme." << finl;
85 if (mot ==
"resolution_monolithique")
95 std::set<std::string> bloc_domap;
99 bloc_domap.insert(m.getString());
111 else if (mot ==
"facsec_max")
113 else if (mot ==
"facsec_expert")
115 else if (mot ==
"facsec_func")
125 Param param(
"facsec_expert");
273 bool convergence_pb =
true;
274 bool convergence_eqn =
false;
276 Cout <<
"=======================================================================================" << finl;
277 Cout <<
"Schema_Euler_Implicite: Implicit iteration " << compteur <<
" on the " << pb.
que_suis_je() <<
" problem " << pb.
le_nom() <<
" :" << finl;
278 Cout <<
"=======================================================================================" << finl;
293 Cout<<
"Solving " << eqn.
que_suis_je() <<
" equation :" << finl;
294 const DoubleTab& inut=futur;
295 convergence_eqn=le_solveur->iterer_eqn(eqn, inut, present,
dt_, compteur, ok);
296 if (!ok)
return false;
297 convergence_pb = convergence_pb&&convergence_eqn;
308 eqn.
inconnue().Champ_base::changer_temps(temps);
311 return (convergence_pb==
true);
356 while (ok && !converged && compteur <
nb_ite_max)
360 converged =
Iterer_Pb(prob,compteur, ok);
363 if (!ok || (!converged && compteur ==
nb_ite_max))
365 Cout<<
"!!! Schema_Euler_Implicite has not converged at t="<<
temps_courant_ <<
" with dt =" <<
dt_<<
" !!!" << finl;
372 Cout<<
"The "<<prob.
que_suis_je()<<
" problem " << prob.
le_nom() <<
" has converged after "<<compteur<<
" implicit iterations."<<finl;
393 int convergence_pbc = 0;
407 while ((!convergence_pbc )&&(compteur<
nb_ite_max))
417 for(
int ii=0; ii<nb_eqn; ii++)
427 std::set<std::string> doms_app, doms_mono;
430 doms_app.insert(ref_cast(
Probleme_base,pbc.
probleme(i)).equation(j).domaine_application().getString());
432 for (
auto &&d : s) doms_mono.insert((
Nom(d)).getSuffix(
"-").getString());
434 if (doms_mono != doms_app)
436 Cerr <<
"Error : all the application domains should be given in the resolution_monolitique block to impose the order of resolution" << finl;
437 Cerr <<
"and some are missing among :";
438 for (
auto &&n: doms_app) Cerr <<
Nom(
" ") + n;
439 Cerr << finl <<
"(an underscore can be put at the begining of the application domains for which a standard resolution is wanted)" << finl;
454 if (eqs.size() == 0)
continue;
456 Cout <<
"RESOLUTION {";
457 for (
auto &&d : s) Cout <<
Nom(
" ") + d;
458 Cout <<
" }" << finl;
459 Cout <<
"-------------------------" << finl;
460 const bool mono = !(s.size() == 1 &&
Nom((*s.begin())).
debute_par(
"-"));
463 Cout <<
"Resolution monolithique! the equations {";
464 for (
int k = 0; k < eqs.size(); k++)
466 Cout <<
" " << eqs[k]->que_suis_je();
467 eqs[k]->probleme().updateGivenFields();
469 Cout <<
" } are solved by assembling a single matrix." << finl;
470 bool convergence_eqs = le_solveur->iterer_eqs(eqs, compteur, ok);
471 convergence_pbc = convergence_pbc && convergence_eqs;
475 for (
int k = 0; k < eqs.size(); k++)
486 Cout<<
"Solving " << eqn.
que_suis_je() <<
" equation :" << finl;
487 const DoubleTab& inut=futur;
488 bool convergence_eqn=le_solveur->iterer_eqn(eqn, inut, present,
dt_, compteur, ok);
490 convergence_pbc = convergence_pbc && convergence_eqn;
495 eqn.
inconnue().Champ_base::changer_temps(temps);
507 convergence_pbc = convergence_pbc * convergence_pb ;
512 if (!ok || (!convergence_pbc && compteur==
nb_ite_max))
514 Cout << pbc.
le_nom() << (ok ?
" : failure" :
" : non-convergence") <<
" at t = "<<
temps_courant_ <<
" with dt = " <<
dt_<<
" !!!" << finl;
520 Cout<<
"The "<<pbc.
que_suis_je()<<
" problem " << pbc.
le_nom() <<
" has converged after "<<compteur<<
" implicit iterations."<<finl;
541 int compteur = 0, ok = 1;
542 bool convergence_eqn =
false;
551 while ((!convergence_eqn)&&(compteur<
nb_ite_max))
554 Cout<<
"==================================================================================" << finl;
555 Cout<<
"Schema_Euler_Implicite: Implicit iteration " << compteur <<
" on the "<<eqn.
que_suis_je() <<
" equation of the problem "<< eqn.
probleme().
le_nom()<<
" :" <<finl;
556 Cout<<
"==================================================================================" << finl;
557 const DoubleTab& inut=futur;
558 convergence_eqn=le_solveur->iterer_eqn(eqn, inut, present,
dt_, compteur, ok);
578 nom_fichier+=
".dt_ev";
580 if (!test.ouvrir(nom_fichier))
582 Cerr <<
"*****************************************" << finl;
583 Cerr <<
"***************** WARNING ***************" << finl;
584 Cerr <<
"File " << nom_fichier <<
" does not exist." << finl;
585 Cerr <<
"In order to restart a calculation carried out with an implicit time scheme" << finl;
586 Cerr <<
"it is preferable to re-read the .dt_ev file to pick up some informations" << finl;
587 Cerr <<
"and in particular the facsec of the previous calculation." << finl;
588 Cerr <<
"TRUST will use facsec= " <<
facsec_ <<
"." << finl;
589 Cerr <<
"Else specify the facsec wanted value in your data file." << finl;
590 Cerr <<
"*****************************************" << finl;
597 double facsec_lu_old;
603 fichier.
ouvrir(nom_fichier);
617 fichier.
ouvrir(nom_fichier);
621 double residu_old_old=0;
625 facsec_lu_old = facsec_lu;
627 fichier >> facsec_lu;
628 fichier >> residu_lu;
631 if (residu_old_old==0)
632 residu_old_old=residu_lu;
637 if (facsec_lu_old != facsec_lu)
643 residu_old_old = residu_lu;
649 envoyer_broadcast(facsec_lu, 0 );
650 envoyer_broadcast(residu_lu, 0 );
664 Cerr <<
"Facsec after reading in " << nom_fichier <<
" : " <<
facsec_ << finl;
665 Cerr <<
"Residu after reading in " << nom_fichier <<
" : " <<
residu_ << finl;
669 Cerr <<
"The readen facsec in " << nom_fichier <<
" : " << facsec_lu << finl;
670 Cerr <<
"is not used since it is lower than the facsec from the data set : " <<
facsec_ << 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.
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 int equation_non_resolue() const
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.
virtual const Motcle & domaine_application() const
Returns "indeterminate" Navier_Stokes_standard for example overrides this method.
This class implements the operators and virtual methods of the EFichier class as follows: The file to...
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
bool contient(const Nom &nom) const
virtual int debute_par(const char *const n) const
Nom & majuscule()
Converts the name to uppercase. Only letters 'a'-'z' are modified.
const std::string & getString() 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_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
void ajouter_non_std(const char *keyword, const Objet_U *value, Param::Nature nat=Param::OPTIONAL)
Register a keyword handled by Objet_U::lire_motcle_non_standard.
int lire_avec_accolades(Entree &is)
Alias of lire_avec_accolades_depuis.
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:
virtual int nombre_d_equations() const =0
virtual const Equation_base & equation(int) const =0
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.
double temps_futur(int i) const override
Returns the time at the i-th future value.
int mettre_a_jour() override
Updates the current time (t+=dt) and the number of time steps performed (nb_pas_dt_++).
int reprendre(Entree &) override
Restores an Objet_U from an input stream. Virtual method to override.
virtual int faire_un_pas_de_temps_pb_couple(Probleme_Couple &, int &ok)
void set_param(Param &) const override
int nb_ite_sans_accel_max_
void Initialiser_Champs(Probleme_base &)
int Iterer_Pb(Probleme_base &, int ite, int &ok)
bool iterateTimeStep(bool &converged) override
Calculate the U(n+1) unknown for each equation (if solved) of the problem with the selected time sche...
int resolution_monolithique(const Nom &nom) const
double temps_defaut() const override
Returns the time that fields must return when valeurs() is called.
int nb_valeurs_futures() const override
Returns the number of future temporal values.
int nb_valeurs_temporelles() const override
Returns the number of temporal values to keep.
const double & residu_old() const
void calcul_fac_sec(double &residu_, double &residu_old, double &facsec_)
int lire_motcle_non_standard(const Motcle &mot, Entree &is) override
Reads non-simple-type parameters of an Objet_U from an input stream.
void lire_facsec_func(Entree &)
std::vector< std::set< std::string > > resolution_monolithique_
Entree & lire_facsec_expert(Entree &)
void test_stationnaire(Probleme_base &)
int faire_un_pas_de_temps_eqn_base(Equation_base &) override
bool initTimeStep(double dt) override
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.
OBS_PTR(Probleme_base) mon_probleme
double dt_
Computation time step.
Probleme_base & pb_base()
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
double pas_de_temps() const
Returns the current time step (delta_t).
void notify_failed_timestep()
virtual bool initTimeStep(double dt)
const double & residu() const
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.