TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
SolveurSys_base.h
1/****************************************************************************
2* Copyright (c) 2026, 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#ifndef SolveurSys_base_included
17#define SolveurSys_base_included
18
19#include <TRUSTTabs_forward.h>
20#include <Objet_U.h>
21#include <Nom.h>
22class Matrice_Base;
23
25{
26
27 Declare_base_sans_constructeur(SolveurSys_base);
28
29public :
30
32 // Each solver should return either 0 for an iterative method, or 1 for a direct method:
33 virtual int solveur_direct() const = 0;
34 // Search for "x" such that "a*x = b"
35 virtual int resoudre_systeme(const Matrice_Base& a, const DoubleVect& b, DoubleVect& x) = 0;
36 virtual int resoudre_systeme(const Matrice_Base& a, const DoubleVect& b, DoubleVect& x, int niter_max);
37 virtual void fixer_schema_temps_limpr(int l) { schema_temps_limpr_=l; }
38 void fixer_limpr(int l) { limpr_=l; }
39 void set_return_on_error(int ret) { return_on_error_ = ret; }
40 // Print solver convergence if impr option set in the solver AND if time scheme gives authorization
41 int limpr() const
42 {
43 if (schema_temps_limpr_ == 0)
44 return 0;
45 return limpr_;
46 }
47
48 virtual void reinit() { nouvelle_matrice_=true; }
49 bool nouvelle_matrice() const { return nouvelle_matrice_; }
51
52 // By default all solvers accept Matrice_Morse_Sym (override otherwise)
53 virtual int supporte_matrice_morse_sym() { return 1; };
54
55 // Call this to know if "b" (right hand side) must have an updated virtual space before calling resoudre(m, b, x)
56 // (this flag cannot be set, it is a property of the solver)
57 virtual int get_flag_updated_input() const { return 1; }
58 // Call this to tell the solver if you want "x" to have an updated virtual space (default is yes)
59 void set_flag_updated_result(bool flag) { echange_ev_resu_ = flag; }
60 int get_flag_updated_result() const { return echange_ev_resu_; }
61
62 void save_matrice_secmem_conditionnel(const Matrice_Base& la_matrice, const DoubleVect& secmem, const DoubleVect& solution, int binaire=1);
63 // Methods to set/get reuse_preconditioner_
64 void set_reuse_preconditioner(bool flag) { reuse_preconditioner_=flag; }
65 bool reuse_preconditioner() { return reuse_preconditioner_; }
66 const Nom& get_chaine_lue() const { return chaine_lue_ ; };
67 inline bool read_matrix() const { return read_matrix_; };
68 void set_read_matrix(bool flag) { read_matrix_ = flag; };
69 inline int save_matrix() const { return save_matrice_; };
70 void set_save_matrix(int flag) { save_matrice_ = flag; };
71 inline const Nom& le_nom() const override { return nom_; };
72 inline void nommer(const Nom& nom) override { nom_ = nom; };
73
74protected :
75 bool nouvelle_matrice_ = true; // Flag indicating whether storage or factorisation must be recomputed
76
77 // Whether to save the matrix (integer because multiple formats are possible: 1: TRUST 2: PETSc format 3: Matrix Market)
78 // WARNING: not a flag in the Param::ajouter_flag sense !!!
80
81 bool return_on_error_ = false; // Flag indicating whether to call exit() or return -1 if resoudre_ fails
82
83 // For reading/storing solver parameters:
85 void lecture(Entree&);
86private:
87 Nom nom_;
88 bool read_matrix_ = false; // Flag indicating whether a matrix should be read from file
89 int limpr_ = 0; // Flag to enable or disable printing of solver convergence
90 int schema_temps_limpr_ = 1; // Authorization printing flag set by the time scheme
91 bool echange_ev_resu_ = true; // User set flag to tell if the solver must do echange_espace_virtuel() on the result.
92 bool reuse_preconditioner_ = false; // Flag to reuse previous preconditioner (default false)
93};
94
95#endif
96
Matrice_Base class - Base class of the matrix hierarchy.
class Nom: a character string for naming TRUST objects.
Definition Nom.h:31
friend class Entree
Definition Objet_U.h:71
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54
virtual int supporte_matrice_morse_sym()
virtual int get_flag_updated_input() const
bool read_matrix() const
void set_reuse_preconditioner(bool flag)
const Nom & get_chaine_lue() const
void set_flag_updated_result(bool flag)
bool reuse_preconditioner()
void set_return_on_error(int ret)
void save_matrice_secmem_conditionnel(const Matrice_Base &la_matrice, const DoubleVect &secmem, const DoubleVect &solution, int binaire=1)
bool nouvelle_matrice() const
int limpr() const
virtual int resoudre_systeme(const Matrice_Base &a, const DoubleVect &b, DoubleVect &x)=0
int get_flag_updated_result() const
virtual void reinit()
void fixer_limpr(int l)
void nommer(const Nom &nom) override
Assigns a name to the Objet_U. Virtual method to override.
void set_save_matrix(int flag)
void set_read_matrix(bool flag)
void fixer_nouvelle_matrice(bool i)
virtual int solveur_direct() const =0
void lecture(Entree &)
int save_matrix() const
virtual void fixer_schema_temps_limpr(int l)
const Nom & le_nom() const override
Returns the name of the Objet_U. Virtual method to override: returns "neant" in this implementation.