1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "pairGAMGAgglomeration.H"
27 #include "lduInterfacePtrsList.H"
28 #include "GAMGInterface.H"
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 void Foam::pairGAMGAgglomeration::combineLevels(const label curLevel)
34 label prevLevel = curLevel - 1;
36 // Set the previous level nCells to the current
37 nCells_[prevLevel] = nCells_[curLevel];
39 // Map the restrictAddressing from the coarser level into the previous
42 const labelList& curResAddr = restrictAddressing_[curLevel];
43 labelList& prevResAddr = restrictAddressing_[prevLevel];
45 const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
46 labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
48 forAll(prevFaceResAddr, i)
50 if (prevFaceResAddr[i] >= 0)
52 prevFaceResAddr[i] = curFaceResAddr[prevFaceResAddr[i]];
56 prevFaceResAddr[i] = -curResAddr[-prevFaceResAddr[i] - 1] - 1;
60 // Delete the restrictAddressing for the coarser level
61 faceRestrictAddressing_.set(curLevel, NULL);
63 forAll(prevResAddr, i)
65 prevResAddr[i] = curResAddr[prevResAddr[i]];
68 // Delete the restrictAddressing for the coarser level
69 restrictAddressing_.set(curLevel, NULL);
72 // Delete the matrix addressing and coefficients from the previous level
73 // and replace with the corresponding entried from the coarser level
74 meshLevels_.set(prevLevel, meshLevels_.set(curLevel, NULL));
76 // Same for the lduInterfaceFields taking care to delete the sub-entries
78 const lduInterfacePtrsList& curInterLevel = interfaceLevels_[curLevel+1];
79 lduInterfacePtrsList& prevInterLevel = interfaceLevels_[prevLevel+1];
81 forAll(prevInterLevel, inti)
83 if (prevInterLevel.set(inti))
85 refCast<GAMGInterface>(const_cast<lduInterface&>
88 )).combine(refCast<const GAMGInterface>(curInterLevel[inti]));
90 delete curInterLevel(inti);
94 interfaceLevels_.set(curLevel+1, NULL);
98 // ************************************************************************* //