40 lduMatrix::solver::addsymMatrixConstructorToTable<GAMGSolver>
43 lduMatrix::solver::addasymMatrixConstructorToTable<GAMGSolver>
52 const word& fieldName,
73 preSweepsLevelMultiplier_(1),
76 postSweepsLevelMultiplier_(1),
80 cacheAgglomeration_(true),
81 interpolateCorrection_(false),
82 scaleCorrection_(matrix.symmetric()),
83 directSolveCoarsest_(false),
87 matrixLevels_(agglomeration_.size()),
88 primitiveInterfaceLevels_(agglomeration_.size()),
89 interfaceLevels_(agglomeration_.size()),
90 interfaceLevelsBouCoeffs_(agglomeration_.size()),
91 interfaceLevelsIntCoeffs_(agglomeration_.size())
97 forAll(agglomeration_, fineLevelIndex)
103 (fineLevelIndex+1) < agglomeration_.
size()
118 fineMeshInterfaces.
size()
122 dummyPrimMeshInterfaces.
size()
128 forAll(fineMeshInterfaces, intI)
130 if (fineMeshInterfaces.
set(intI))
136 fineMeshInterfaces[intI]
141 dummyPrimMeshInterfaces.
set
146 fineMeshInterfaces[intI].
type(),
155 forAll(dummyPrimMeshInterfaces, intI)
157 if (dummyPrimMeshInterfaces.
set(intI))
159 dummyMeshInterfaces.
set
162 &dummyPrimMeshInterfaces[intI]
173 agglomeration_.
meshLevel(fineLevelIndex),
183 procAgglomerateMatrix
195 agglomeration_.
meshLevel(fineLevelIndex + 1),
208 forAll(agglomeration_, fineLevelIndex)
214 agglomeration_.
meshLevel(fineLevelIndex + 1),
220 if ((
log_ >= 2) || (debug & 2))
224 label fineLevelIndex = 0;
225 fineLevelIndex <= matrixLevels_.size();
229 if (fineLevelIndex == 0 || matrixLevels_.set(fineLevelIndex-1))
231 const lduMatrix&
matrix = matrixLevel(fineLevelIndex);
233 interfaceLevel(fineLevelIndex);
235 Pout<<
"level:" << fineLevelIndex <<
nl
236 <<
" nCells:" <<
matrix.diag().size() <<
nl
237 <<
" nFaces:" <<
matrix.lower().size() <<
nl
248 <<
interfaces[i].interface().faceCells().size()
255 Pout<<
"level:" << fineLevelIndex <<
" : no matrix" <<
endl;
262 if (matrixLevels_.size())
264 const label coarsestLevel = matrixLevels_.size() - 1;
266 if (matrixLevels_.set(coarsestLevel))
268 if (directSolveCoarsest_)
270 coarsestLUMatrixPtr_.reset
274 matrixLevels_[coarsestLevel],
275 interfaceLevelsBouCoeffs_[coarsestLevel],
276 interfaceLevels_[coarsestLevel]
287 if (coarseEntry && coarseEntry->isDict())
292 matrixLevels_[coarsestLevel],
293 interfaceLevelsBouCoeffs_[coarsestLevel],
294 interfaceLevelsIntCoeffs_[coarsestLevel],
295 interfaceLevels_[coarsestLevel],
299 else if (matrixLevels_[coarsestLevel].asymmetric())
301 coarsestSolverPtr_.reset
306 matrixLevels_[coarsestLevel],
307 interfaceLevelsBouCoeffs_[coarsestLevel],
308 interfaceLevelsIntCoeffs_[coarsestLevel],
309 interfaceLevels_[coarsestLevel],
316 coarsestSolverPtr_.reset
321 matrixLevels_[coarsestLevel],
322 interfaceLevelsBouCoeffs_[coarsestLevel],
323 interfaceLevelsIntCoeffs_[coarsestLevel],
324 interfaceLevels_[coarsestLevel],
335 <<
"No coarse levels created, either matrix too small for GAMG"
336 " or nCellsInCoarsestLevel too large.\n"
337 " Either choose another solver of reduce "
338 "nCellsInCoarsestLevel."
348 if (!cacheAgglomeration_)
350 delete &agglomeration_;
361 controlDict_.readIfPresent(
"cacheAgglomeration", cacheAgglomeration_);
362 controlDict_.readIfPresent(
"nPreSweeps", nPreSweeps_);
363 controlDict_.readIfPresent
365 "preSweepsLevelMultiplier",
366 preSweepsLevelMultiplier_
368 controlDict_.readIfPresent(
"maxPreSweeps", maxPreSweeps_);
369 controlDict_.readIfPresent(
"nPostSweeps", nPostSweeps_);
370 controlDict_.readIfPresent
372 "postSweepsLevelMultiplier",
373 postSweepsLevelMultiplier_
375 controlDict_.readIfPresent(
"maxPostSweeps", maxPostSweeps_);
376 controlDict_.readIfPresent(
"nFinestSweeps", nFinestSweeps_);
377 controlDict_.readIfPresent(
"interpolateCorrection", interpolateCorrection_);
378 controlDict_.readIfPresent(
"scaleCorrection", scaleCorrection_);
379 controlDict_.readIfPresent(
"directSolveCoarsest", directSolveCoarsest_);
381 if ((log_ >= 2) ||
debug)
383 Info<<
"GAMGSolver settings :"
384 <<
" cacheAgglomeration:" << cacheAgglomeration_
385 <<
" nPreSweeps:" << nPreSweeps_
386 <<
" preSweepsLevelMultiplier:" << preSweepsLevelMultiplier_
387 <<
" maxPreSweeps:" << maxPreSweeps_
388 <<
" nPostSweeps:" << nPostSweeps_
389 <<
" postSweepsLevelMultiplier:" << postSweepsLevelMultiplier_
390 <<
" maxPostSweeps:" << maxPostSweeps_
391 <<
" nFinestSweeps:" << nFinestSweeps_
392 <<
" interpolateCorrection:" << interpolateCorrection_
393 <<
" scaleCorrection:" << scaleCorrection_
394 <<
" directSolveCoarsest:" << directSolveCoarsest_
400const Foam::lduMatrix& Foam::GAMGSolver::matrixLevel(
const label i)
const
402 return i ? matrixLevels_[i-1] : matrix_;
411 return i ? interfaceLevels_[i-1] : interfaces_;
415const Foam::FieldField<Foam::Field, Foam::scalar>&
416Foam::GAMGSolver::interfaceBouCoeffsLevel
421 return i ? interfaceLevelsBouCoeffs_[i-1] : interfaceBouCoeffs_;
425const Foam::FieldField<Foam::Field, Foam::scalar>&
426Foam::GAMGSolver::interfaceIntCoeffsLevel
431 return i ? interfaceLevelsIntCoeffs_[i-1] : interfaceIntCoeffs_;
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
Mapping from processor to agglomerated processor (global, all processors have the same information)....
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 master processor. (local, same only on those proce...
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.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
void reset(const char *buffer, size_t nbytes)
Reset input area, position to buffer start and clear errors.
Class to perform the LU decomposition on a symmetric matrix.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An OSstream with internal List storage.
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
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
label size() const noexcept
The number of entries in the list.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const noexcept
True if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const lduMatrix & matrix_
solver(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Construct solver for given field name, matrix etc.
scalar tolerance_
Final convergence tolerance.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
const lduMatrix & matrix() const noexcept
static autoPtr< solver > New(const word &solverName, const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new solver of given type.
int log_
Verbosity level for solver output statements.
scalar relTol_
Convergence tolerance relative to the initial.
virtual void readControls()
Read the control parameters from controlDict_.
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
dictionary controlDict_
Dictionary of solution controls.
virtual const word & type() const =0
Runtime type information.
const word & fieldName() const noexcept
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
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)
Namespace for handling debugging switches.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
List< label > labelList
A List of labels.
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
lduMatrix::solver::addasymMatrixConstructorToTable< GAMGSolver > addGAMGAsymSolverMatrixConstructorToTable_
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
constexpr char nl
The newline '\n' character (0x0a).
lduMatrix::solver::addsymMatrixConstructorToTable< GAMGSolver > addGAMGSolverMatrixConstructorToTable_
#define forAll(list, i)
Loop across all elements in list.