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

GAMGAgglomerationTemplates.C

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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "GAMGAgglomeration.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 template<class Type>
00032 void Foam::GAMGAgglomeration::restrictField
00033 (
00034     Field<Type>& cf,
00035     const Field<Type>& ff,
00036     const label fineLevelIndex
00037 ) const
00038 {
00039     const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex];
00040 
00041     if (ff.size() != fineToCoarse.size())
00042     {
00043         FatalErrorIn
00044         (
00045             "void GAMGAgglomeration::restrictField"
00046             "(Field<Type>& cf, const Field<Type>& ff, "
00047             "const label fineLevelIndex) const"
00048         )   << "field does not correspond to level " << fineLevelIndex
00049             << " sizes: field = " << ff.size()
00050             << " level = " << fineToCoarse.size()
00051             << abort(FatalError);
00052     }
00053 
00054     cf = pTraits<Type>::zero;
00055 
00056     forAll(ff, i)
00057     {
00058         cf[fineToCoarse[i]] += ff[i];
00059     }
00060 }
00061 
00062 
00063 template<class Type>
00064 void Foam::GAMGAgglomeration::restrictFaceField
00065 (
00066     Field<Type>& cf,
00067     const Field<Type>& ff,
00068     const label fineLevelIndex
00069 ) const
00070 {
00071     const labelList& fineToCoarse = faceRestrictAddressing_[fineLevelIndex];
00072 
00073     cf = pTraits<Type>::zero;
00074 
00075     forAll(fineToCoarse, ffacei)
00076     {
00077         label cFace = fineToCoarse[ffacei];
00078 
00079         if (cFace >= 0)
00080         {
00081             cf[cFace] += ff[ffacei];
00082         }
00083     }
00084 }
00085 
00086 
00087 template<class Type>
00088 void Foam::GAMGAgglomeration::prolongField
00089 (
00090     Field<Type>& ff,
00091     const Field<Type>& cf,
00092     const label coarseLevelIndex
00093 ) const
00094 {
00095     const labelList& fineToCoarse = restrictAddressing_[coarseLevelIndex];
00096 
00097     forAll(fineToCoarse, i)
00098     {
00099         ff[i] = cf[fineToCoarse[i]];
00100     }
00101 }
00102 
00103 
00104 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd