1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "MGridGenGAMGAgglomeration.H"
28 #include "addToRunTimeSelectionTable.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(MGridGenGAMGAgglomeration, 0);
36 addToRunTimeSelectionTable
39 MGridGenGAMGAgglomeration,
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration
50 const dictionary& dict
53 GAMGAgglomeration(mesh, dict),
54 fvMesh_(refCast<const fvMesh>(mesh))
56 // Min, max size of agglomerated cells
57 label minSize(readLabel(dict.lookup("minSize")));
58 label maxSize(readLabel(dict.lookup("maxSize")));
61 // Get the finest-level interfaces from the mesh
65 new lduInterfacePtrsList(fvMesh_.boundary().interfaces())
68 // Start geometric agglomeration from the cell volumes and areas of the mesh
69 scalarField* VPtr = const_cast<scalarField*>(&fvMesh_.cellVolumes());
70 vectorField* SfPtr = const_cast<vectorField*>(&fvMesh_.faceAreas());
72 // Create the boundary area cell field
73 scalarField* SbPtr(new scalarField(fvMesh_.nCells(), 0));
76 scalarField& Sb = *SbPtr;
78 const labelList& own = fvMesh_.faceOwner();
79 const vectorField& Sf = fvMesh_.faceAreas();
83 if (!fvMesh_.isInternalFace(facei))
85 Sb[own[facei]] += mag(Sf[facei]);
91 // Agglomerate until the required number of cells in the coarsest level
94 label nCreatedLevels = 0;
96 while (nCreatedLevels < maxLevels_ - 1)
98 label nCoarseCells = -1;
100 tmp<labelField> finalAgglomPtr = agglomerate
105 meshLevel(nCreatedLevels).lduAddr(),
111 if (continueAgglomerating(nCoarseCells))
113 nCells_[nCreatedLevels] = nCoarseCells;
114 restrictAddressing_.set(nCreatedLevels, finalAgglomPtr);
121 agglomerateLduAddressing(nCreatedLevels);
123 // Agglomerate the cell volumes field for the next level
127 new scalarField(meshLevels_[nCreatedLevels].size())
130 restrictField(*aggVPtr, *VPtr, nCreatedLevels);
140 // Agglomerate the face areas field for the next level
142 vectorField* aggSfPtr
146 meshLevels_[nCreatedLevels].upperAddr().size(),
151 restrictFaceField(*aggSfPtr, *SfPtr, nCreatedLevels);
161 // Agglomerate the cell boundary areas field for the next level
163 scalarField* aggSbPtr
165 new scalarField(meshLevels_[nCreatedLevels].size())
168 restrictField(*aggSbPtr, *SbPtr, nCreatedLevels);
177 // Shrink the storage of the levels to those created
178 compactLevels(nCreatedLevels);
180 // Delete temporary geometry storage
190 // ************************************************************************* //