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 "GAMGAgglomeration.H"
29 #include "lduMatrix.H"
31 #include "dlLibraryTable.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(GAMGAgglomeration, 0);
38 defineRunTimeSelectionTable(GAMGAgglomeration, lduMesh);
39 defineRunTimeSelectionTable(GAMGAgglomeration, lduMatrix);
43 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
47 nCells_.setSize(nCreatedLevels);
48 restrictAddressing_.setSize(nCreatedLevels);
49 meshLevels_.setSize(nCreatedLevels);
50 interfaceLevels_.setSize(nCreatedLevels + 1);
54 bool Foam::GAMGAgglomeration::continueAgglomerating
56 const label nCoarseCells
59 // Check the need for further agglomeration on all processors
60 bool contAgg = nCoarseCells >= nCellsInCoarsestLevel_;
61 reduce(contAgg, andOp<bool>());
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 Foam::GAMGAgglomeration::GAMGAgglomeration
71 const dictionary& controlDict
74 MeshObject<lduMesh, GAMGAgglomeration>(mesh),
78 nCellsInCoarsestLevel_
80 readLabel(controlDict.lookup("nCellsInCoarsestLevel"))
84 restrictAddressing_(maxLevels_),
85 faceRestrictAddressing_(maxLevels_),
87 meshLevels_(maxLevels_),
88 interfaceLevels_(maxLevels_ + 1)
92 const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
95 const dictionary& controlDict
100 !mesh.thisDb().foundObject<GAMGAgglomeration>
102 GAMGAgglomeration::typeName
106 word agglomeratorType(controlDict.lookup("agglomerator"));
111 "geometricGAMGAgglomerationLibs",
112 lduMeshConstructorTablePtr_
115 lduMeshConstructorTable::iterator cstrIter =
116 lduMeshConstructorTablePtr_->find(agglomeratorType);
118 if (cstrIter == lduMeshConstructorTablePtr_->end())
122 "GAMGAgglomeration::New"
123 "(const lduMesh& mesh, const dictionary& controlDict)"
124 ) << "Unknown GAMGAgglomeration type "
125 << agglomeratorType << ".\n"
126 << "Valid algebraic GAMGAgglomeration types are :"
127 << lduMatrixConstructorTablePtr_->toc() << endl
128 << "Valid algebraic GAMGAgglomeration types are :"
129 << lduMeshConstructorTablePtr_->toc()
133 return store(cstrIter()(mesh, controlDict).ptr());
137 return mesh.thisDb().lookupObject<GAMGAgglomeration>
139 GAMGAgglomeration::typeName
145 const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
147 const lduMatrix& matrix,
148 const dictionary& controlDict
151 const lduMesh& mesh = matrix.mesh();
155 !mesh.thisDb().foundObject<GAMGAgglomeration>
157 GAMGAgglomeration::typeName
161 word agglomeratorType(controlDict.lookup("agglomerator"));
166 "algebraicGAMGAgglomerationLibs",
167 lduMatrixConstructorTablePtr_
172 !lduMatrixConstructorTablePtr_
173 || !lduMatrixConstructorTablePtr_->found(agglomeratorType)
176 return New(mesh, controlDict);
180 lduMatrixConstructorTable::iterator cstrIter =
181 lduMatrixConstructorTablePtr_->find(agglomeratorType);
183 return store(cstrIter()(matrix, controlDict).ptr());
188 return mesh.thisDb().lookupObject<GAMGAgglomeration>
190 GAMGAgglomeration::typeName
196 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
198 Foam::GAMGAgglomeration::~GAMGAgglomeration()
200 // Clear the interface storage by hand.
201 // It is a list of ptrs not a PtrList for consistency of the interface
202 for (label leveli=1; leveli<interfaceLevels_.size(); leveli++)
204 lduInterfacePtrsList& curLevel = interfaceLevels_[leveli];
217 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
219 const Foam::lduMesh& Foam::GAMGAgglomeration::meshLevel
230 return meshLevels_[i - 1];
235 const Foam::lduInterfacePtrsList& Foam::GAMGAgglomeration::interfaceLevel
240 return interfaceLevels_[i];
244 // ************************************************************************* //