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 / coarseBlockAmgLevel.H
blobc7ecf3a6fafe0475c21d34c5e6acfa76ca482bec
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     coarseBlockAmgLevel
27 Description
28     Coarse AMG level stores matrix, x and b locally, for BlockLduMatrix
30 Author
31     Klas Jareteg, 2012-12-13
33 SourceFiles
34     coarseBlockAmgLevel.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef coarseBlockAmgLevel_H
39 #define coarseBlockAmgLevel_H
41 #include "BlockAmgLevel.H"
42 #include "BlockLduSmoother.H"
43 #include "BlockLduMatrix.H"
44 #include "lduPrimitiveMesh.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 /*---------------------------------------------------------------------------*\
52                         Class coarseBlockAmgLevel Declaration
53 \*---------------------------------------------------------------------------*/
55 template<class Type>
56 class coarseBlockAmgLevel
58     public BlockAmgLevel<Type>
60     // Private data
62         //- Matrix addressing object.  This also contains coupling interfaces
63         autoPtr<lduPrimitiveMesh> addrPtr_;
65         //- Matrix
66         autoPtr<BlockLduMatrix<Type> > matrixPtr_;
68         //- Solution field
69         Field<Type> x_;
71         //- RHS field
72         Field<Type> b_;
74         //- Dictionary
75         const dictionary& dict_;
77         //- AMG coarsening
78         autoPtr<BlockMatrixCoarsening<Type> > coarseningPtr_;
80         //- Smoother
81         autoPtr<BlockLduSmoother<Type> > smootherPtr_;
83         //- Ax buffer
84         mutable Field<Type> Ax_;
87     // Private Member Functions
89         //- Disallow default bitwise copy construct
90         coarseBlockAmgLevel(const coarseBlockAmgLevel<Type>&);
92         //- Disallow default bitwise assignment
93         void operator=(const coarseBlockAmgLevel<Type>&);
96 public:
98     //- Runtime type information
99         TypeName("coarseBlockAmgLevel");
102     // Constructors
104         //- Construct from components
105         coarseBlockAmgLevel
106         (
107             autoPtr<lduPrimitiveMesh> addrPtr,
108             autoPtr<BlockLduMatrix<Type> > matrixPtr,
109             const dictionary& dict,
110             const word& coarseningType,
111             const label groupSize,
112             const label minCoarseEqns
113         );
116     // Destructor
118         virtual ~coarseBlockAmgLevel();
121     // Member Functions
123         //- Return reference to x
124         virtual Field<Type>& x();
126         //- Return reference to b
127         virtual Field<Type>& b();
129         //- Return reference to dictionary
130         const dictionary& dict() const
131         {
132             return dict_;
133         }
135         //- Calculate residual
136         virtual void residual
137         (
138             const Field<Type>& x,
139             const Field<Type>& b,
140             Field<Type>& res
141         ) const;
143         //- Restrict residual
144         virtual void restrictResidual
145         (
146             const Field<Type>& x,
147             const Field<Type>& b,
148             Field<Type>& xBuffer,
149             Field<Type>& coarseRes,
150             bool preSweepsDone
151         ) const;
153         //- Prolongate correction
154         virtual void prolongateCorrection
155         (
156             Field<Type>& x,
157             const Field<Type>& coarseX
158         ) const;
160         //- Smooth level
161         virtual void smooth
162         (
163             Field<Type>& x,
164             const Field<Type>& b,
165             const label nSweeps
166         ) const;
168         //- Solve level
169         virtual void solve
170         (
171             Field<Type>& x,
172             const Field<Type>& b,
173             const scalar tolerance,
174             const scalar relTol
175         ) const;
177         //- Scale x
178         virtual void scaleX
179         (
180             Field<Type>& x,
181             const Field<Type>& b,
182             Field<Type>& xBuffer
183         ) const;
186         //- Create next level from current level
187         virtual autoPtr<BlockAmgLevel<Type> > makeNextLevel() const;
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 } // End namespace Foam
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 #ifdef NoRepository
198 #   include "coarseBlockAmgLevel.C"
199 #endif
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 #endif
205 // ************************************************************************* //