16#include <Solv_GCP_NS.h>
17#include <Matrice_Bloc_Sym.h>
18#include <TRUSTTab_parts.h>
21#include <Perf_counters.h>
37 param.lire_avec_accolades_depuis(is);
47 param.
ajouter(
"precond", &le_precond_);
57 else if (mot ==
"quiet")
59 else if (mot ==
"solveur0")
64 else if (mot ==
"solveur1")
75static inline void corriger(DoubleVect& X,
double alpha,
double beta,
const DoubleVect& X1,
const DoubleVect& X0,
int prems,
int n)
79 for (; i < prems; i++)
82 X(i) += alpha * X1(i - prems);
85static inline void injecter(
const DoubleVect& X, DoubleVect& tmp,
int prems,
int n)
88 for (
int i = prems; i < sz; i++)
89 tmp(i) = X(i - prems);
91static inline void extraire(DoubleVect& X,
const DoubleVect& tmp,
int prems,
int n)
94 for (
int i = prems; i < sz; i++)
95 X(i - prems) = tmp(i);
100 Cerr <<
"The dedicated solver GCP_NS can be used only for blocks symetric matrixes" << finl;
101 Cerr <<
"containing 2*2 blocks for VEF discretization P0+P1." << finl;
129 const trustIdType nmax_min = 100, nmaxmax=10000000;
131 int nmax =
static_cast<int>(std::min(nmax0, nmaxmax));
133 double dold, dnew, alfa;
137 ConstDoubleTab_parts mo_solution(solution);
138 DoubleVect X1 = mo_solution[1];
151 DoubleVect X0 = mo_solution[0];
157 extraire(F0, secmem, 0, n0);
158 DoubleVect residu(F0);
160 extraire(F1, secmem, n0, n1);
163 injecter(X1, solution, n0, n1);
170 double norme = mp_norme_vect(residu);
172 le_precond_->preconditionner(A00, residu, g);
179 dold = mp_prodscal(residu, g);
182 Cout <<
"GCP NS residue = " << norme <<
" " << finl;
184 while ((norme >
seuil_) && (niter++ < nmax))
191 Cout <<
"Solveur1: ";
198 s = mp_prodscal(F0, p);
200 corriger(solution, alfa, alfa, X1, p, n0, n1);
202 norme = mp_norme_vect(residu);
203 if (norme >
seuil_ && dnew > 0)
206 Cout <<
"Solveur0: ";
208 le_precond_->preconditionner(A00, residu, g);
211 dnew = mp_prodscal(residu, g);
217 Cerr <<
"Error : dnew<0 in GCP NS solver." << finl;
218 Cerr <<
"Try to reduce the threshold value of solveur0" << finl;
219 Cerr <<
"to a value inferior to those of the GCP NS solver." << finl;
225 Cout <<
"GCP NS residue = " << norme <<
" " << finl;
226 if ((niter % 15) == 0)
232 Cerr <<
"No convergence after : " << niter <<
" iterations\n";
233 Cerr <<
" Residue : " << norme <<
"\n";
241 statistics().end_count(STD_COUNTERS::system_solver,-1,0);
243 statistics().begin_count(STD_COUNTERS::system_solver,statistics().get_last_opened_counter_level()+1);
Class defining operators and methods for all reading operation in an input flow (file,...
Matrice_Base class - Base class of the matrix hierarchy.
virtual DoubleVect & multvectT(const DoubleVect &, DoubleVect &) const
Multiplication of a vector by the transposed matrix.
virtual int nb_lignes() const =0
Return local number of lines (=size on the current proc).
virtual DoubleVect & multvect(const DoubleVect &, DoubleVect &) const
Multiplication of a vector by the matrix.
virtual DoubleVect & ajouter_multvect(const DoubleVect &x, DoubleVect &r) const
Matrix-vector multiply-accumulate operation (saxpy).
const Matrice & get_bloc(int i, int j) const override
int nb_bloc_lignes() const
int nb_bloc_colonnes(void) const
A character string (Nom) in uppercase.
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.
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.
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.
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
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.
SolveurSys solveur_poisson0
int lire_motcle_non_standard(const Motcle &, Entree &) override
Reads non-simple-type parameters of an Objet_U from an input stream.
int resoudre_systeme(const Matrice_Base &, const DoubleVect &, DoubleVect &) override
void set_param(Param ¶m) const override
SolveurSys solveur_poisson1
Base class for output streams.
_SIZE_ size_totale() const
void ajoute(_SCALAR_TYPE_ alpha, const TRUSTVect &y, Mp_vect_options opt=VECT_ALL_ITEMS)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")