From 0ef0eb1e6a555cd154f0d0642778cde25c763235 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Fri, 25 May 2018 10:11:29 +0100 Subject: [PATCH] Robustness improvement on top AMG level --- .../amg/amgPolicy/clusterAmgPolicy.C | 3 +++ src/lduSolvers/amg/coarseAmgLevel.C | 20 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/lduSolvers/amg/amgPolicy/clusterAmgPolicy.C b/src/lduSolvers/amg/amgPolicy/clusterAmgPolicy.C index 26c6e50fb..18d778652 100644 --- a/src/lduSolvers/amg/amgPolicy/clusterAmgPolicy.C +++ b/src/lduSolvers/amg/amgPolicy/clusterAmgPolicy.C @@ -525,6 +525,9 @@ Foam::clusterAmgPolicy::clusterAmgPolicy "clusterAmgPolicy::clusterAmgPolicy\n" "(\n" " const lduMatrix& matrix,\n" + " const FieldField& bouCoeffs,\n" + " const FieldField& intCoeffs,\n" + " const lduInterfaceFieldPtrsList& interfaceFields,\n" " const label groupSize,\n" " const label minCoarseEqns\n" ")" diff --git a/src/lduSolvers/amg/coarseAmgLevel.C b/src/lduSolvers/amg/coarseAmgLevel.C index 57c9b167f..5e25384dc 100644 --- a/src/lduSolvers/amg/coarseAmgLevel.C +++ b/src/lduSolvers/amg/coarseAmgLevel.C @@ -193,11 +193,9 @@ void Foam::coarseAmgLevel::solve { lduSolverPerformance coarseSolverPerf; - label maxIter = Foam::min(2*policyPtr_->minCoarseEqns(), 1000); - dictionary topLevelDict; topLevelDict.add("minIter", 1); - topLevelDict.add("maxIter", maxIter); + topLevelDict.add("maxIter", 500); topLevelDict.add("tolerance", tolerance); topLevelDict.add("relTol", relTol); @@ -220,7 +218,6 @@ void Foam::coarseAmgLevel::solve if (matrixPtr_->matrix().symmetric()) { // Note: must change preconditioner to C0. HJ. 10/Oct/2017 - // topLevelDict.add("preconditioner", "Cholesky"); topLevelDict.add("preconditioner", "ILUC0"); coarseSolverPerf = cgSolver @@ -248,6 +245,21 @@ void Foam::coarseAmgLevel::solve ).solve(x, b, cmpt); } + // Check for convergence + const scalar magInitialRes = mag(coarseSolverPerf.initialResidual()); + const scalar magFinalRes = mag(coarseSolverPerf.finalResidual()); + + if (magFinalRes > magInitialRes && magInitialRes > SMALL) + { + if (blockLduMatrix::debug) + { + Info<< "Divergence in top AMG level" << endl; + coarseSolverPerf.print(); + } + + x = 0; + } + // Restore debug blockLduMatrix::debug = oldDebug;