PPCG.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019-2020 Mattijs Janssens
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::PPCG
29 
30 Description
31  Preconditioned pipelined conjugate gradient solver for symmetric
32  lduMatrices using a run-time selectable preconditioner.
33 
34  Reference:
35  \verbatim
36  P. Ghysels, W. Vanroose.
37  "Hiding global synchronization latency in the
38  preconditioned Conjugate Gradient algorithm"
39  \endverbatim
40  and implementation details from
41  \verbatim
42  Paul Eller, William Gropp
43  "Scalable Non-blocking Preconditioned Conjugate Gradient Methods"
44  \endverbatim
45 
46 SourceFiles
47  PPCG.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef PPCG_H
52 #define PPCG_H
53 
54 #include "lduMatrix.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class PPCG Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class PPCG
66 :
67  public lduMatrix::solver
68 {
69  // Private Member Functions
70 
71  //- Non-blocking version of sum(a*b), sum(a*c), sum(mag(sumMag))
72  void gSumMagProd
73  (
74  FixedList<solveScalar, 3>& globalSum,
75  const solveScalarField& a,
76  const solveScalarField& b,
77  const solveScalarField& c,
78  const solveScalarField& sumMag,
79  label& outstandingRequest,
80  const label comm
81  ) const;
82 
83  //- No copy construct
84  PPCG(const PPCG&) = delete;
85 
86  //- No copy assignment
87  void operator=(const PPCG&) = delete;
88 
89 
90 protected:
91 
92  //- CG solver. Operates either in conjugate-gradient mode or
93  //- conjugate residual
95  (
97  const solveScalarField& source,
98  const direction cmpt,
99  const bool cgMode
100  ) const;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("PPCG");
107 
108 
109  // Constructors
110 
111  //- Construct from matrix components and solver controls
112  PPCG
113  (
114  const word& fieldName,
115  const lduMatrix& matrix,
119  const dictionary& solverControls
120  );
121 
122 
123  //- Destructor
124  virtual ~PPCG() = default;
125 
126 
127  // Member Functions
128 
129  //- Solve the matrix with this solver
130  virtual solverPerformance solve
131  (
132  scalarField& psi,
133  const scalarField& source,
134  const direction cmpt=0
135  ) const;
136 };
137 
138 
139 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
140 
141 } // End namespace Foam
142 
143 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
144 
145 #endif
146 
147 // ************************************************************************* //
Foam::lduMatrix::solver::interfaces
const lduInterfaceFieldPtrsList & interfaces() const
Definition: lduMatrix.H:246
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::FieldField
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:53
Foam::lduMatrix
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: lduMatrix.H:83
Foam::sumMag
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:332
Foam::lduMatrix::solver::matrix
const lduMatrix & matrix() const
Definition: lduMatrix.H:231
Foam::lduMatrix::solver
Abstract base-class for lduMatrix solvers.
Definition: lduMatrix.H:97
lduMatrix.H
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::Field< solveScalar >
Foam::UPtrList< const lduInterfaceField >
Foam::PPCG::solve
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
Definition: PPCG.C:283
Foam::PPCG::TypeName
TypeName("PPCG")
Runtime type information.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::PPCG::~PPCG
virtual ~PPCG()=default
Destructor.
Foam::lduMatrix::solver::interfaceBouCoeffs
const FieldField< Field, scalar > & interfaceBouCoeffs() const
Definition: lduMatrix.H:236
Foam::FixedList
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:104
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::lduMatrix::solver::fieldName
const word & fieldName() const
Definition: lduMatrix.H:226
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::PPCG::scalarSolveCG
solverPerformance scalarSolveCG(solveScalarField &psi, const solveScalarField &source, const direction cmpt, const bool cgMode) const
Definition: PPCG.C:82
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::PPCG
Preconditioned pipelined conjugate gradient solver for symmetric lduMatrices using a run-time selecta...
Definition: PPCG.H:64
Foam::lduMatrix::solver::interfaceIntCoeffs
const FieldField< Field, scalar > & interfaceIntCoeffs() const
Definition: lduMatrix.H:241
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:51