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 249 Pout<<
"level:" << fineLevelIndex <<
" : no matrix" <<
endl;
256 if (matrixLevels_.size())
258 const label coarsestLevel = matrixLevels_.size() - 1;
260 if (matrixLevels_.set(coarsestLevel))
262 if (directSolveCoarsest_)
264 coarsestLUMatrixPtr_.reset
268 matrixLevels_[coarsestLevel],
269 interfaceLevelsBouCoeffs_[coarsestLevel],
270 interfaceLevels_[coarsestLevel]
281 if (coarseEntry && coarseEntry->isDict())
286 matrixLevels_[coarsestLevel],
287 interfaceLevelsBouCoeffs_[coarsestLevel],
288 interfaceLevelsIntCoeffs_[coarsestLevel],
289 interfaceLevels_[coarsestLevel],
293 else if (matrixLevels_[coarsestLevel].asymmetric())
295 coarsestSolverPtr_.reset
300 matrixLevels_[coarsestLevel],
301 interfaceLevelsBouCoeffs_[coarsestLevel],
302 interfaceLevelsIntCoeffs_[coarsestLevel],
303 interfaceLevels_[coarsestLevel],
310 coarsestSolverPtr_.reset
315 matrixLevels_[coarsestLevel],
316 interfaceLevelsBouCoeffs_[coarsestLevel],
317 interfaceLevelsIntCoeffs_[coarsestLevel],
318 interfaceLevels_[coarsestLevel],
329 <<
"No coarse levels created, either matrix too small for GAMG" 330 " or nCellsInCoarsestLevel too large.\n" 331 " Either choose another solver of reduce " 332 "nCellsInCoarsestLevel." 342 if (!cacheAgglomeration_)
344 delete &agglomeration_;
351 void Foam::GAMGSolver::readControls()
355 controlDict_.readIfPresent(
"cacheAgglomeration", cacheAgglomeration_);
356 controlDict_.readIfPresent(
"nPreSweeps", nPreSweeps_);
357 controlDict_.readIfPresent
359 "preSweepsLevelMultiplier",
360 preSweepsLevelMultiplier_
362 controlDict_.readIfPresent(
"maxPreSweeps", maxPreSweeps_);
363 controlDict_.readIfPresent(
"nPostSweeps", nPostSweeps_);
364 controlDict_.readIfPresent
366 "postSweepsLevelMultiplier",
367 postSweepsLevelMultiplier_
369 controlDict_.readIfPresent(
"maxPostSweeps", maxPostSweeps_);
370 controlDict_.readIfPresent(
"nFinestSweeps", nFinestSweeps_);
371 controlDict_.readIfPresent(
"interpolateCorrection", interpolateCorrection_);
372 controlDict_.readIfPresent(
"scaleCorrection", scaleCorrection_);
373 controlDict_.readIfPresent(
"directSolveCoarsest", directSolveCoarsest_);
375 if ((log_ >= 2) ||
debug)
377 Info<<
"GAMGSolver settings :" 378 <<
" cacheAgglomeration:" << cacheAgglomeration_
379 <<
" nPreSweeps:" << nPreSweeps_
380 <<
" preSweepsLevelMultiplier:" << preSweepsLevelMultiplier_
381 <<
" maxPreSweeps:" << maxPreSweeps_
382 <<
" nPostSweeps:" << nPostSweeps_
383 <<
" postSweepsLevelMultiplier:" << postSweepsLevelMultiplier_
384 <<
" maxPostSweeps:" << maxPostSweeps_
385 <<
" nFinestSweeps:" << nFinestSweeps_
386 <<
" interpolateCorrection:" << interpolateCorrection_
387 <<
" scaleCorrection:" << scaleCorrection_
388 <<
" directSolveCoarsest:" << directSolveCoarsest_
394 const Foam::lduMatrix& Foam::GAMGSolver::matrixLevel(
const label i)
const 396 return i ? matrixLevels_[i-1] : matrix_;
405 return i ? interfaceLevels_[i-1] : interfaces_;
410 Foam::GAMGSolver::interfaceBouCoeffsLevel
415 return i ? interfaceLevelsBouCoeffs_[i-1] : interfaceBouCoeffs_;
420 Foam::GAMGSolver::interfaceIntCoeffsLevel
425 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)
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 >> &tf1, 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.
#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 entries 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.
lduMatrix::solver::addsymMatrixConstructorToTable< GAMGSolver > addGAMGSolverMatrixConstructorToTable_
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 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_.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
scalar relTol_
Convergence tolerance relative to the initial.