TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
PrecondSolv.cpp
1/****************************************************************************
2* Copyright (c) 2024, 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 <PrecondSolv.h>
17#include <Check_espace_virtuel.h>
18
19Implemente_instanciable(PrecondSolv,"PrecondSolv",Precond_base);
20// XD precondsolv precond_base precondsolv NO_BRACE not_set
21// XD attr solveur solveur_sys_base solveur REQ Solver type.
22
23//
24// printOn et readOn
25
27{
28 return s;
29}
30
32{
33 is >> solveur;
34 solveur.nommer("PrecondSolv");
35 // Pour eviter trop d'affichage (Convergence)
36 if (!solveur->limpr())
37 solveur->fixer_limpr(-1);
38 return is;
39}
40
41void PrecondSolv::prepare_(const Matrice_Base& m, const DoubleVect& src)
42{
43 solveur->reinit();
45}
46
47/*! @brief Calcule la solution du systeme lineaire: A * solution = b avec la methode de relaxation PrecondSolv.
48 *
49 */
51 const DoubleVect& b,
52 DoubleVect& solution)
53{
54 double norme=mp_norme_vect(b);
55 if (norme > 0.)
56 {
57 DoubleVect b2(b);
58 // Certains solveurs peuvent avoir besoin de l'espace virtuel,
59 // on calcule tout le vecteur:
60 assert_espace_virtuel_vect(b2);
61 operator_multiply(b2, 1. / norme, VECT_ALL_ITEMS);
62
63 solveur.resoudre_systeme(matrice, b2, solution);
64
66 {
67 // On veut renvoyer un vecteur avec espace virtuel a jour
68 // Plutot que de refaire un echange on multiplie tous les elements
69 // mais il faut que l'espace virtuel soit deja a jour avant:
70 assert_espace_virtuel_vect(solution);
71 operator_multiply(solution, norme, VECT_ALL_ITEMS);
72 }
73 else
74 {
75 operator_multiply(solution, norme);
76 }
77 }
78 else
79 {
81 {
82 operator_egal(solution, 0., VECT_ALL_ITEMS);
83 }
84 else
85 {
86 operator_egal(solution, 0.);
87 }
88 }
89 return 1;
90}
91
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.
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
SolveurSys solveur
Definition PrecondSolv.h:40
void prepare_(const Matrice_Base &, const DoubleVect &src) override
this method must be overloaded if some preparation is necessary.
int preconditionner_(const Matrice_Base &, const DoubleVect &, DoubleVect &) override
Calcule la solution du systeme lineaire: A * solution = b avec la methode de relaxation PrecondSolv.
int echange_ev_solution_
virtual void prepare_(const Matrice_Base &, const DoubleVect &)
this method must be overloaded if some preparation is necessary.
Classe de base des flux de sortie.
Definition Sortie.h:52