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))
134 refCast<const GAMGInterface>
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),
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 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_;
357 void Foam::GAMGSolver::readControls()
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_
400 const Foam::lduMatrix& Foam::GAMGSolver::matrixLevel(
const label i)
const 402 return i ? matrixLevels_[i-1] : matrix_;
411 return i ? interfaceLevels_[i-1] : interfaces_;
416 Foam::GAMGSolver::interfaceBouCoeffsLevel
421 return i ? interfaceLevelsBouCoeffs_[i-1] : interfaceBouCoeffs_;
426 Foam::GAMGSolver::interfaceIntCoeffsLevel
431 return i ? interfaceLevelsIntCoeffs_[i-1] : interfaceIntCoeffs_;
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
const scalarField & diag() const
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.
void reset(const char *buffer, size_t nbytes)
Reset input area, position to buffer start and clear errors.
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.
An OSstream with internal List storage.
const scalarField & lower() const
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)...
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.
Similar to IStringStream but using an externally managed buffer for its input. This allows the input ...
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.