FPCG.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) 2011-2012 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10  Copyright (C) 2023 Huawei (Yu Ankun)
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 Class
29  Foam::FPCG
30 
31 Group
32  grpLduMatrixSolvers
33 
34 Description
35  A 'faster' preconditioned conjugate gradient solver for
36  symmetric lduMatrices using a run-time selectable preconditioner.
37 
38  This is termed \em "faster" than the regular PCG since it combines
39  global reductions.
40 
41 SourceFiles
42  FPCG.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef Foam_FPCG_H
47 #define Foam_FPCG_H
48 
49 #include "lduMatrix.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class FPCG Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class FPCG
61 :
62  public lduMatrix::solver
63 {
64  // Private Member Data
65 
66  //- Cached preconditioner
67  mutable autoPtr<lduMatrix::preconditioner> preconPtr_;
68 
69 
70  // Private Member Functions
71 
72  //- Blocking version of sum(a*b), sum(mag(b))
73  static void gSumMagProd
74  (
75  FixedList<solveScalar, 2>& globalSum,
76  const solveScalarField& a,
77  const solveScalarField& b,
78  const label comm
79  );
80 
81  //- No copy construct
82  FPCG(const FPCG&) = delete;
83 
84  //- No copy assignment
85  void operator=(const FPCG&) = delete;
86 
87 
88 public:
89 
90  //- Runtime type information
91  TypeName("FPCG");
92 
93 
94  // Constructors
95 
96  //- Construct from matrix components and solver controls
97  FPCG
98  (
99  const word& fieldName,
100  const lduMatrix& matrix,
104  const dictionary& solverControls
105  );
106 
107 
108  //- Destructor
109  virtual ~FPCG() = default;
110 
111 
112  // Member Functions
113 
114  //- Solve the matrix with this solver
116  (
118  const solveScalarField& source,
119  const direction cmpt=0
120  ) const;
121 
122  //- Solve the matrix with this solver
123  virtual solverPerformance solve
124  (
125  scalarField& psi,
126  const scalarField& source,
127  const direction cmpt=0
128  ) const;
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace Foam
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 #endif
139 
140 // ************************************************************************* //
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
Definition: lduMatrix.H:323
uint8_t direction
Definition: direction.H:46
virtual solverPerformance scalarSolve(solveScalarField &psi, const solveScalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
Definition: FPCG.C:93
A 1D vector of objects of type <T> with a fixed length <N>.
Definition: HashTable.H:107
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual ~FPCG()=default
Destructor.
const lduMatrix & matrix() const noexcept
Definition: lduMatrix.H:318
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
Definition: FPCG.C:253
A field of fields is a PtrList of fields with reference counting.
Definition: FieldField.H:51
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
A class for handling words, derived from Foam::string.
Definition: word.H:63
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
Abstract base-class for lduMatrix solvers.
Definition: lduMatrix.H:141
const lduInterfaceFieldPtrsList & interfaces() const noexcept
Definition: lduMatrix.H:333
TypeName("FPCG")
Runtime type information.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: lduMatrix.H:80
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
Definition: lduMatrix.H:328
A &#39;faster&#39; preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time select...
Definition: FPCG.H:55
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const volScalarField & psi
const word & fieldName() const noexcept
Definition: lduMatrix.H:313
Namespace for OpenFOAM.