TRUST 1.9.8
HPC thermohydraulic platform
Loading...
Searching...
No Matches
SolveurSys_base.cpp
1/****************************************************************************
2* Copyright (c) 2025, 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 <SolveurSys_base.h>
17#include <EcrFicCollecte.h>
18#include <Matrice_Base.h>
19#include <MD_Vector_tools.h>
20#include <SChaine.h>
21#include <Motcle.h>
22
23Implemente_base_sans_constructeur(SolveurSys_base,"SolveurSys_base",Objet_U);
24// XD solveur_sys_base class_generic solveur_sys_base INHERITS_BRACE Basic class to solve the linear system.
25
29
31{
32 return s << que_suis_je();
33}
34
36{
37 return is;
38}
39
41 const DoubleVect& b,
42 DoubleVect& x,
43 int niter_max)
44{
46 return resoudre_systeme(A,b,x);
47}
48
49
50void SolveurSys_base::save_matrice_secmem_conditionnel(const Matrice_Base& la_matrice, const DoubleVect& secmem, const DoubleVect& solution, int binaire2 )
51{
52 int binaire=binaire2;
53 if (save_matrice_==1)
54 {
55 // on simule l'ecriture d'une Matrice et non d'une Matrice_Base
56 // pour aider a la relecture
57 {
58 EcrFicCollecte sortie;
59 sortie.set_bin(binaire);
60 sortie.ouvrir("Matrice.sa");
61 sortie<<la_matrice.que_suis_je()<<finl;
62 sortie<<la_matrice;
63 }
64 // on sauvegarde le Secmem avec les espaces virtuels !!!!!
65 {
66 EcrFicCollecte sortie;
67 sortie.set_bin(binaire);
68 sortie.ouvrir("Secmem.sa");
70 }
71 // on sauvegarde la solution avec les espaces virtuels !!!!!
72 {
73 EcrFicCollecte sortie;
74 sortie.set_bin(binaire);
75 sortie.ouvrir("Solution.sa");
77 }
78 Cout <<"Saving of the matrix, secmem and solution ended."<<finl;
79 }
80}
81
82
83// Lecture des parametres du solveurs
84// Ex: solveur type { ... }
85// chaine_lue_ = "type { ... }"
87{
88 // Lecture de la chaine de mot cles
89 Motcle accolade_ouverte("{");
90 Motcle accolade_fermee("}");
91 Motcle motlu;
92 Nom nomlu;
93 is >> motlu;
94 SChaine prov;
95 prov<<motlu;
96 is >> motlu;
97 if (motlu != accolade_ouverte)
98 {
99 Cerr << "Error while reading parameters of Petsc: " << finl;
100 Cerr << "We expected " << accolade_ouverte << " instead of " << motlu << finl;
102 }
103 prov<<" { ";
104 int nb_acco=1;
105 while (nb_acco!=0)
106 {
107 is >> nomlu;
108 if ((Motcle)nomlu=="READ_MATRIX") set_read_matrix(true);
109 prov<<nomlu<<" ";
110 if (nomlu==accolade_ouverte)
111 nb_acco++;
112 else if (nomlu==accolade_fermee)
113 nb_acco--;
114 }
115 chaine_lue_=prov.get_str();
116}
117
Ecriture dans un fichier Cette classe implemente les operateurs et les methodes virtuelles de la clas...
int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::out) override
Ouvre le fichier avec les parametres mode et prot donnes Ces parametres sont les parametres de la met...
Class defining operators and methods for all reading operation in an input flow (file,...
Definition Entree.h:42
static void dump_vector_with_md(const DoubleVect &, Sortie &)
dumps vector v with its parallel descriptor to os.
Classe Matrice_Base Classe de base de la hierarchie des matrices.
Une chaine de caractere (Nom) en majuscules.
Definition Motcle.h:26
class Nom Une chaine de caractere pour nommer les objets de TRUST
Definition Nom.h:31
classe Objet_U Cette classe est la classe de base des Objets de TRUST
Definition Objet_U.h:73
friend class Entree
Definition Objet_U.h:76
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
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
Cette classe derivee de Sortie empile ce qu'on lui envoie dans une chaine de caracteres.
Definition SChaine.h:26
const char * get_str() const
returns a copy of the string stored by the SChaine
Definition SChaine.cpp:72
void save_matrice_secmem_conditionnel(const Matrice_Base &la_matrice, const DoubleVect &secmem, const DoubleVect &solution, int binaire=1)
virtual int resoudre_systeme(const Matrice_Base &a, const DoubleVect &b, DoubleVect &x)=0
void set_read_matrix(bool flag)
void lecture(Entree &)
Classe de base des flux de sortie.
Definition Sortie.h:52
void set_bin(bool bin) override
Change le mode d'ecriture du fichier.
Definition Sortie.cpp:255