38 lduMatrix::solver::addsymMatrixConstructorToTable<GAMGSolver>
41 lduMatrix::solver::addasymMatrixConstructorToTable<GAMGSolver>
50 const word& fieldName,
70 cacheAgglomeration_(true),
72 preSweepsLevelMultiplier_(1),
75 postSweepsLevelMultiplier_(1),
78 interpolateCorrection_(false),
79 scaleCorrection_(matrix.symmetric()),
80 directSolveCoarsest_(false),
83 matrixLevels_(agglomeration_.size()),
84 primitiveInterfaceLevels_(agglomeration_.size()),
85 interfaceLevels_(agglomeration_.size()),
86 interfaceLevelsBouCoeffs_(agglomeration_.size()),
87 interfaceLevelsIntCoeffs_(agglomeration_.size())
93 forAll(agglomeration_, fineLevelIndex)
99 (fineLevelIndex+1) < agglomeration_.
size()
114 fineMeshInterfaces.
size()
118 dummyPrimMeshInterfaces.
size()
120 forAll(fineMeshInterfaces, intI)
122 if (fineMeshInterfaces.
set(intI))
125 refCast<const GAMGInterface>
127 fineMeshInterfaces[intI]
131 dummyPrimMeshInterfaces.
set
136 fineMeshInterfaces[intI].
type(),
145 forAll(dummyPrimMeshInterfaces, intI)
147 if (dummyPrimMeshInterfaces.
set(intI))
149 dummyMeshInterfaces.
set
152 &dummyPrimMeshInterfaces[intI]
163 agglomeration_.
meshLevel(fineLevelIndex),
173 procAgglomerateMatrix
185 agglomeration_.
meshLevel(fineLevelIndex + 1),
198 forAll(agglomeration_, fineLevelIndex)
204 agglomeration_.
meshLevel(fineLevelIndex + 1),
215 label fineLevelIndex = 0;
216 fineLevelIndex <= matrixLevels_.size();
220 if (fineLevelIndex == 0 || matrixLevels_.set(fineLevelIndex-1))
224 interfaceLevel(fineLevelIndex);
226 Pout<<
"level:" << fineLevelIndex <<
nl
244 Pout<<
"level:" << fineLevelIndex <<
" : no matrix" <<
endl;
251 if (matrixLevels_.size())
253 const label coarsestLevel = matrixLevels_.size() - 1;
255 if (matrixLevels_.set(coarsestLevel))
257 if (directSolveCoarsest_)
259 coarsestLUMatrixPtr_.set
263 matrixLevels_[coarsestLevel],
264 interfaceLevelsBouCoeffs_[coarsestLevel],
265 interfaceLevels_[coarsestLevel]
272 matrixLevels_[coarsestLevel].diagonal()
278 matrixLevels_[coarsestLevel],
279 interfaceLevelsBouCoeffs_[coarsestLevel],
280 interfaceLevelsIntCoeffs_[coarsestLevel],
281 interfaceLevels_[coarsestLevel],
285 : matrixLevels_[coarsestLevel].asymmetric()
291 matrixLevels_[coarsestLevel],
292 interfaceLevelsBouCoeffs_[coarsestLevel],
293 interfaceLevelsIntCoeffs_[coarsestLevel],
294 interfaceLevels_[coarsestLevel],
297 "preconditioner",
"DILU",
308 matrixLevels_[coarsestLevel],
309 interfaceLevelsBouCoeffs_[coarsestLevel],
310 interfaceLevelsIntCoeffs_[coarsestLevel],
311 interfaceLevels_[coarsestLevel],
314 "preconditioner",
"DIC",
326 <<
"No coarse levels created, either matrix too small for GAMG"
327 " or minCellsPerProcessor too large.\n"
328 " Either choose another solver of reduce "
329 "minCellsPerProcessor."
339 if (!cacheAgglomeration_)
341 delete &agglomeration_;
348 void Foam::GAMGSolver::readControls()
352 controlDict_.readIfPresent(
"cacheAgglomeration", cacheAgglomeration_);
353 controlDict_.readIfPresent(
"nPreSweeps", nPreSweeps_);
354 controlDict_.readIfPresent
356 "preSweepsLevelMultiplier",
357 preSweepsLevelMultiplier_
359 controlDict_.readIfPresent(
"maxPreSweeps", maxPreSweeps_);
360 controlDict_.readIfPresent(
"nPostSweeps", nPostSweeps_);
361 controlDict_.readIfPresent
363 "postSweepsLevelMultiplier",
364 postSweepsLevelMultiplier_
366 controlDict_.readIfPresent(
"maxPostSweeps", maxPostSweeps_);
367 controlDict_.readIfPresent(
"nFinestSweeps", nFinestSweeps_);
368 controlDict_.readIfPresent(
"interpolateCorrection", interpolateCorrection_);
369 controlDict_.readIfPresent(
"scaleCorrection", scaleCorrection_);
370 controlDict_.readIfPresent(
"directSolveCoarsest", directSolveCoarsest_);
374 Pout<<
"GAMGSolver settings :"
375 <<
" cacheAgglomeration:" << cacheAgglomeration_
376 <<
" nPreSweeps:" << nPreSweeps_
377 <<
" preSweepsLevelMultiplier:" << preSweepsLevelMultiplier_
378 <<
" maxPreSweeps:" << maxPreSweeps_
379 <<
" nPostSweeps:" << nPostSweeps_
380 <<
" postSweepsLevelMultiplier:" << postSweepsLevelMultiplier_
381 <<
" maxPostSweeps:" << maxPostSweeps_
382 <<
" nFinestSweeps:" << nFinestSweeps_
383 <<
" interpolateCorrection:" << interpolateCorrection_
384 <<
" scaleCorrection:" << scaleCorrection_
385 <<
" directSolveCoarsest:" << directSolveCoarsest_
399 return matrixLevels_[i - 1];
415 return interfaceLevels_[i - 1];
421 Foam::GAMGSolver::interfaceBouCoeffsLevel
428 return interfaceBouCoeffs_;
432 return interfaceLevelsBouCoeffs_[i - 1];
438 Foam::GAMGSolver::interfaceIntCoeffsLevel
445 return interfaceIntCoeffs_;
449 return interfaceLevelsIntCoeffs_[i - 1];
#define forAll(list, i)
Loop across all elements in list.
Geometric agglomerated algebraic multigrid agglomeration class.
bool processorAgglomerate() const
Whether to agglomerate across processors.
const labelList & procAgglomMap(const label fineLeveli) const
Mapping from processor to agglomerated processor (global, all.
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
const labelList & agglomProcIDs(const label fineLeveli) const
Set of processors to agglomerate. Element 0 is the.
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
static autoPtr< GAMGInterface > New(const label index, const lduInterfacePtrsList &coarseInterfaces, const lduInterface &fineInterface, const labelField &localRestrictAddressing, const labelField &neighbourRestrictAddressing, const label fineLevelIndex, const label coarseComm)
Return a pointer to a new interface created on freestore given.
Geometric agglomerated algebraic multigrid solver.
GAMGSolver(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Construct from lduMatrix and solver controls.
virtual ~GAMGSolver()
Destructor.
Input from memory buffer stream.
Class to perform the LU decomposition on a symmetric matrix.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual Ostream & write(const char)
Write character.
Output to memory buffer stream.
string str() const
Return the string.
Preconditioned bi-conjugate gradient stabilised solver for asymmetric lduMatrices using a run-time se...
Preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time selectable precon...
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool set(const label) const
Is element set.
bool set(const label) const
Is element set.
label size() const
Return the number of elements in the UPtrList.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
static std::tuple< const Entries &... > entries(const Entries &...)
Construct an entries tuple from which to make a dictionary.
virtual const word & type() const =0
Runtime type information.
const lduInterfaceFieldPtrsList & interfaces() const
scalar tolerance_
Final convergence tolerance.
scalar relTol_
Convergence tolerance relative to the initial.
virtual void readControls()
Read the control parameters from the controlDict_.
const lduMatrix & matrix() const
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Abstract base class for run-time selectable region solvers.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
lduMatrix::solver::addasymMatrixConstructorToTable< GAMGSolver > addGAMGAsymSolverMatrixConstructorToTable_
prefixOSstream Pout(cout, "Pout")
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
lduMatrix::solver::addsymMatrixConstructorToTable< GAMGSolver > addGAMGSolverMatrixConstructorToTable_