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 / BlockAmgCycle.H
blob68d9722c0df92da83e1b8f19103a4ffc264722e2
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     BlockAmgCycle
27 Description
28     Algebraic multigrid fixed cycle class for the BlockLduMatrix
30 Author
31     Klas Jareteg, 2012-12-12
33 SourceFiles
34     BlockAmgCycle.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef BlockAmgCycle_H
39 #define BlockAmgCycle_H
41 #include "BlockAmgLevel.H"
42 #include "NamedEnum.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 BlockMatrixCoarsening;
60 template<class Type>
61 class BlockAmgLevel;
64 /*---------------------------------------------------------------------------*\
65                    Class blockAmgCycleName Declaration
66 \*---------------------------------------------------------------------------*/
68 class blockAmgCycleName
70 public:
72     // Public enumerations
74         //- Cycle type
75         enum cycleType
76         {
77             V_CYCLE,
78             W_CYCLE,
79             F_CYCLE
80         };
82     //- Static data
84         //- Cycle type names
85         static const NamedEnum<cycleType, 3> cycleNames_;
89 /*---------------------------------------------------------------------------*\
90                            Class BlockAmgCycle Declaration
91 \*---------------------------------------------------------------------------*/
93 template<class Type>
94 class BlockAmgCycle
96     public blockAmgCycleName
98     // Private data
100         //- Pointer to current AMG level
101         autoPtr<BlockAmgLevel<Type> > levelPtr_;
103         //- Pointer to coarse AMG cycle
104         BlockAmgCycle<Type>* coarseLevelPtr_;
106         //- Number of coarse levels
107         label nLevels_;
110     // Private Member Functions
112         //- Disallow default bitwise copy construct
113         BlockAmgCycle(const BlockAmgCycle<Type>&);
115         //- Disallow default bitwise assignment
116         void operator=(const BlockAmgCycle<Type>&);
119 public:
121     //- Runtime type information
122     TypeName("BlockAmgCycle");
125     // Constructors
127         //- Construct from AMG level
128         BlockAmgCycle(autoPtr<BlockAmgLevel<Type> > levelPtr);
131     // Destructor
133         virtual ~BlockAmgCycle();
136     // Member Functions
138         //- Make coarse levels
139         void makeCoarseLevels(const label nMaxLevels);
141         //- Return number of levels
142         label nLevels() const
143         {
144             return nLevels_;
145         }
147         //- Calculate residual
148         void residual
149         (
150             const Field<Type>& x,
151             const Field<Type>& b,
152             Field<Type>& res
153         ) const
154         {
155             levelPtr_->residual(x, b, res);
156         }
159         //- Fixed cycle
160         void fixedCycle
161         (
162             Field<Type>& x,
163             const Field<Type>& b,
164             Field<Type>& xBuffer,
165             const BlockAmgCycle::cycleType cycle,
166             const label nPreSweeps,
167             const label nPostSweeps,
168             const bool scale
169         ) const;
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 } // End namespace Foam
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 #ifdef NoRepository
180 #   include "BlockAmgCycle.C"
181 #endif
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 #endif
187 // ************************************************************************* //