All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DiagonalPreconditioner.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::DiagonalPreconditioner
26 
27 Description
28  Diagonal preconditioner for both symmetric and asymmetric matrices.
29 
30  The inverse (reciprocal for scalar) of the diagonal is calculated and
31  stored.
32 
33 SourceFiles
34  DiagonalPreconditioner.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef DiagonalPreconditioner_H
39 #define DiagonalPreconditioner_H
40 
41 #include "LduMatrix.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class DiagonalPreconditioner Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type, class DType, class LUType>
54 :
55  public LduMatrix<Type, DType, LUType>::preconditioner
56 {
57  // Private Data
58 
59  //- The inverse (reciprocal for scalar) diagonal
60  Field<DType> rD;
61 
62 
63 public:
64 
65  //- Runtime type information
66  TypeName("diagonal");
67 
68 
69  // Constructors
70 
71  //- Construct from matrix components and preconditioner data dictionary
73  (
74  const typename LduMatrix<Type, DType, LUType>::solver& sol,
75  const dictionary& preconditionerDict
76  );
77 
78  //- Disallow default bitwise copy construction
80 
81 
82  // Destructor
83 
84  virtual ~DiagonalPreconditioner()
85  {}
86 
87 
88  // Member Functions
89 
90  //- Read and reset the preconditioner parameters from the given
91  // dictionary
92  virtual void read(const dictionary& preconditionerDict);
93 
94  //- Return wA the preconditioned form of residual rA
95  virtual void precondition
96  (
97  Field<Type>& wA,
98  const Field<Type>& rA
99  ) const;
100 
101  //- Return wT the transpose-matrix preconditioned form of
102  // residual rT.
103  virtual void preconditionT
104  (
105  Field<Type>& wT,
106  const Field<Type>& rT
107  ) const
108  {
109  return(precondition(wT, rT));
110  }
111 
112 
113  // Member Operators
114 
115  //- Disallow default bitwise assignment
116  void operator=(const DiagonalPreconditioner&) = delete;
117 };
118 
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 } // End namespace Foam
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 #ifdef NoRepository
127  #include "DiagonalPreconditioner.C"
128 #endif
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 #endif
133 
134 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void precondition(Field< Type > &wA, const Field< Type > &rA) const
Return wA the preconditioned form of residual rA.
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of.
Diagonal preconditioner for both symmetric and asymmetric matrices.
TypeName("diagonal")
Runtime type information.
Abstract base-class for LduMatrix solvers.
Definition: LduMatrix.H:112
void operator=(const DiagonalPreconditioner &)=delete
Disallow default bitwise assignment.
LduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: LduMatrix.H:69
DiagonalPreconditioner(const typename LduMatrix< Type, DType, LUType >::solver &sol, const dictionary &preconditionerDict)
Construct from matrix components and preconditioner data dictionary.
Namespace for OpenFOAM.
virtual void read(const dictionary &preconditionerDict)
Read and reset the preconditioner parameters from the given.