TrioCFD 1.9.9_beta
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 and readOn
25
27{
28 return s;
29}
30
32{
33 is >> solveur;
34 solveur.nommer("PrecondSolv");
35 // To avoid excessive output (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 // Some solvers may need the virtual space,
59 // we compute the entire vector:
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 // We want to return a vector with an up-to-date virtual space
68 // Rather than redoing an exchange we multiply all elements
69 // but the virtual space must already be up to date beforehand:
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
Matrice_Base class - Base class of the matrix hierarchy.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Definition Objet_U.cpp:289
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
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.
Base class for output streams.
Definition Sortie.h:52