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 | Copyright (C) 2011-2016 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  // Private Member Functions
64 
65  //- Disallow default bitwise copy construct
67 
68  //- Disallow default bitwise assignment
69  void operator=(const DiagonalPreconditioner&);
70 
71 
72 public:
73 
74  //- Runtime type information
75  TypeName("diagonal");
76 
77 
78  // Constructors
79 
80  //- Construct from matrix components and preconditioner data dictionary
82  (
83  const typename LduMatrix<Type, DType, LUType>::solver& sol,
84  const dictionary& preconditionerDict
85  );
86 
87 
88  // Destructor
89 
90  virtual ~DiagonalPreconditioner()
91  {}
92 
93 
94  // Member Functions
95 
96  //- Read and reset the preconditioner parameters from the given
97  // dictionary
98  virtual void read(const dictionary& preconditionerDict);
99 
100  //- Return wA the preconditioned form of residual rA
101  virtual void precondition
102  (
103  Field<Type>& wA,
104  const Field<Type>& rA
105  ) const;
106 
107  //- Return wT the transpose-matrix preconditioned form of
108  // residual rT.
109  virtual void preconditionT
110  (
111  Field<Type>& wT,
112  const Field<Type>& rT
113  ) const
114  {
115  return(precondition(wT, rT));
116  }
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:137
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
LduMatrix is a general matrix class in which the coefficients are stored as three arrays...
Definition: LduMatrix.H:69
Namespace for OpenFOAM.
virtual void read(const dictionary &preconditionerDict)
Read and reset the preconditioner parameters from the given.