Commit e7b8b7d6 authored by mattijs's avatar mattijs Committed by Andrew Heather
Browse files

ENH: GAMGSolver: specify coarsest level solver. Fixes #1342.

parent ed10b19a
......@@ -27,6 +27,8 @@ License
#include "GAMGSolver.H"
#include "GAMGInterface.H"
#include "PCG.H"
#include "PBiCGStab.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......@@ -249,11 +251,11 @@ Foam::GAMGSolver::GAMGSolver
if (matrixLevels_.size())
{
if (directSolveCoarsest_)
{
const label coarsestLevel = matrixLevels_.size() - 1;
const label coarsestLevel = matrixLevels_.size() - 1;
if (matrixLevels_.set(coarsestLevel))
if (matrixLevels_.set(coarsestLevel))
{
if (directSolveCoarsest_)
{
coarsestLUMatrixPtr_.reset
(
......@@ -265,6 +267,56 @@ Foam::GAMGSolver::GAMGSolver
)
);
}
else
{
entry* coarseEntry = controlDict_.findEntry
(
"coarsestLevelCorr",
keyType::LITERAL_RECURSIVE
);
if (coarseEntry && coarseEntry->isDict())
{
coarsestSolverPtr_ = lduMatrix::solver::New
(
"coarsestLevelCorr",
matrixLevels_[coarsestLevel],
interfaceLevelsBouCoeffs_[coarsestLevel],
interfaceLevelsIntCoeffs_[coarsestLevel],
interfaceLevels_[coarsestLevel],
coarseEntry->dict()
);
}
else if (matrixLevels_[coarsestLevel].asymmetric())
{
coarsestSolverPtr_.set
(
new PBiCGStab
(
"coarsestLevelCorr",
matrixLevels_[coarsestLevel],
interfaceLevelsBouCoeffs_[coarsestLevel],
interfaceLevelsIntCoeffs_[coarsestLevel],
interfaceLevels_[coarsestLevel],
PBiCGStabSolverDict(tolerance_, relTol_)
)
);
}
else
{
coarsestSolverPtr_.set
(
new PCG
(
"coarsestLevelCorr",
matrixLevels_[coarsestLevel],
interfaceLevelsBouCoeffs_[coarsestLevel],
interfaceLevelsIntCoeffs_[coarsestLevel],
interfaceLevels_[coarsestLevel],
PCGsolverDict(tolerance_, relTol_)
)
);
}
}
}
}
else
......
......@@ -135,6 +135,9 @@ class GAMGSolver
//- LU decomposed coarsest matrix
autoPtr<LUscalarMatrix> coarsestLUMatrixPtr_;
//- Sparse coarsest matrix solver
autoPtr<lduMatrix::solver> coarsestSolverPtr_;
// Private Member Functions
......
......@@ -26,8 +26,6 @@ License
\*---------------------------------------------------------------------------*/
#include "GAMGSolver.H"
#include "PCG.H"
#include "PBiCGStab.H"
#include "SubField.H"
#include "PrecisionAdaptor.H"
......@@ -695,42 +693,16 @@ void Foam::GAMGSolver::solveCoarsestLevel
else
{
coarsestCorrField = 0;
solverPerformance coarseSolverPerf;
if (matrixLevels_[coarsestLevel].asymmetric())
{
coarseSolverPerf = PBiCGStab
(
"coarsestLevelCorr",
matrixLevels_[coarsestLevel],
interfaceLevelsBouCoeffs_[coarsestLevel],
interfaceLevelsIntCoeffs_[coarsestLevel],
interfaceLevels_[coarsestLevel],
PBiCGStabSolverDict(tolerance_, relTol_)
).scalarSolve
(
coarsestCorrField,
coarsestSource
);
}
else
{
coarseSolverPerf = PCG
(
"coarsestLevelCorr",
matrixLevels_[coarsestLevel],
interfaceLevelsBouCoeffs_[coarsestLevel],
interfaceLevelsIntCoeffs_[coarsestLevel],
interfaceLevels_[coarsestLevel],
PCGsolverDict(tolerance_, relTol_)
).scalarSolve
const solverPerformance coarseSolverPerf
(
coarsestSolverPtr_->solve
(
coarsestCorrField,
coarsestSource
);
}
)
);
if (debug >= 2)
if (debug)
{
coarseSolverPerf.print(Info.masterStream(coarseComm));
}
......
......@@ -33,6 +33,15 @@ solvers
{
$p;
relTol 0;
// Explicit specify solver for coarse-level correction to override
// solution tolerance
coarsestLevelCorr
{
solver PCG;
preconditioner DIC;
relTol 0.05;
}
}
"(U|k|B|nuTilda)"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment