initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / matrices / lduMatrix / solvers / GAMG / GAMGAgglomerations / pairGAMGAgglomeration / pairGAMGAgglomerationCombineLevels.C
blob58ad3ac53d6b7c3cb61b6516716ae29e28ba6d0e
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
41     // finer level
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)
50     {
51         if (prevFaceResAddr[i] >= 0)
52         {
53             prevFaceResAddr[i] = curFaceResAddr[prevFaceResAddr[i]];
54         }
55         else
56         {
57             prevFaceResAddr[i] = -curResAddr[-prevFaceResAddr[i] - 1] - 1;
58         }
59     }
61     // Delete the restrictAddressing for the coarser level
62     faceRestrictAddressing_.set(curLevel, NULL);
64     forAll(prevResAddr, i)
65     {
66         prevResAddr[i] = curResAddr[prevResAddr[i]];
67     }
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
78     // held on List<T*>
79     const lduInterfacePtrsList& curInterLevel = interfaceLevels_[curLevel+1];
80     lduInterfacePtrsList& prevInterLevel = interfaceLevels_[prevLevel+1];
82     forAll (prevInterLevel, inti)
83     {
84         if (prevInterLevel.set(inti))
85         {
86             refCast<GAMGInterface>(const_cast<lduInterface&>
87             (
88                 prevInterLevel[inti]
89             )).combine(refCast<const GAMGInterface>(curInterLevel[inti]));
91             delete curInterLevel(inti);
92         }
93     }
95     interfaceLevels_.set(curLevel+1, NULL);
99 // ************************************************************************* //