initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / matrices / lduMatrix / solvers / GAMG / GAMGAgglomerations / GAMGAgglomeration / GAMGAgglomeration.H
blob9ab294b574ef666f53cde2d77307bbea8505c8e5
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::GAMGAgglomeration
28 Description
29     Geometric agglomerated algebraic multigrid agglomeration class.
31 SourceFiles
32     GAMGAgglomeration.C
33     GAMGAgglomerationTemplates.C
34     GAMGAgglomerate.C
35     GAMGAgglomerateLduAddressing.C
37 \*---------------------------------------------------------------------------*/
39 #ifndef GAMGAgglomeration_H
40 #define GAMGAgglomeration_H
42 #include "MeshObject.H"
43 #include "lduPrimitiveMesh.H"
44 #include "lduInterfacePtrsList.H"
45 #include "primitiveFields.H"
46 #include "runTimeSelectionTables.H"
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 namespace Foam
53 class lduMesh;
54 class lduMatrix;
56 /*---------------------------------------------------------------------------*\
57                            Class GAMGAgglomeration Declaration
58 \*---------------------------------------------------------------------------*/
60 class GAMGAgglomeration
62     public MeshObject<lduMesh, GAMGAgglomeration>
64 protected:
66     // Protected data
68         //- Max number of levels
69         label maxLevels_;
71         //- Number of cells in coarsest level
72         label nCellsInCoarsestLevel_;
74         //- The number of cells in each level
75         labelList nCells_;
77         //- Cell restriction addressing array.
78         //  Maps from the finer to the coarser level.
79         PtrList<labelField> restrictAddressing_;
81         //- Face restriction addressing array.
82         //  Maps from the finer to the coarser level.
83         //  Positive indices map the finer faces which form part of the boundary
84         //  of the coarser cells to the corresponding coarser cell face.
85         //  Negative indices map the finer faces which are internal to the
86         //  coarser cells to minus the corresponding coarser cell index minus 1.
87         PtrList<labelList> faceRestrictAddressing_;
89         //- Hierarchy of mesh addressing
90         PtrList<lduPrimitiveMesh> meshLevels_;
92         //- Hierarchy interfaces.
93         //  Warning: Needs to be deleted explicitly.
94         PtrList<lduInterfacePtrsList> interfaceLevels_;
96         //- Assemble coarse mesh addressing
97         void agglomerateLduAddressing(const label fineLevelIndex);
99         //- Shrink the number of levels to that specified
100         void compactLevels(const label nCreatedLevels);
102         //- Check the need for further agglomeration
103         bool continueAgglomerating(const label nCoarseCells) const;
106     // Private Member Functions
108         //- Disallow default bitwise copy construct
109         GAMGAgglomeration(const GAMGAgglomeration&);
111         //- Disallow default bitwise assignment
112         void operator=(const GAMGAgglomeration&);
115 public:
117     //- Runtime type information
118     TypeName("GAMGAgglomeration");
121     // Declare run-time constructor selection tables
123         //- Runtime selection table for pure geometric agglomerators
124         declareRunTimeSelectionTable
125         (
126             autoPtr,
127             GAMGAgglomeration,
128             lduMesh,
129             (
130                 const lduMesh& mesh,
131                 const dictionary& controlDict
132             ),
133             (
134                 mesh,
135                 controlDict
136             )
137         );
139         //- Runtime selection table for matrix or mixed geometric/matrix
140         //  agglomerators
141         declareRunTimeSelectionTable
142         (
143             autoPtr,
144             GAMGAgglomeration,
145             lduMatrix,
146             (
147                 const lduMatrix& matrix,
148                 const dictionary& controlDict
149             ),
150             (
151                 matrix,
152                 controlDict
153             )
154         );
157     // Constructors
159         //- Construct given mesh and controls
160         GAMGAgglomeration
161         (
162             const lduMesh& mesh,
163             const dictionary& controlDict
164         );
167     // Selectors
169         //- Return the selected geometric agglomerator
170         static const GAMGAgglomeration& New
171         (
172             const lduMesh& mesh,
173             const dictionary& controlDict
174         );
176         //- Return the selected matrix agglomerator
177         static const GAMGAgglomeration& New
178         (
179             const lduMatrix& matrix,
180             const dictionary& controlDict
181         );
184     // Destructor
186         ~GAMGAgglomeration();
189     // Member Functions
191         // Access
193             label size() const
194             {
195                 return meshLevels_.size();
196             }
198             //- Return LDU mesh of given level
199             const lduMesh& meshLevel(const label leveli) const;
201             //- Return LDU interface addressing of given level
202             const lduInterfacePtrsList& interfaceLevel
203             (
204                 const label leveli
205             ) const;
207             //- Return cell restrict addressing of given level
208             const labelField& restrictAddressing(const label leveli) const
209             {
210                 return restrictAddressing_[leveli];
211             }
213             //- Return face restrict addressing of given level
214             const labelList& faceRestrictAddressing(const label leveli) const
215             {
216                 return faceRestrictAddressing_[leveli];
217             }
220         // Restriction and prolongation
222             //- Restrict (integrate by summation) cell field
223             template<class Type>
224             void restrictField
225             (
226                 Field<Type>& cf,
227                 const Field<Type>& ff,
228                 const label fineLevelIndex
229             ) const;
231             //- Restrict (integrate by summation) face field
232             template<class Type>
233             void restrictFaceField
234             (
235                 Field<Type>& cf,
236                 const Field<Type>& ff,
237                 const label fineLevelIndex
238             ) const;
240             //- Prolong (interpolate by injection) cell field
241             template<class Type>
242             void prolongField
243             (
244                 Field<Type>& ff,
245                 const Field<Type>& cf,
246                 const label coarseLevelIndex
247             ) const;
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 #ifdef NoRepository
258 #   include "GAMGAgglomerationTemplates.C"
259 #endif
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 #endif
265 // ************************************************************************* //