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 -------------------------------------------------------------------------------
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::DiagonalPreconditioner
29 
30 Description
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 
36 SourceFiles
37  DiagonalPreconditioner.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef DiagonalPreconditioner_H
42 #define DiagonalPreconditioner_H
43 
44 #include "LduMatrix.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class DiagonalPreconditioner Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 template<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 
75 public:
76 
77  //- Runtime type information
78  TypeName("diagonal");
79 
80 
81  // Constructors
82 
83  //- Construct from matrix components and preconditioner data dictionary
85  (
86  const typename LduMatrix<Type, DType, LUType>::solver& sol,
87  const dictionary& preconditionerDict
88  );
89 
90 
91  // Destructor
92 
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 // ************************************************************************* //
Foam::DiagonalPreconditioner
Diagonal preconditioner for both symmetric and asymmetric matrices.
Definition: DiagonalPreconditioner.H:55
Foam::LduMatrix
LduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Definition: LduMatrix.H:72
LduMatrix.H
Foam::LduMatrix::solver
Abstract base-class for LduMatrix solvers.
Definition: LduMatrix.H:115
Foam::DiagonalPreconditioner::read
virtual void read(const dictionary &preconditionerDict)
Read and reset the preconditioner parameters from the given.
Definition: DiagonalPreconditioner.C:58
Foam::Field< DType >
Foam::DiagonalPreconditioner::TypeName
TypeName("diagonal")
Runtime type information.
Foam::DiagonalPreconditioner::preconditionT
virtual void preconditionT(Field< Type > &wT, const Field< Type > &rT) const
Return wT the transpose-matrix preconditioned form of.
Definition: DiagonalPreconditioner.H:111
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::DiagonalPreconditioner::precondition
virtual void precondition(Field< Type > &wA, const Field< Type > &rA) const
Return wA the preconditioned form of residual rA.
Definition: DiagonalPreconditioner.C:64
Foam::DiagonalPreconditioner::~DiagonalPreconditioner
virtual ~DiagonalPreconditioner()=default
DiagonalPreconditioner.C