16#include <Operateur_base.h>
17#include <Probleme_base.h>
18#include <Schema_Temps_base.h>
19#include <EcrFicPartage.h>
20#include <Periodique.h>
24#include <Domaine_VF.h>
25#include <Matrice_Morse.h>
27#include <Discretisation_base.h>
28#include <Domaine_Cl_dis_base.h>
32Operateur_base::Operateur_base()
99 for (
auto& itr : les_cl)
110 if (noms_compo_courts.size() > 1)
111 for (
int i = 0; i < noms_compo_courts.size(); ++i)
114 w_suffix = std::max(w_suffix, noms_compo_courts[i].longueur());
136 Cerr <<
"You must overload the method " <<
que_suis_je()
137 <<
"::calculer_dt_local(DoubleVect&)" << finl;
193 DoubleTrav secmem(inco);
219 Cerr <<
"***********************************************************************************" << finl;
220 Cerr <<
"Sorry, implicit scheme is not available yet for the " <<
que_suis_je() <<
" scheme." << finl;
222 Cerr <<
"***********************************************************************************" << finl;
233 if (
equation().discretisation().is_poly_family())
256 DoubleTrav secmem(inco);
268 DoubleTrav secmem(inco);
281 Cerr <<
"You must overload the method " <<
que_suis_je()
282 <<
"::contribuer_au_second_membre(DoubleTab&)" << finl;
292 Cerr<<
"Operateur_base::associer_domaine_cl_dis must be overloaded "<<finl;
300 Cerr <<
"You provided an empty string to name the .out file of operator " <<
que_suis_je() <<
" in equation " <<
equation().
que_suis_je() <<
"." << finl;
301 Cerr <<
"If you don't want to write a .out file for this operator, don't call set_fichier()" << finl;
322 Cerr<<
"Only master process can open "<<type<<
" file. See Operateur_base::ouvrir_fichier()" << finl;
331 if (type!=
"") nomfichier+=(
Nom)
"_"+type;
339 std::vector<std::string> comp_m = {
"_Mx",
"_My",
"_Mz"};
341 os <<
"# " << (type==
"moment" ?
"Moment of " :
"") <<
description() << finl;
343 if (!gnuplot_header) os <<
"#";
351 Cerr <<
"flux_bords_ not dimensioned for the operator " <<
que_suis_je() << finl;
357 if (type==
"moment" &&
dimension == 2) nb_compo=1;
360 for (
int i = 0; i < noms_compo_courts.size(); ++i)
367 for (
int num_cl=0; num_cl<les_cls.size(); num_cl++)
376 os.
add_col((ch + comp_m[2]).getChar());
379 os.
add_col((ch + comp_m[d]).getChar());
384 for (
int d = 0; d < nb_compo; ++d)
386 os.
add_col((ch +
"_" + noms_compo_courts[d]).getChar());
393 for (
int d = 0; d < nb_compo; ++d)
395 os.
add_col((ch +
"_" + noms_compo_courts[d]).getChar());
402 if (type!=
"sum" && type!=
"moment")
406 for (
int d = 0; d < nb_compo; ++d)
407 os.
add_col((
Nom(
"Total_") + noms_compo_courts[d]).getChar());
416 os.
ouvrir(nomfichier,ios::app);
419 os.
setf(ios::scientific);
421 pb.get_set_out_files().add(os);
439 if (type!=
"") nomfichier+=(
Nom)
"_"+type;
449 os.
ouvrir(nomfichier,ios::app);
452 os.
setf(ios::scientific);
478 if (opt == DESCRIPTION)
492 bool surfacique = (
Motcle(
option)==
"flux_surfacique_bords");
493 DoubleTab& es_valeurs = espace_stockage.
valeurs();
502 for (
int n_bord=0; n_bord<nb_front; n_bord++)
506 if (surfacique) la_cl->frontiere_dis().frontiere().faces().calculer_surfaces(aire);
508 int nfin = ndeb + le_bord.
nb_faces();
510 for (
int face=ndeb; face<nfin; face++)
511 es_valeurs(face) =
flux_bords_(face,comp) / (surfacique ? aire(face-ndeb) : 1.);
517 Cerr<<
"The method calculer_pour_post is not recognized for the option "<<
option<<finl;
527 if (!
equation().discretisation().is_vdf())
534 Cerr<<
"The method get_localisation_pour_post is not actually coded "<<finl;
545 Cerr <<
"Warning : 'Operateur_base::ajouter_flux()' must be overloaded" << finl;
570 char* theValue = getenv(
"TRUST_TEST_OPERATEUR_IMPLICITE");
571 if (theValue !=
nullptr) test_op=2;
574 char* theValue = getenv(
"TRUST_TEST_OPERATEUR_IMPLICITE_BLOQUANT");
575 if (theValue !=
nullptr) test_op=1;
577 if (test_op==0)
return;
580 DoubleTrav resu(inco);
581 auto& coeff_contribuer = mat_contribuer.get_set_coeff();
583 coeff_contribuer = 0;
590 const double eps = 1e-6;
595 for (
int i = 0; i < inco.
dimension(0); i++)
596 for (
auto j = tab1[i] - 1; j < tab1[i + 1] - 1; j++)
598 const int i2 = tab2[j] - 1;
600 DoubleTrav resu_DF(inco);
601 DoubleTab inco_pert(inco);
602 inco_pert[i2] += eps;
604 mat_DF(i, i2) = -(resu_DF[i] - resu[i]) / eps;
610 mat_DF += -mat_contribuer;
612 Cerr <<
"Max difference between contribuer_a_avec and finite difference jacobian : " << coeff_DF.mp_max_abs_vect() << finl;
614 else Cerr <<
"nbcomp > 1 : the finite difference jacobian matrix is not compared to the contribuer_a_avec one.";
616 mat_contribuer.ajouter_multvect(inco, resu);
619 mon_equation->solv_masse().appliquer(resu);
624 mon_equation->solv_masse().appliquer(un);
625 resu/=mp_max_vect(un);
626 double err=mp_max_abs_vect(resu);
627 Cerr<<
"Test contribuer_a_avec on " <<
que_suis_je() <<
" error: "<<err<<finl;
631 DoubleVect& resu_=resu;
632 Cerr<<
" size "<< resu_.
size()<<finl;
633 for (
int i=0; i<resu_.size(); i++)
634 if (std::fabs(resu_(i))>1e-10)
636 Cerr<<i <<
" "<< resu_(i)<<
" "<<finl;
const Domaine_Cl_dis_base & domaine_Cl_dis() const
DoubleTab & valeurs() override
Returns the array of field values at the current time.
virtual DoubleTab & valeurs()=0
class Champ_base This class is the base of the fields hierarchy.
bool has_champ(const Motcle &nom, OBS_PTR(FIELD_TYPE)&ref_champ) const
class Cond_lim Generic class used to represent any class
class Conds_lim This class represents a vector of boundary conditions.
class Domaine_Cl_dis_base Domaine_Cl_dis_base objects represent discretized boundary conditions
const Cond_lim & les_conditions_limites(int) const
Returns the i-th boundary condition.
class Domaine_dis_base This class is the base of the hierarchy of discretized domains.
const Domaine & domaine() const
int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out) override
Opens the file with the given mode and prot parameters. These parameters are the parameters of the st...
void precision(int) override
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.
Domaine_dis_base & domaine_dis()
Returns the discretized domain associated with the equation.
const Nom & le_nom() const override
Returns the name of the field.
const Noms & noms_compo() const
Returns the array of names of the field components.
int num_premiere_face() const
class Frontiere_dis_base Class representing a discretized boundary.
const Nom & le_nom() const override
Returns the name of the geometric boundary.
Matrice_Morse class - Represents a (sparse) matrix M, not necessarily square,.
const Equation_base & equation() const
Returns the reference to the equation pointed to by MorEqn::mon_equation.
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
const char * getChar() const
const Nom getSuffix(const char *const) const
int longueur() const
Returns the number of characters in the Nom string, including the null terminator.
const std::string & getString() const
An array of character strings (VECT(Nom)).
Base class for TRUST objects (Objet_U).
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.
class Operateur_base This class is the base of the hierarchy of objects representing an
virtual void ajouter_termes_croises(const DoubleTab &inco, const Probleme_base &autre_pb, const DoubleTab &autre_inco, DoubleTab &resu) const
void set_fichier(const Nom &)
virtual void modifier_pour_Cl(Matrice_Morse &, DoubleTab &) const
DOES NOTHING - to override in derived classes.
Champs_compris champs_compris_
virtual void calculer_dt_local(DoubleTab &) const
virtual void associer_champ(const Champ_Inc_base &, const std::string &nom_ch)
virtual DoubleTab & calculer(const DoubleTab &, DoubleTab &) const
virtual void contribuer_a_avec(const DoubleTab &, Matrice_Morse &) const
DOES NOTHING - to override in derived classes.
virtual void associer_domaine_cl_dis(const Domaine_Cl_dis_base &)
virtual int has_interface_blocs() const
void tester_contribuer_a_avec(const DoubleTab &, const Matrice_Morse &)
virtual void associer(const Domaine_dis_base &, const Domaine_Cl_dis_base &, const Champ_Inc_base &inco)=0
virtual void mettre_a_jour(double temps)
DOES NOTHING - to override in derived classes.
virtual void ajouter_flux(const DoubleTab &inconnue, DoubleTab &contribution) const
void ouvrir_fichier_partage(EcrFicPartage &, const Nom &, const int flag=1) const
Opening/creation of a shared file for printing an operator. To override in derived classes.
void calculer_pour_post(Champ_base &espace_stockage, const Nom &option, int comp) const override
bool has_champ(const Motcle &nom, OBS_PTR(Champ_base) &ref_champ) const override
virtual void preparer_calcul()
virtual void dimensionner_bloc_vitesse(Matrice_Morse &matrice) const
virtual double calculer_dt_stab() const
Computes dt_stab.
virtual void dimensionner_termes_croises(Matrice_Morse &, const Probleme_base &autre_pb, int nl, int nc) const
virtual void dimensionner(Matrice_Morse &) const
DOES NOTHING - to override in derived classes.
virtual void completer()
Associates the operator with the domaine_dis, the domaine_Cl_dis, and the unknown of its equation.
void get_noms_champs_postraitables(Noms &nom, Option opt=NONE) const override
virtual int impr(Sortie &os) const
DOES NOTHING - to override in derived classes.
virtual void contribuer_bloc_vitesse(const DoubleTab &, Matrice_Morse &) const
Motcle get_localisation_pour_post(const Nom &option) const override
virtual void dimensionner_blocs(matrices_t matrices, const tabs_t &semi_impl={ }) const
const Champ_base & get_champ(const Motcle &nom) const override
virtual void contribuer_au_second_membre(DoubleTab &) const
DOES NOTHING - to override in derived classes.
virtual void resetTime(double time)
virtual void ajouter_contribution_explicite_au_second_membre(const Champ_Inc_base &inconnue, DoubleTab &derivee) const
virtual void abortTimeStep()
const Nom description() const
virtual DoubleTab & ajouter(const DoubleTab &, DoubleTab &) const
virtual int systeme_invariant() const
virtual void ajouter_blocs(matrices_t matrices, DoubleTab &secmem, const tabs_t &semi_impl={ }) const
virtual void contribuer_termes_croises(const DoubleTab &inco, const Probleme_base &autre_pb, const DoubleTab &autre_inco, Matrice_Morse &matrice) const
virtual void calculer_flux(const DoubleTab &inconnue, DoubleTab &flux) const
void ouvrir_fichier(SFichier &os, const Nom &, const int flag=1) const
Opening/creation of a file for printing an operator. To override in derived classes.
class Periodique This class represents a periodic boundary condition.
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.
class Probleme_base It is a Probleme_U that is not a coupling.
bool & reprise_effectuee()
const Schema_Temps_base & schema_temps() const
Returns the time scheme associated with the problem.
static void abort()
Abort routine for TRUST on a fatal error.
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.
SFichier is to the C++ ofstream class what Sortie is to the C++ ostream class.
int nb_impr() const
Returns the number of outputs performed.
int gnuplot_header() const
int precision_impr() const
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out)
void precision(int pre) override
void setf(IOS_FORMAT code) override
Base class for output streams.
void set_col_width(int w)
virtual int add_col(const double ob)
_SIZE_ dimension(int d) const