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
Branches
No related merge requests found
......@@ -236,31 +236,21 @@ PetscErrorCode Foam::PetscUtils::foamKSPConverge
KSPGetSolution(ksp, &psi);
KSPGetRhs(ksp, &source);
// Precompute A dot psi
MatMult(A, psi, ctx->AdotPsi);
// Only compute normFactor on the first iteration
if (it == 0)
// compute the normFactor only at the first iteration
{
ctx->normFactor =
Foam::PetscUtils::normFactor
(
ctx->AdotPsi,
psi,
source,
ctx->ArowsSum
);
// precompute A dot psi
MatMult(A, psi, ctx->AdotPsi);
ctx->normFactor = Foam::PetscUtils::normFactor(A,
ctx->AdotPsi,
psi,
source,
ctx->ArowsSum,
ctx->normFactorVec);
}
PetscScalar residual =
calcResidual
(
source,
ctx->AdotPsi,
ctx->rA,
ctx->normFactor
);
// rescale the petsc norm (default l1) by the normFactor
PetscScalar residual = rnorm / ctx->normFactor;
if (it == 0)
{
solverPerf->initialResidual() = residual;
......
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