FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::GAMGAgglomeration
00026 
00027 Description
00028     Geometric agglomerated algebraic multigrid agglomeration class.
00029 
00030 SourceFiles
00031     GAMGAgglomeration.C
00032     GAMGAgglomerationTemplates.C
00033     GAMGAgglomerate.C
00034     GAMGAgglomerateLduAddressing.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef GAMGAgglomeration_H
00039 #define GAMGAgglomeration_H
00040 
00041 #include <OpenFOAM/MeshObject.H>
00042 #include <OpenFOAM/lduPrimitiveMesh.H>
00043 #include <OpenFOAM/lduInterfacePtrsList.H>
00044 #include <OpenFOAM/primitiveFields.H>
00045 #include <OpenFOAM/runTimeSelectionTables.H>
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 class lduMesh;
00053 class lduMatrix;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                            Class GAMGAgglomeration Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class GAMGAgglomeration
00060 :
00061     public MeshObject<lduMesh, GAMGAgglomeration>
00062 {
00063 protected:
00064 
00065     // Protected data
00066 
00067         //- Max number of levels
00068         label maxLevels_;
00069 
00070         //- Number of cells in coarsest level
00071         label nCellsInCoarsestLevel_;
00072 
00073         //- The number of cells in each level
00074         labelList nCells_;
00075 
00076         //- Cell restriction addressing array.
00077         //  Maps from the finer to the coarser level.
00078         PtrList<labelField> restrictAddressing_;
00079 
00080         //- Face restriction addressing array.
00081         //  Maps from the finer to the coarser level.
00082         //  Positive indices map the finer faces which form part of the boundary
00083         //  of the coarser cells to the corresponding coarser cell face.
00084         //  Negative indices map the finer faces which are internal to the
00085         //  coarser cells to minus the corresponding coarser cell index minus 1.
00086         PtrList<labelList> faceRestrictAddressing_;
00087 
00088         //- Hierarchy of mesh addressing
00089         PtrList<lduPrimitiveMesh> meshLevels_;
00090 
00091         //- Hierarchy interfaces.
00092         //  Warning: Needs to be deleted explicitly.
00093         PtrList<lduInterfacePtrsList> interfaceLevels_;
00094 
00095         //- Assemble coarse mesh addressing
00096         void agglomerateLduAddressing(const label fineLevelIndex);
00097 
00098         //- Shrink the number of levels to that specified
00099         void compactLevels(const label nCreatedLevels);
00100 
00101         //- Check the need for further agglomeration
00102         bool continueAgglomerating(const label nCoarseCells) const;
00103 
00104 
00105     // Private Member Functions
00106 
00107         //- Disallow default bitwise copy construct
00108         GAMGAgglomeration(const GAMGAgglomeration&);
00109 
00110         //- Disallow default bitwise assignment
00111         void operator=(const GAMGAgglomeration&);
00112 
00113 
00114 public:
00115 
00116     //- Runtime type information
00117     TypeName("GAMGAgglomeration");
00118 
00119 
00120     // Declare run-time constructor selection tables
00121 
00122         //- Runtime selection table for pure geometric agglomerators
00123         declareRunTimeSelectionTable
00124         (
00125             autoPtr,
00126             GAMGAgglomeration,
00127             lduMesh,
00128             (
00129                 const lduMesh& mesh,
00130                 const dictionary& controlDict
00131             ),
00132             (
00133                 mesh,
00134                 controlDict
00135             )
00136         );
00137 
00138         //- Runtime selection table for matrix or mixed geometric/matrix
00139         //  agglomerators
00140         declareRunTimeSelectionTable
00141         (
00142             autoPtr,
00143             GAMGAgglomeration,
00144             lduMatrix,
00145             (
00146                 const lduMatrix& matrix,
00147                 const dictionary& controlDict
00148             ),
00149             (
00150                 matrix,
00151                 controlDict
00152             )
00153         );
00154 
00155 
00156     // Constructors
00157 
00158         //- Construct given mesh and controls
00159         GAMGAgglomeration
00160         (
00161             const lduMesh& mesh,
00162             const dictionary& controlDict
00163         );
00164 
00165 
00166     // Selectors
00167 
00168         //- Return the selected geometric agglomerator
00169         static const GAMGAgglomeration& New
00170         (
00171             const lduMesh& mesh,
00172             const dictionary& controlDict
00173         );
00174 
00175         //- Return the selected matrix agglomerator
00176         static const GAMGAgglomeration& New
00177         (
00178             const lduMatrix& matrix,
00179             const dictionary& controlDict
00180         );
00181 
00182 
00183     // Destructor
00184 
00185         ~GAMGAgglomeration();
00186 
00187 
00188     // Member Functions
00189 
00190         // Access
00191 
00192             label size() const
00193             {
00194                 return meshLevels_.size();
00195             }
00196 
00197             //- Return LDU mesh of given level
00198             const lduMesh& meshLevel(const label leveli) const;
00199 
00200             //- Return LDU interface addressing of given level
00201             const lduInterfacePtrsList& interfaceLevel
00202             (
00203                 const label leveli
00204             ) const;
00205 
00206             //- Return cell restrict addressing of given level
00207             const labelField& restrictAddressing(const label leveli) const
00208             {
00209                 return restrictAddressing_[leveli];
00210             }
00211 
00212             //- Return face restrict addressing of given level
00213             const labelList& faceRestrictAddressing(const label leveli) const
00214             {
00215                 return faceRestrictAddressing_[leveli];
00216             }
00217 
00218 
00219         // Restriction and prolongation
00220 
00221             //- Restrict (integrate by summation) cell field
00222             template<class Type>
00223             void restrictField
00224             (
00225                 Field<Type>& cf,
00226                 const Field<Type>& ff,
00227                 const label fineLevelIndex
00228             ) const;
00229 
00230             //- Restrict (integrate by summation) face field
00231             template<class Type>
00232             void restrictFaceField
00233             (
00234                 Field<Type>& cf,
00235                 const Field<Type>& ff,
00236                 const label fineLevelIndex
00237             ) const;
00238 
00239             //- Prolong (interpolate by injection) cell field
00240             template<class Type>
00241             void prolongField
00242             (
00243                 Field<Type>& ff,
00244                 const Field<Type>& cf,
00245                 const label coarseLevelIndex
00246             ) const;
00247 };
00248 
00249 
00250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00251 
00252 } // End namespace Foam
00253 
00254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00255 
00256 #ifdef NoRepository
00257 #   include <OpenFOAM/GAMGAgglomerationTemplates.C>
00258 #endif
00259 
00260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00261 
00262 #endif
00263 
00264 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines