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
25 \*---------------------------------------------------------------------------*/
27 #include "pairGAMGAgglomeration.H"
28 #include "lduInterfacePtrsList.H"
29 #include "GAMGInterface.H"
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 void Foam::pairGAMGAgglomeration::combineLevels(const label curLevel)
35 label prevLevel = curLevel - 1;
37 // Set the previous level nCells to the current
38 nCells_[prevLevel] = nCells_[curLevel];
40 // Map the restrictAddressing from the coarser level into the previous
43 const labelList& curResAddr = restrictAddressing_[curLevel];
44 labelList& prevResAddr = restrictAddressing_[prevLevel];
46 const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
47 labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
49 forAll(prevFaceResAddr, i)
51 if (prevFaceResAddr[i] >= 0)
53 prevFaceResAddr[i] = curFaceResAddr[prevFaceResAddr[i]];
57 prevFaceResAddr[i] = -curResAddr[-prevFaceResAddr[i] - 1] - 1;
61 // Delete the restrictAddressing for the coarser level
62 faceRestrictAddressing_.set(curLevel, NULL);
64 forAll(prevResAddr, i)
66 prevResAddr[i] = curResAddr[prevResAddr[i]];
69 // Delete the restrictAddressing for the coarser level
70 restrictAddressing_.set(curLevel, NULL);
73 // Delete the matrix addressing and coefficients from the previous level
74 // and replace with the corresponding entried from the coarser level
75 meshLevels_.set(prevLevel, meshLevels_.set(curLevel, NULL));
77 // Same for the lduInterfaceFields taking care to delete the sub-entries
79 const lduInterfacePtrsList& curInterLevel = interfaceLevels_[curLevel+1];
80 lduInterfacePtrsList& prevInterLevel = interfaceLevels_[prevLevel+1];
82 forAll (prevInterLevel, inti)
84 if (prevInterLevel.set(inti))
86 refCast<GAMGInterface>(const_cast<lduInterface&>
89 )).combine(refCast<const GAMGInterface>(curInterLevel[inti]));
91 delete curInterLevel(inti);
95 interfaceLevels_.set(curLevel+1, NULL);
99 // ************************************************************************* //