Skip to content
Snippets Groups Projects
Commit 8ebbdb63 authored by stefano zampini's avatar stefano zampini Committed by Mark OLESEN
Browse files

Add stages to PetscLog

parent 286fc357
No related merge requests found
......@@ -166,14 +166,24 @@ Foam::solverPerformance Foam::petscSolver::scalarSolve
ctx.initialized() = true;
needsCacheUpdate = false;
PetscLogStageRegister
(
("foam_" + eqName_ + "_mat").c_str(),
&ctx.matstage
);
PetscLogStageRegister
(
("foam_" + eqName_ + "_ksp").c_str(),
&ctx.kspstage
);
computeMatAllocation(Amat, lowNonZero, maxLowNonZeroPerRow);
buildMat(Amat, lowNonZero, maxLowNonZeroPerRow);
buildMat(Amat, lowNonZero, maxLowNonZeroPerRow, ctx.matstage);
buildKsp(Amat, ksp);
}
if (ctx.caching.needsMatrixUpdate() && needsCacheUpdate)
{
buildMat(Amat, lowNonZero, maxLowNonZeroPerRow);
buildMat(Amat, lowNonZero, maxLowNonZeroPerRow, ctx.matstage);
updateKsp(ksp, Amat, !ctx.caching.needsPrecondUpdate());
}
......@@ -269,6 +279,8 @@ Foam::solverPerformance Foam::petscSolver::scalarSolve
);
}
PetscLogStagePush(ctx.kspstage);
// Setup KSP (this is not explicitly needed, but we call it to separate
// PCSetUp from KSPSolve timings when requesting -log_view from PETSc)
KSPSetUp(ksp);
......@@ -276,6 +288,8 @@ Foam::solverPerformance Foam::petscSolver::scalarSolve
// Solve A x = b
KSPSolve(ksp, petsc_source, petsc_psi);
PetscLogStagePop();
// Set nIterations and final residual
PetscInt nIters;
KSPGetIterationNumber(ksp, &nIters);
......@@ -527,9 +541,12 @@ void Foam::petscSolver::buildMat
(
Mat& Amat,
List<label>& lowNonZero,
label& maxLowNonZeroPerRow
label& maxLowNonZeroPerRow,
PetscLogStage stage
) const
{
PetscLogStagePush(stage);
const lduAddressing& lduAddr = matrix_.mesh().lduAddr();
const lduInterfacePtrsList interfaces(matrix_.mesh().interfaces());
......@@ -710,6 +727,7 @@ void Foam::petscSolver::buildMat
MatAssemblyBegin(Amat, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd(Amat, MAT_FINAL_ASSEMBLY);
PetscLogStagePop();
}
......
......@@ -105,7 +105,8 @@ class petscSolver
(
Mat& Amat,
List<label>& lowNonZero,
label& maxLowNonZeroPerRow
label& maxLowNonZeroPerRow,
PetscLogStage stage
) const;
//- Build the ksp_ krylov solver context
......
......@@ -69,6 +69,9 @@ public:
Mat Amat;
KSP ksp;
PetscLogStage matstage;
PetscLogStage kspstage;
solverPerformance performance;
petscCacheManager caching;
......@@ -143,7 +146,8 @@ public:
}
}
//- Compute the normFactor used in convergence testing, assumes ArowsSum has been already computed
//- Compute the normFactor used in convergence testing,
//- assumes ArowsSum has been already computed
void computeNormFactor(Mat A, Vec psi, Vec source)
{
if (!init_aux_vectors_) return;
......
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