FreeFOAM The Cross-Platform CFD Toolkit
pairGAMGAgglomerationCombineLevels.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "pairGAMGAgglomeration.H"
28 #include <OpenFOAM/GAMGInterface.H>
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
33 {
34  label prevLevel = curLevel - 1;
35 
36  // Set the previous level nCells to the current
37  nCells_[prevLevel] = nCells_[curLevel];
38 
39  // Map the restrictAddressing from the coarser level into the previous
40  // finer level
41 
42  const labelList& curResAddr = restrictAddressing_[curLevel];
43  labelList& prevResAddr = restrictAddressing_[prevLevel];
44 
45  const labelList& curFaceResAddr = faceRestrictAddressing_[curLevel];
46  labelList& prevFaceResAddr = faceRestrictAddressing_[prevLevel];
47 
48  forAll(prevFaceResAddr, i)
49  {
50  if (prevFaceResAddr[i] >= 0)
51  {
52  prevFaceResAddr[i] = curFaceResAddr[prevFaceResAddr[i]];
53  }
54  else
55  {
56  prevFaceResAddr[i] = -curResAddr[-prevFaceResAddr[i] - 1] - 1;
57  }
58  }
59 
60  // Delete the restrictAddressing for the coarser level
61  faceRestrictAddressing_.set(curLevel, NULL);
62 
63  forAll(prevResAddr, i)
64  {
65  prevResAddr[i] = curResAddr[prevResAddr[i]];
66  }
67 
68  // Delete the restrictAddressing for the coarser level
69  restrictAddressing_.set(curLevel, NULL);
70 
71 
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));
75 
76  // Same for the lduInterfaceFields taking care to delete the sub-entries
77  // held on List<T*>
78  const lduInterfacePtrsList& curInterLevel = interfaceLevels_[curLevel+1];
79  lduInterfacePtrsList& prevInterLevel = interfaceLevels_[prevLevel+1];
80 
81  forAll (prevInterLevel, inti)
82  {
83  if (prevInterLevel.set(inti))
84  {
85  refCast<GAMGInterface>(const_cast<lduInterface&>
86  (
87  prevInterLevel[inti]
88  )).combine(refCast<const GAMGInterface>(curInterLevel[inti]));
89 
90  delete curInterLevel(inti);
91  }
92  }
93 
94  interfaceLevels_.set(curLevel+1, NULL);
95 }
96 
97 
98 // ************************ vim: set sw=4 sts=4 et: ************************ //