Skip to content
Snippets Groups Projects
Commit 61f57ab7 authored by Simone Bnà's avatar Simone Bnà
Browse files

ENH: used the rnorm from petsc as residual to be scaled by the normFactor

parent 6f85d99c
No related branches found
No related tags found
No related merge requests found
...@@ -236,31 +236,21 @@ PetscErrorCode Foam::PetscUtils::foamKSPConverge ...@@ -236,31 +236,21 @@ PetscErrorCode Foam::PetscUtils::foamKSPConverge
KSPGetSolution(ksp, &psi); KSPGetSolution(ksp, &psi);
KSPGetRhs(ksp, &source); KSPGetRhs(ksp, &source);
// Precompute A dot psi // compute the normFactor only at the first iteration
MatMult(A, psi, ctx->AdotPsi);
// Only compute normFactor on the first iteration
if (it == 0)
{ {
ctx->normFactor = // precompute A dot psi
Foam::PetscUtils::normFactor MatMult(A, psi, ctx->AdotPsi);
( ctx->normFactor = Foam::PetscUtils::normFactor(A,
ctx->AdotPsi, ctx->AdotPsi,
psi, psi,
source, source,
ctx->ArowsSum ctx->ArowsSum,
); ctx->normFactorVec);
} }
PetscScalar residual = // rescale the petsc norm (default l1) by the normFactor
calcResidual PetscScalar residual = rnorm / ctx->normFactor;
(
source,
ctx->AdotPsi,
ctx->rA,
ctx->normFactor
);
if (it == 0) if (it == 0)
{ {
solverPerf->initialResidual() = residual; solverPerf->initialResidual() = residual;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment