40 lduMatrix::solver::addsymMatrixConstructorToTable<GAMGSolver>
43 lduMatrix::solver::addasymMatrixConstructorToTable<GAMGSolver>
52 const word& fieldName,
72 cacheAgglomeration_(true),
74 preSweepsLevelMultiplier_(1),
77 postSweepsLevelMultiplier_(1),
80 interpolateCorrection_(false),
81 scaleCorrection_(matrix.symmetric()),
82 directSolveCoarsest_(false),
85 matrixLevels_(agglomeration_.size()),
86 primitiveInterfaceLevels_(agglomeration_.size()),
87 interfaceLevels_(agglomeration_.size()),
88 interfaceLevelsBouCoeffs_(agglomeration_.size()),
89 interfaceLevelsIntCoeffs_(agglomeration_.size())
95 forAll(agglomeration_, fineLevelIndex)
101 (fineLevelIndex+1) < agglomeration_.
size()
116 fineMeshInterfaces.
size()
120 dummyPrimMeshInterfaces.
size()
122 forAll(fineMeshInterfaces, intI)
124 if (fineMeshInterfaces.
set(intI))
127 refCast<const GAMGInterface>
129 fineMeshInterfaces[intI]
133 dummyPrimMeshInterfaces.
set
138 fineMeshInterfaces[intI].
type(),
147 forAll(dummyPrimMeshInterfaces, intI)
149 if (dummyPrimMeshInterfaces.
set(intI))
151 dummyMeshInterfaces.
set
154 &dummyPrimMeshInterfaces[intI]
165 agglomeration_.
meshLevel(fineLevelIndex),
175 procAgglomerateMatrix
187 agglomeration_.
meshLevel(fineLevelIndex + 1),
200 forAll(agglomeration_, fineLevelIndex)
206 agglomeration_.
meshLevel(fineLevelIndex + 1),
212 if ((
log_ >= 2) || (debug & 2))
216 label fineLevelIndex = 0;
217 fineLevelIndex <= matrixLevels_.size();
221 if (fineLevelIndex == 0 || matrixLevels_.set(fineLevelIndex-1))
225 interfaceLevel(fineLevelIndex);
227 Pout<<
"level:" << fineLevelIndex <<
nl
245 Pout<<
"level:" << fineLevelIndex <<
" : no matrix" <<
endl;
252 if (matrixLevels_.size())
254 const label coarsestLevel = matrixLevels_.size() - 1;
256 if (matrixLevels_.set(coarsestLevel))
258 if (directSolveCoarsest_)
260 coarsestLUMatrixPtr_.reset
264 matrixLevels_[coarsestLevel],
265 interfaceLevelsBouCoeffs_[coarsestLevel],
266 interfaceLevels_[coarsestLevel]
277 if (coarseEntry && coarseEntry->
isDict())
282 matrixLevels_[coarsestLevel],
283 interfaceLevelsBouCoeffs_[coarsestLevel],
284 interfaceLevelsIntCoeffs_[coarsestLevel],
285 interfaceLevels_[coarsestLevel],
289 else if (matrixLevels_[coarsestLevel].asymmetric())
291 coarsestSolverPtr_.reset
296 matrixLevels_[coarsestLevel],
297 interfaceLevelsBouCoeffs_[coarsestLevel],
298 interfaceLevelsIntCoeffs_[coarsestLevel],
299 interfaceLevels_[coarsestLevel],
306 coarsestSolverPtr_.reset
311 matrixLevels_[coarsestLevel],
312 interfaceLevelsBouCoeffs_[coarsestLevel],
313 interfaceLevelsIntCoeffs_[coarsestLevel],
314 interfaceLevels_[coarsestLevel],
325 <<
"No coarse levels created, either matrix too small for GAMG"
326 " or nCellsInCoarsestLevel too large.\n"
327 " Either choose another solver of reduce "
328 "nCellsInCoarsestLevel."
338 if (!cacheAgglomeration_)
340 delete &agglomeration_;
347void Foam::GAMGSolver::readControls()
351 controlDict_.readIfPresent(
"cacheAgglomeration", cacheAgglomeration_);
352 controlDict_.readIfPresent(
"nPreSweeps", nPreSweeps_);
353 controlDict_.readIfPresent
355 "preSweepsLevelMultiplier",
356 preSweepsLevelMultiplier_
358 controlDict_.readIfPresent(
"maxPreSweeps", maxPreSweeps_);
359 controlDict_.readIfPresent(
"nPostSweeps", nPostSweeps_);
360 controlDict_.readIfPresent
362 "postSweepsLevelMultiplier",
363 postSweepsLevelMultiplier_
365 controlDict_.readIfPresent(
"maxPostSweeps", maxPostSweeps_);
366 controlDict_.readIfPresent(
"nFinestSweeps", nFinestSweeps_);
367 controlDict_.readIfPresent(
"interpolateCorrection", interpolateCorrection_);
368 controlDict_.readIfPresent(
"scaleCorrection", scaleCorrection_);
369 controlDict_.readIfPresent(
"directSolveCoarsest", directSolveCoarsest_);
371 if ((log_ >= 2) || debug)
373 Info<<
"GAMGSolver settings :"
374 <<
" cacheAgglomeration:" << cacheAgglomeration_
375 <<
" nPreSweeps:" << nPreSweeps_
376 <<
" preSweepsLevelMultiplier:" << preSweepsLevelMultiplier_
377 <<
" maxPreSweeps:" << maxPreSweeps_
378 <<
" nPostSweeps:" << nPostSweeps_
379 <<
" postSweepsLevelMultiplier:" << postSweepsLevelMultiplier_
380 <<
" maxPostSweeps:" << maxPostSweeps_
381 <<
" nFinestSweeps:" << nFinestSweeps_
382 <<
" interpolateCorrection:" << interpolateCorrection_
383 <<
" scaleCorrection:" << scaleCorrection_
384 <<
" directSolveCoarsest:" << directSolveCoarsest_
390const Foam::lduMatrix& Foam::GAMGSolver::matrixLevel(
const label i)
const
398 return matrixLevels_[i - 1];
414 return interfaceLevels_[i - 1];
420Foam::GAMGSolver::interfaceBouCoeffsLevel
427 return interfaceBouCoeffs_;
431 return interfaceLevelsBouCoeffs_[i - 1];
437Foam::GAMGSolver::interfaceIntCoeffsLevel
444 return interfaceIntCoeffs_;
448 return interfaceLevelsIntCoeffs_[i - 1];
A field of fields is a PtrList of fields with reference counting.
Geometric agglomerated algebraic multigrid agglomeration class.
bool processorAgglomerate() const
Whether to agglomerate across processors.
const labelList & procAgglomMap(const label fineLeveli) const
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
const labelList & agglomProcIDs(const label fineLeveli) const
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.
Geometric agglomerated algebraic multigrid solver.
virtual ~GAMGSolver()
Destructor.
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
Class to perform the LU decomposition on a symmetric matrix.
virtual Ostream & write(const char c)
Write character.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Preconditioned bi-conjugate gradient stabilized solver for asymmetric lduMatrices using a run-time se...
Preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time selectable precon...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
const T * set(const label i) const
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
const T * set(const label i) const
label size() const noexcept
The number of elements in the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
scalar tolerance_
Final convergence tolerance.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
const lduMatrix & matrix() const noexcept
int log_
Level of verbosity in the solver output statements.
scalar relTol_
Convergence tolerance relative to the initial.
virtual void readControls()
Read the control parameters from the controlDict_.
dictionary controlDict_
Dictionary of controls.
virtual const word & type() const =0
Runtime type information.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
Base class for solution control classes.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
lduMatrix::solver::addasymMatrixConstructorToTable< GAMGSolver > addGAMGAsymSolverMatrixConstructorToTable_
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
lduMatrix::solver::addsymMatrixConstructorToTable< GAMGSolver > addGAMGSolverMatrixConstructorToTable_
#define forAll(list, i)
Loop across all elements in list.