OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

GAMGAgglomeration.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::GAMGAgglomeration
00027 
00028 Description
00029     Geometric agglomerated algebraic multigrid agglomeration class.
00030 
00031 SourceFiles
00032     GAMGAgglomeration.C
00033     GAMGAgglomerationTemplates.C
00034     GAMGAgglomerate.C
00035     GAMGAgglomerateLduAddressing.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef GAMGAgglomeration_H
00040 #define GAMGAgglomeration_H
00041 
00042 #include "MeshObject.H"
00043 #include "lduPrimitiveMesh.H"
00044 #include "lduInterfacePtrsList.H"
00045 #include "primitiveFields.H"
00046 #include "runTimeSelectionTables.H"
00047 
00048 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00049 
00050 namespace Foam
00051 {
00052 
00053 class lduMesh;
00054 class lduMatrix;
00055 
00056 /*---------------------------------------------------------------------------*\
00057                            Class GAMGAgglomeration Declaration
00058 \*---------------------------------------------------------------------------*/
00059 
00060 class GAMGAgglomeration
00061 :
00062     public MeshObject<lduMesh, GAMGAgglomeration>
00063 {
00064 protected:
00065 
00066     // Protected data
00067 
00068         //- Max number of levels
00069         label maxLevels_;
00070 
00071         //- Number of cells in coarsest level
00072         label nCellsInCoarsestLevel_;
00073 
00074         //- The number of cells in each level
00075         labelList nCells_;
00076 
00077         //- Cell restriction addressing array.
00078         //  Maps from the finer to the coarser level.
00079         PtrList<labelField> restrictAddressing_;
00080 
00081         //- Face restriction addressing array.
00082         //  Maps from the finer to the coarser level.
00083         //  Positive indices map the finer faces which form part of the boundary
00084         //  of the coarser cells to the corresponding coarser cell face.
00085         //  Negative indices map the finer faces which are internal to the
00086         //  coarser cells to minus the corresponding coarser cell index minus 1.
00087         PtrList<labelList> faceRestrictAddressing_;
00088 
00089         //- Hierarchy of mesh addressing
00090         PtrList<lduPrimitiveMesh> meshLevels_;
00091 
00092         //- Hierarchy interfaces.
00093         //  Warning: Needs to be deleted explicitly.
00094         PtrList<lduInterfacePtrsList> interfaceLevels_;
00095 
00096         //- Assemble coarse mesh addressing
00097         void agglomerateLduAddressing(const label fineLevelIndex);
00098 
00099         //- Shrink the number of levels to that specified
00100         void compactLevels(const label nCreatedLevels);
00101 
00102         //- Check the need for further agglomeration
00103         bool continueAgglomerating(const label nCoarseCells) const;
00104 
00105 
00106     // Private Member Functions
00107 
00108         //- Disallow default bitwise copy construct
00109         GAMGAgglomeration(const GAMGAgglomeration&);
00110 
00111         //- Disallow default bitwise assignment
00112         void operator=(const GAMGAgglomeration&);
00113 
00114 
00115 public:
00116 
00117     //- Runtime type information
00118     TypeName("GAMGAgglomeration");
00119 
00120 
00121     // Declare run-time constructor selection tables
00122 
00123         //- Runtime selection table for pure geometric agglomerators
00124         declareRunTimeSelectionTable
00125         (
00126             autoPtr,
00127             GAMGAgglomeration,
00128             lduMesh,
00129             (
00130                 const lduMesh& mesh,
00131                 const dictionary& controlDict
00132             ),
00133             (
00134                 mesh,
00135                 controlDict
00136             )
00137         );
00138 
00139         //- Runtime selection table for matrix or mixed geometric/matrix
00140         //  agglomerators
00141         declareRunTimeSelectionTable
00142         (
00143             autoPtr,
00144             GAMGAgglomeration,
00145             lduMatrix,
00146             (
00147                 const lduMatrix& matrix,
00148                 const dictionary& controlDict
00149             ),
00150             (
00151                 matrix,
00152                 controlDict
00153             )
00154         );
00155 
00156 
00157     // Constructors
00158 
00159         //- Construct given mesh and controls
00160         GAMGAgglomeration
00161         (
00162             const lduMesh& mesh,
00163             const dictionary& controlDict
00164         );
00165 
00166 
00167     // Selectors
00168 
00169         //- Return the selected geometric agglomerator
00170         static const GAMGAgglomeration& New
00171         (
00172             const lduMesh& mesh,
00173             const dictionary& controlDict
00174         );
00175 
00176         //- Return the selected matrix agglomerator
00177         static const GAMGAgglomeration& New
00178         (
00179             const lduMatrix& matrix,
00180             const dictionary& controlDict
00181         );
00182 
00183 
00184     // Destructor
00185 
00186         ~GAMGAgglomeration();
00187 
00188 
00189     // Member Functions
00190 
00191         // Access
00192 
00193             label size() const
00194             {
00195                 return meshLevels_.size();
00196             }
00197 
00198             //- Return LDU mesh of given level
00199             const lduMesh& meshLevel(const label leveli) const;
00200 
00201             //- Return LDU interface addressing of given level
00202             const lduInterfacePtrsList& interfaceLevel
00203             (
00204                 const label leveli
00205             ) const;
00206 
00207             //- Return cell restrict addressing of given level
00208             const labelField& restrictAddressing(const label leveli) const
00209             {
00210                 return restrictAddressing_[leveli];
00211             }
00212 
00213             //- Return face restrict addressing of given level
00214             const labelList& faceRestrictAddressing(const label leveli) const
00215             {
00216                 return faceRestrictAddressing_[leveli];
00217             }
00218 
00219 
00220         // Restriction and prolongation
00221 
00222             //- Restrict (integrate by summation) cell field
00223             template<class Type>
00224             void restrictField
00225             (
00226                 Field<Type>& cf,
00227                 const Field<Type>& ff,
00228                 const label fineLevelIndex
00229             ) const;
00230 
00231             //- Restrict (integrate by summation) face field
00232             template<class Type>
00233             void restrictFaceField
00234             (
00235                 Field<Type>& cf,
00236                 const Field<Type>& ff,
00237                 const label fineLevelIndex
00238             ) const;
00239 
00240             //- Prolong (interpolate by injection) cell field
00241             template<class Type>
00242             void prolongField
00243             (
00244                 Field<Type>& ff,
00245                 const Field<Type>& cf,
00246                 const label coarseLevelIndex
00247             ) const;
00248 };
00249 
00250 
00251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00252 
00253 } // End namespace Foam
00254 
00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00256 
00257 #ifdef NoRepository
00258 #   include "GAMGAgglomerationTemplates.C"
00259 #endif
00260 
00261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00262 
00263 #endif
00264 
00265 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd