DiagonalPreconditioner.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-2016 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::DiagonalPreconditioner
29
30Description
31 Diagonal preconditioner for both symmetric and asymmetric matrices.
32
33 The inverse (reciprocal for scalar) of the diagonal is calculated and
34 stored.
35
36SourceFiles
37 DiagonalPreconditioner.C
38
39\*---------------------------------------------------------------------------*/
40
41#ifndef DiagonalPreconditioner_H
42#define DiagonalPreconditioner_H
43
44#include "LduMatrix.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
50
51/*---------------------------------------------------------------------------*\
52 Class DiagonalPreconditioner Declaration
53\*---------------------------------------------------------------------------*/
54
55template<class Type, class DType, class LUType>
57:
58 public LduMatrix<Type, DType, LUType>::preconditioner
59{
60 // Private data
61
62 //- The inverse (reciprocal for scalar) diagonal
63 Field<DType> rD;
64
65
66 // Private Member Functions
67
68 //- No copy construct
70
71 //- No copy assignment
72 void operator=(const DiagonalPreconditioner&) = delete;
73
74
75public:
76
77 //- Runtime type information
78 TypeName("diagonal");
79
80
81 // Constructors
82
83 //- Construct from matrix components and preconditioner data dictionary
85 (
87 const dictionary& preconditionerDict
88 );
89
90
91 // Destructor
93 virtual ~DiagonalPreconditioner() = default;
94
95
96 // Member Functions
97
98 //- Read and reset the preconditioner parameters from the given
99 // dictionary
100 virtual void read(const dictionary& preconditionerDict);
101
102 //- Return wA the preconditioned form of residual rA
103 virtual void precondition
104 (
105 Field<Type>& wA,
106 const Field<Type>& rA
107 ) const;
108
109 //- Return wT the transpose-matrix preconditioned form of
110 // residual rT.
111 virtual void preconditionT
112 (
113 Field<Type>& wT,
114 const Field<Type>& rT
115 ) const
116 {
117 return(precondition(wT, rT));
118 }
119};
120
121
122// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123
124} // End namespace Foam
125
126// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127
128#ifdef NoRepository
129 #include "DiagonalPreconditioner.C"
130#endif
131
132// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133
134#endif
135
136// ************************************************************************* //
Diagonal preconditioner for both symmetric and asymmetric matrices.
virtual ~DiagonalPreconditioner()=default
virtual void precondition(Field< Type > &wA, const Field< Type > &rA) const
Return wA the preconditioned form of residual rA.
TypeName("diagonal")
Runtime type information.
virtual void read(const dictionary &preconditionerDict)
Read and reset the preconditioner parameters from the given.
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of.
Generic templated field type.
Definition: Field.H:82
Abstract base-class for LduMatrix solvers.
Definition: LduMatrix.H:116
LduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: LduMatrix.H:88
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Namespace for OpenFOAM.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73