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()
124 forAll(fineMeshInterfaces, intI)
126 if (fineMeshInterfaces.
set(intI))
129 refCast<const GAMGInterface>
131 fineMeshInterfaces[intI]
135 dummyPrimMeshInterfaces.set
140 fineMeshInterfaces[intI].
type(),
149 forAll(dummyPrimMeshInterfaces, intI)
151 if (dummyPrimMeshInterfaces.set(intI))
153 dummyMeshInterfaces.set
156 &dummyPrimMeshInterfaces[intI]
167 agglomeration_.
meshLevel(fineLevelIndex),
177 procAgglomerateMatrix
189 agglomeration_.
meshLevel(fineLevelIndex + 1),
202 forAll(agglomeration_, fineLevelIndex)
208 agglomeration_.
meshLevel(fineLevelIndex + 1),
218 label fineLevelIndex = 0;
219 fineLevelIndex <= matrixLevels_.size();
223 if (fineLevelIndex == 0 || matrixLevels_.set(fineLevelIndex-1))
225 const lduMatrix&
matrix = matrixLevel(fineLevelIndex);
227 interfaceLevel(fineLevelIndex);
229 Pout<<
"level:" << fineLevelIndex <<
nl 247 Pout<<
"level:" << fineLevelIndex <<
" : no matrix" <<
endl;
254 if (matrixLevels_.size())
256 const label coarsestLevel = matrixLevels_.size() - 1;
258 if (matrixLevels_.set(coarsestLevel))
260 if (directSolveCoarsest_)
262 coarsestLUMatrixPtr_.reset
266 matrixLevels_[coarsestLevel],
267 interfaceLevelsBouCoeffs_[coarsestLevel],
268 interfaceLevels_[coarsestLevel]
279 if (coarseEntry && coarseEntry->isDict())
284 matrixLevels_[coarsestLevel],
285 interfaceLevelsBouCoeffs_[coarsestLevel],
286 interfaceLevelsIntCoeffs_[coarsestLevel],
287 interfaceLevels_[coarsestLevel],
291 else if (matrixLevels_[coarsestLevel].asymmetric())
293 coarsestSolverPtr_.reset
298 matrixLevels_[coarsestLevel],
299 interfaceLevelsBouCoeffs_[coarsestLevel],
300 interfaceLevelsIntCoeffs_[coarsestLevel],
301 interfaceLevels_[coarsestLevel],
308 coarsestSolverPtr_.reset
313 matrixLevels_[coarsestLevel],
314 interfaceLevelsBouCoeffs_[coarsestLevel],
315 interfaceLevelsIntCoeffs_[coarsestLevel],
316 interfaceLevels_[coarsestLevel],
327 <<
"No coarse levels created, either matrix too small for GAMG" 328 " or nCellsInCoarsestLevel too large.\n" 329 " Either choose another solver of reduce " 330 "nCellsInCoarsestLevel." 340 if (!cacheAgglomeration_)
342 delete &agglomeration_;
349 void Foam::GAMGSolver::readControls()
353 controlDict_.readIfPresent(
"cacheAgglomeration", cacheAgglomeration_);
354 controlDict_.readIfPresent(
"nPreSweeps", nPreSweeps_);
355 controlDict_.readIfPresent
357 "preSweepsLevelMultiplier",
358 preSweepsLevelMultiplier_
360 controlDict_.readIfPresent(
"maxPreSweeps", maxPreSweeps_);
361 controlDict_.readIfPresent(
"nPostSweeps", nPostSweeps_);
362 controlDict_.readIfPresent
364 "postSweepsLevelMultiplier",
365 postSweepsLevelMultiplier_
367 controlDict_.readIfPresent(
"maxPostSweeps", maxPostSweeps_);
368 controlDict_.readIfPresent(
"nFinestSweeps", nFinestSweeps_);
369 controlDict_.readIfPresent(
"interpolateCorrection", interpolateCorrection_);
370 controlDict_.readIfPresent(
"scaleCorrection", scaleCorrection_);
371 controlDict_.readIfPresent(
"directSolveCoarsest", directSolveCoarsest_);
373 if ((log_ >= 2) ||
debug)
375 Info<<
"GAMGSolver settings :" 376 <<
" cacheAgglomeration:" << cacheAgglomeration_
377 <<
" nPreSweeps:" << nPreSweeps_
378 <<
" preSweepsLevelMultiplier:" << preSweepsLevelMultiplier_
379 <<
" maxPreSweeps:" << maxPreSweeps_
380 <<
" nPostSweeps:" << nPostSweeps_
381 <<
" postSweepsLevelMultiplier:" << postSweepsLevelMultiplier_
382 <<
" maxPostSweeps:" << maxPostSweeps_
383 <<
" nFinestSweeps:" << nFinestSweeps_
384 <<
" interpolateCorrection:" << interpolateCorrection_
385 <<
" scaleCorrection:" << scaleCorrection_
386 <<
" directSolveCoarsest:" << directSolveCoarsest_
392 const Foam::lduMatrix& Foam::GAMGSolver::matrixLevel(
const label i)
const 394 return i ? matrixLevels_[i-1] : matrix_;
403 return i ? interfaceLevels_[i-1] : interfaces_;
408 Foam::GAMGSolver::interfaceBouCoeffsLevel
413 return i ? interfaceLevelsBouCoeffs_[i-1] : interfaceBouCoeffs_;
418 Foam::GAMGSolver::interfaceIntCoeffsLevel
423 return i ? interfaceLevelsIntCoeffs_[i-1] : interfaceIntCoeffs_;
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
bool hasProcMesh(const label fineLeveli) const
Check that level has combined mesh.
void size(const label n)
Older name for setAddressableSize.
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.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Base class for solution control classes.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const lduMesh & meshLevel(const label leveli) const
Return LDU mesh of given level.
constexpr char nl
The newline '\n' character (0x0a)
const lduMatrix & matrix() const noexcept
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
int log_
Verbosity level for solver output statements.
A field of fields is a PtrList of fields with reference counting.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
#define forAll(list, i)
Loop across all elements in list.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
scalar tolerance_
Final convergence tolerance.
bool processorAgglomerate() const
Whether to agglomerate across processors.
A class for handling words, derived from Foam::string.
label size() const noexcept
The number of elements in the list.
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 lduInterfaceFieldPtrsList & interfaces() const noexcept
virtual const word & type() const =0
Runtime type information.
static autoPtr< solver > New(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.
lduMatrix::solver::addsymMatrixConstructorToTable< GAMGSolver > addGAMGSolverMatrixConstructorToTable_
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
dictionary controlDict_
Dictionary of solution controls.
Geometric agglomerated algebraic multigrid solver.
virtual ~GAMGSolver()
Destructor.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
const labelList & procAgglomMap(const label fineLeveli) const
Mapping from processor to agglomerated processor (global, all processors have the same information)...
Input from string buffer, using a ISstream. Always UNCOMPRESSED.
lduMatrix::solver::addasymMatrixConstructorToTable< GAMGSolver > addGAMGAsymSolverMatrixConstructorToTable_
const lduInterfacePtrsList & interfaceLevel(const label leveli) const
Return LDU interface addressing of given level.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Geometric agglomerated algebraic multigrid agglomeration class.
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
bool hasMeshLevel(const label leveli) const
Do we have mesh for given level?
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
virtual void readControls()
Read the control parameters from controlDict_.
scalar relTol_
Convergence tolerance relative to the initial.