TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
SolveurSys.cpp
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#include <SolveurSys.h>
17#include <Motcle.h>
18#include <Param.h>
19#include <Perf_counters.h>
20
21Implemente_instanciable(SolveurSys, "SolveurSys", OWN_PTR(SolveurSys_base));
22
23Sortie& SolveurSys::printOn(Sortie& s) const
24{
25 return OWN_PTR(SolveurSys_base)::printOn(s);
26}
27
28Entree& SolveurSys::readOn(Entree& is)
29{
30 Param param(que_suis_je());
31 Nom solver_name;
32 param.ajouter("solveur_pression", &solver_name, Param::REQUIRED);
33 param.lire_sans_accolade(is);
34 if (solver_name.majuscule() == "GEN")
35 {
36 Cerr << "Error: Sparskit based solver 'solveur gen { solv_elem bicgstab|gmres ... }' removed in v1.9.8" << finl;
37 Cerr << " It can be replaced by more efficient PETSc equivalent solvers." << finl;
39 }
40 Nom type_solv_sys("Solv_");
41 type_solv_sys += solver_name;
42 typer(type_solv_sys);
43 return is >> valeur();
44}
45
46static int nested_solver = 0;
47
48int SolveurSys::resoudre_systeme(const Matrice_Base& matrice, const DoubleVect& secmem, DoubleVect& solution)
49{
50 valeur().save_matrice_secmem_conditionnel(matrice, secmem, solution);
51 // Cas de solveurs emboites: n'afficher que le temps du solveur "exterieur"
52 // temporaire : test issu du baltik IJK_FT en commentaire car sinon erreur dans .TU avec PETSC (solveurs Ax=B => 0%)
53 statistics().begin_count(STD_COUNTERS::system_solver,statistics().get_last_opened_counter_level()+1);
54 nested_solver++;
55 int nb_iter = valeur().resoudre_systeme(matrice, secmem, solution);
56 nested_solver--;
57 // temporaire : test issu du baltik IJK_FT en commentaire car sinon erreur avec script Check_solver.sh pour test PETSC_VEF
58 // Si limpr vaut -1, on n'imprime pas
59 //if (le_nom()=="??")
60 // Process::exit("Solver not named. Fix!");
61 if (valeur().limpr() >= 0)
62 Cout << " Convergence in " << nb_iter << " iterations for " << le_nom() << finl;
63 if (valeur().limpr() == 1)
64 Cout << "clock Ax=B: " << statistics().get_time_since_last_open(STD_COUNTERS::system_solver) << " s for " << le_nom() << finl;
65 statistics().end_count(STD_COUNTERS::system_solver,1,nb_iter);
66
67 return nb_iter;
68}
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.
Nom & majuscule()
Transforme le nom en majuscules Seules les lettres 'a'-'z' sont modifiees.
Definition Nom.cpp:180
@ REQUIRED
Definition Param.h:115
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.
Definition Process.cpp:455
class SolveurSys Un SolveurSys represente n'importe qu'elle classe
Definition SolveurSys.h:32
int resoudre_systeme(const Matrice_Base &matrice, const DoubleVect &secmem, DoubleVect &solution)
const Nom & le_nom() const override
Definition SolveurSys.h:36
Classe de base des flux de sortie.
Definition Sortie.h:52