1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
26 Foam::GAMGAgglomeration
29 Geometric agglomerated algebraic multigrid agglomeration class.
33 GAMGAgglomerationTemplates.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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 /*---------------------------------------------------------------------------*\
57 Class GAMGAgglomeration Declaration
58 \*---------------------------------------------------------------------------*/
60 class GAMGAgglomeration
62 public MeshObject<lduMesh, GAMGAgglomeration>
68 //- Max number of levels
71 //- Number of cells in coarsest level
72 label nCellsInCoarsestLevel_;
74 //- The number of cells in each level
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&);
117 //- Runtime type information
118 TypeName("GAMGAgglomeration");
121 // Declare run-time constructor selection tables
123 //- Runtime selection table for pure geometric agglomerators
124 declareRunTimeSelectionTable
131 const dictionary& controlDict
139 //- Runtime selection table for matrix or mixed geometric/matrix
141 declareRunTimeSelectionTable
147 const lduMatrix& matrix,
148 const dictionary& controlDict
159 //- Construct given mesh and controls
163 const dictionary& controlDict
169 //- Return the selected geometric agglomerator
170 static const GAMGAgglomeration& New
173 const dictionary& controlDict
176 //- Return the selected matrix agglomerator
177 static const GAMGAgglomeration& New
179 const lduMatrix& matrix,
180 const dictionary& controlDict
186 ~GAMGAgglomeration();
195 return meshLevels_.size();
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
207 //- Return cell restrict addressing of given level
208 const labelField& restrictAddressing(const label leveli) const
210 return restrictAddressing_[leveli];
213 //- Return face restrict addressing of given level
214 const labelList& faceRestrictAddressing(const label leveli) const
216 return faceRestrictAddressing_[leveli];
220 // Restriction and prolongation
222 //- Restrict (integrate by summation) cell field
227 const Field<Type>& ff,
228 const label fineLevelIndex
231 //- Restrict (integrate by summation) face field
233 void restrictFaceField
236 const Field<Type>& ff,
237 const label fineLevelIndex
240 //- Prolong (interpolate by injection) cell field
245 const Field<Type>& cf,
246 const label coarseLevelIndex
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 } // End namespace Foam
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 # include "GAMGAgglomerationTemplates.C"
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 // ************************************************************************* //