GAMGAgglomeration.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "GAMGAgglomeration.H"
00028 #include "lduMesh.H"
00029 #include "lduMatrix.H"
00030 #include "Time.H"
00031 #include "dlLibraryTable.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(GAMGAgglomeration, 0);
00038 defineRunTimeSelectionTable(GAMGAgglomeration, lduMesh);
00039 defineRunTimeSelectionTable(GAMGAgglomeration, lduMatrix);
00040 }
00041
00042
00043
00044
00045 void Foam::GAMGAgglomeration::compactLevels(const label nCreatedLevels)
00046 {
00047 nCells_.setSize(nCreatedLevels);
00048 restrictAddressing_.setSize(nCreatedLevels);
00049 meshLevels_.setSize(nCreatedLevels);
00050 interfaceLevels_.setSize(nCreatedLevels + 1);
00051 }
00052
00053
00054 bool Foam::GAMGAgglomeration::continueAgglomerating
00055 (
00056 const label nCoarseCells
00057 ) const
00058 {
00059
00060 bool contAgg = nCoarseCells >= nCellsInCoarsestLevel_;
00061 reduce(contAgg, andOp<bool>());
00062 return contAgg;
00063 }
00064
00065
00066
00067
00068 Foam::GAMGAgglomeration::GAMGAgglomeration
00069 (
00070 const lduMesh& mesh,
00071 const dictionary& controlDict
00072 )
00073 :
00074 MeshObject<lduMesh, GAMGAgglomeration>(mesh),
00075
00076 maxLevels_(50),
00077
00078 nCellsInCoarsestLevel_
00079 (
00080 readLabel(controlDict.lookup("nCellsInCoarsestLevel"))
00081 ),
00082
00083 nCells_(maxLevels_),
00084 restrictAddressing_(maxLevels_),
00085 faceRestrictAddressing_(maxLevels_),
00086
00087 meshLevels_(maxLevels_),
00088 interfaceLevels_(maxLevels_ + 1)
00089 {}
00090
00091
00092 const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
00093 (
00094 const lduMesh& mesh,
00095 const dictionary& controlDict
00096 )
00097 {
00098 if
00099 (
00100 !mesh.thisDb().foundObject<GAMGAgglomeration>
00101 (
00102 GAMGAgglomeration::typeName
00103 )
00104 )
00105 {
00106 word agglomeratorType(controlDict.lookup("agglomerator"));
00107
00108 dlLibraryTable::open
00109 (
00110 controlDict,
00111 "geometricGAMGAgglomerationLibs",
00112 lduMeshConstructorTablePtr_
00113 );
00114
00115 lduMeshConstructorTable::iterator cstrIter =
00116 lduMeshConstructorTablePtr_->find(agglomeratorType);
00117
00118 if (cstrIter == lduMeshConstructorTablePtr_->end())
00119 {
00120 FatalErrorIn
00121 (
00122 "GAMGAgglomeration::New"
00123 "(const lduMesh& mesh, const dictionary& controlDict)"
00124 ) << "Unknown GAMGAgglomeration type "
00125 << agglomeratorType << ".\n"
00126 << "Valid algebraic GAMGAgglomeration types are :"
00127 << lduMatrixConstructorTablePtr_->toc() << endl
00128 << "Valid algebraic GAMGAgglomeration types are :"
00129 << lduMeshConstructorTablePtr_->toc()
00130 << exit(FatalError);
00131 }
00132
00133 return store(cstrIter()(mesh, controlDict).ptr());
00134 }
00135 else
00136 {
00137 return mesh.thisDb().lookupObject<GAMGAgglomeration>
00138 (
00139 GAMGAgglomeration::typeName
00140 );
00141 }
00142 }
00143
00144
00145 const Foam::GAMGAgglomeration& Foam::GAMGAgglomeration::New
00146 (
00147 const lduMatrix& matrix,
00148 const dictionary& controlDict
00149 )
00150 {
00151 const lduMesh& mesh = matrix.mesh();
00152
00153 if
00154 (
00155 !mesh.thisDb().foundObject<GAMGAgglomeration>
00156 (
00157 GAMGAgglomeration::typeName
00158 )
00159 )
00160 {
00161 word agglomeratorType(controlDict.lookup("agglomerator"));
00162
00163 dlLibraryTable::open
00164 (
00165 controlDict,
00166 "algebraicGAMGAgglomerationLibs",
00167 lduMatrixConstructorTablePtr_
00168 );
00169
00170 if
00171 (
00172 !lduMatrixConstructorTablePtr_
00173 || !lduMatrixConstructorTablePtr_->found(agglomeratorType)
00174 )
00175 {
00176 return New(mesh, controlDict);
00177 }
00178 else
00179 {
00180 lduMatrixConstructorTable::iterator cstrIter =
00181 lduMatrixConstructorTablePtr_->find(agglomeratorType);
00182
00183 return store(cstrIter()(matrix, controlDict).ptr());
00184 }
00185 }
00186 else
00187 {
00188 return mesh.thisDb().lookupObject<GAMGAgglomeration>
00189 (
00190 GAMGAgglomeration::typeName
00191 );
00192 }
00193 }
00194
00195
00196
00197
00198 Foam::GAMGAgglomeration::~GAMGAgglomeration()
00199 {
00200
00201
00202 for (label leveli=1; leveli<interfaceLevels_.size(); leveli++)
00203 {
00204 lduInterfacePtrsList& curLevel = interfaceLevels_[leveli];
00205
00206 forAll (curLevel, i)
00207 {
00208 if (curLevel.set(i))
00209 {
00210 delete curLevel(i);
00211 }
00212 }
00213 }
00214 }
00215
00216
00217
00218
00219 const Foam::lduMesh& Foam::GAMGAgglomeration::meshLevel
00220 (
00221 const label i
00222 ) const
00223 {
00224 if (i == 0)
00225 {
00226 return mesh_;
00227 }
00228 else
00229 {
00230 return meshLevels_[i - 1];
00231 }
00232 }
00233
00234
00235 const Foam::lduInterfacePtrsList& Foam::GAMGAgglomeration::interfaceLevel
00236 (
00237 const label i
00238 ) const
00239 {
00240 return interfaceLevels_[i];
00241 }
00242
00243
00244
Copyright © 2000-2009 OpenCFD Ltd