TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Precond_base.cpp
1/****************************************************************************
2* Copyright (c) 2022, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#include <Precond_base.h>
17#include <Motcle.h>
18
19Implemente_base_sans_constructeur(Precond_base,"Precond_base",Objet_U);
20// XD precond_base objet_u precond_base INHERITS_BRACE Basic class for preconditioning.
21
22
28
30{
31 return s << que_suis_je();
32}
33
35{
36 return is;
37}
38
39/*! @brief this method must be called before preconditionner() whenever the matrix changes (coefficients only or coefficients and structure) to
40 *
41 * tell the object to recompute some matrix related data.
42 *
43 */
45{
46 switch(x)
47 {
48 case READY:
49 break;
50 case REINIT_COEFF:
51 if (status_ != REINIT_ALL) status_ = REINIT_COEFF;
52 break;
53 case REINIT_ALL:
54 status_ = REINIT_ALL;
55 break;
56 default:
57 Cerr << "Error Precond_base::reinit" << finl;
58 exit();
59 }
60}
61
62/*! @brief returns 1 if the implementation accepts Matrice_Morse_Sym matrices, otherwise 0.
63 *
64 * (must be reimplemented if answer is 0)
65 *
66 */
71
72
73
74
75/*! @brief Call this method to change the behaviour of the preconditionner() method 0-> result will not have an up-to-date virtual space
76 *
77 * 1-> yes it will (this must be the default value in the implementation)
78 *
79 */
84
85/*! @brief Call to the prepare() method if reinit() has been called previously, then call to preconditionner_().
86 *
87 * ..
88 * If echange_ev_solution is not zero, the solution vector will have an updated virtual space.
89 *
90 */
91int Precond_base::preconditionner(const Matrice_Base& m, const DoubleVect& src, DoubleVect& solution)
92{
93 if (status_ != READY)
94 prepare(m, src);
95 // implementation of the prepare() method must call ancestor methods until Precond_base::prepare();
96 assert(status_ == READY);
97 int ok = preconditionner_(m, src, solution);
98 return ok;
99}
100
101/*! @brief prepares the preconditionner if needed after a matrix change (reinit() call).
102 *
103 * prepare() is public, in case we want to perform preparation separately from preconditionning (eg nested solvers)
104 * but calling prepare() is not mandatory (done automatically in preconditionner())
105 * m is the new matrix, and md is the descriptor of the solution vector.
106 *
107 */
108void Precond_base::prepare(const Matrice_Base& m, const DoubleVect& v)
109{
110 if (status_ != READY)
111 prepare_(m, v);
112 assert(status_ == READY);
113}
114
115/*! @brief this method must be overloaded if some preparation is necessary.
116 *
117 * It is called after a call to reinit() and before the next call to preconditionner_().
118 * Do not forget to call the prepare_() method of the ancestor (at the end of the routine, otherwise
119 * status will be put to READY) and use get_status() to know what should be prepared.
120 *
121 */
122void Precond_base::prepare_(const Matrice_Base& m, const DoubleVect& v)
123{
124 status_ = READY;
125}
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
Classe Matrice_Base Classe de base de la hierarchie des matrices.
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
const Nom & que_suis_je() const
renvoie la chaine identifiant la classe.
Definition Objet_U.cpp:104
virtual Entree & readOn(Entree &)
Lecture d'un Objet_U sur un flot d'entree Methode a surcharger.
Definition Objet_U.cpp:293
virtual Sortie & printOn(Sortie &) const
Ecriture de l'objet sur un flot de sortie Methode a surcharger.
Definition Objet_U.cpp:282
int preconditionner(const Matrice_Base &, const DoubleVect &src, DoubleVect &solution)
Call to the prepare() method if reinit() has been called previously, then call to preconditionner_().
void prepare(const Matrice_Base &, const DoubleVect &src)
prepares the preconditionner if needed after a matrix change (reinit() call).
void set_echange_espace_virtuel_resultat(int flag)
Call this method to change the behaviour of the preconditionner() method 0-> result will not have an ...
int echange_ev_solution_
virtual void prepare_(const Matrice_Base &, const DoubleVect &)
this method must be overloaded if some preparation is necessary.
void reinit(Init_Status x=REINIT_ALL)
this method must be called before preconditionner() whenever the matrix changes (coefficients only or...
virtual int preconditionner_(const Matrice_Base &, const DoubleVect &src, DoubleVect &solution)=0
virtual int supporte_matrice_morse_sym()
returns 1 if the implementation accepts Matrice_Morse_Sym matrices, otherwise 0.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Classe de base des flux de sortie.
Definition Sortie.h:52