Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / foam / matrices / blockLduMatrix / BlockAmg / BlockAmgLevel.H
blob646b305f6224b74d83955d431163514021f19b52
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     BlockAmgLevel
27 Description
28     Algebraic multigrid level virtual base class for BlockLduMatrix
30 Author
31     Klas Jareteg, 2012-12-13
33 SourceFiles
34     BlockAmgLevel.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef BlockAmgLevel_H
39 #define BlockAmgLevel_H
41 #include "BlockLduMatrix.H"
42 #include "BlockMatrixCoarsening.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
51 template<class Type>
52 class fineBlockAmgLevel;
54 template<class Type>
55 class coarseBlockAmgLevel;
57 template<class Type>
58 class BlockAmgCycle;
60 template<class Type>
61 class BlockMatrixCoarsening;
63 template<class Type>
64 class BlockAmgSolver;
66 template<class Type>
67 class BlockAmgPrecon;
69 /*---------------------------------------------------------------------------*\
70                            Class BlockAmgLevel Declaration
71 \*---------------------------------------------------------------------------*/
73 template<class Type>
74 class BlockAmgLevel
76 public:
77     //- Runtime type information
78         TypeName("BlockAmgLevel");
81     // Destructor
83         virtual ~BlockAmgLevel()
84         {}
87     // Member Functions
89         //- Return reference to x
90         virtual Field<Type>& x() = 0;
92         //- Return reference to b
93         virtual Field<Type>& b() = 0;
95         //- Calculate residual
96         virtual void residual
97         (
98             const Field<Type>& x,
99             const Field<Type>& b,
100             Field<Type>& res
101         ) const = 0;
103         //- Restrict residual
104         virtual void restrictResidual
105         (
106             const Field<Type>& x,
107             const Field<Type>& b,
108             Field<Type>& xBuffer,
109             Field<Type>& coarseRes,
110             bool preSweepsDone
111         ) const = 0;
113         //- Prolongate correction
114         virtual void prolongateCorrection
115         (
116             Field<Type>& x,
117             const Field<Type>& coarseX
118         ) const = 0;
120         //- Smooth level
121         virtual void smooth
122         (
123             Field<Type>& x,
124             const Field<Type>& b,
125             const label nSweeps
126         ) const = 0;
128         //- Solve level
129         virtual void solve
130         (
131             Field<Type>& x,
132             const Field<Type>& b,
133             const scalar tolerance,
134             const scalar relTol
135         ) const = 0;
137         //- Scale x
138         virtual void scaleX
139         (
140             Field<Type>& x,
141             const Field<Type>& b,
142             Field<Type>& xBuffer
143         ) const = 0;
145         //- Create next level from current level
146         virtual autoPtr<BlockAmgLevel> makeNextLevel() const = 0;
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 } // End namespace Foam
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 #endif
161 // ************************************************************************* //