TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
SolveurPP1B.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 <SolveurPP1B.h>
17#include <Champ_P1_isoP1Bulle.h>
18#include <Solv_AMG.h>
19#include <Perf_counters.h>
20
21Implemente_instanciable(SolveurPP1B,"SolveurPP1B",SolveurSys_base);
22
23// printOn
25{
26 return s << que_suis_je();
27}
28
29
30// readOn
32{
33 return is;
34}
35
36static int nw=0;
38 const DoubleVect& second_membre,
39 DoubleVect& x)
40{
41 // Stop the solv_sys_counter_ counter to not count the changing base
42 statistics().end_count(STD_COUNTERS::system_solver,-1,0);
43 b_ = second_membre;
44 assembleur_pression_->changer_base_second_membre(b_);
45 assembleur_pression_->changer_base_pression(x);
46 int nb_iter=solveur_pression_.resoudre_systeme(A,b_,x);
47 // Advice to use AMG solver based on PCFieldsplit from PETSc
48 if (!sub_type(Solv_AMG, solveur_pression_.valeur()))
49 {
50 nw++;
51 if (nw<100 && x.size_array()*Process::nproc()>100000)
52 {
53 Cerr << finl;
54 Cerr << "************** Advice (printed only on the first 100 time steps) **************" << finl;
55 Cerr << "You should use AMG (Algebric Multigrid) solver for your pressure solver problem" << finl;
56 Cerr << "which benefits from the block P0P1 structure of the pressure matrix." << finl;
57 Cerr << "Something like: solveur_pression AMG GCP { atol|rtol XXX impr } " << finl;
58 Cerr << "For the caracteristics of your problem, it will have much faster convergence !" << finl;
59 Cerr << "*******************************************************************************" << finl << finl;
60 }
61 }
62 assembleur_pression_->changer_base_pression_inverse(x);
63 statistics().begin_count(STD_COUNTERS::system_solver,statistics().get_last_opened_counter_level()+1);
64 return nb_iter;
65}
66
67
68
70 const DoubleVect& b,
71 DoubleVect& x,
72
73 int niter_max)
74{
76}
77
78
79// Assignment of the pressure assembler and solver
80int SolveurPP1B::associer(const Assembleur_P_VEFPreP1B& assembleur_pression, const SolveurSys& solveur_pression)
81{
82 assembleur_pression_=assembleur_pression;
83 solveur_pression_=solveur_pression;
84 fixer_limpr(-1); // No printing
85 return 0;
86}
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.
const Nom & que_suis_je() const
Returns the string identifying the class.
Definition Objet_U.cpp:104
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
static int nproc()
Returns the number of processors in the current group. See Comm_Group::nproc() and PE_Groups::current...
Definition Process.cpp:102
AMD solver wrapper to switch to the more robust/performant AMG preconditioner on CPU/GPU Nvidia/GPU A...
Definition Solv_AMG.h:28
int associer(const Assembleur_P_VEFPreP1B &, const SolveurSys &)
SolveurSys solveur_pression_
Definition SolveurPP1B.h:42
int resoudre_systeme(const Matrice_Base &, const DoubleVect &, DoubleVect &) override
DoubleVect b_
Definition SolveurPP1B.h:44
void fixer_limpr(int l)
class SolveurSys A SolveurSys represents any class
Definition SolveurSys.h:32
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const