Commit 0a79fc7f authored by Thomas Witkowski's avatar Thomas Witkowski

Added some support for block preconditioners.

parent 842726b8
......@@ -92,11 +92,12 @@ namespace AMDiS {
matAssembly();
// === Init PETSc solver. ===
KSPCreate(mpiCommGlobal, &kspInterior);
KSPSetOperators(kspInterior, getMatInterior(), getMatInterior(),
SAME_NONZERO_PATTERN);
KSPSetFromOptions(kspInterior);
// === Init PETSc solver and preconditioner objects. ===
initSolver(kspInterior);
KSPGetPC(kspInterior, &pcInterior);
initPreconditioner(pcInterior);
MSG("Fill petsc matrix needed %.5f seconds\n", MPI::Wtime() - wtime);
}
......@@ -131,14 +132,45 @@ namespace AMDiS {
}
void PetscSolverGlobalBlockMatrix::initSolver(KSP &ksp)
{
FUNCNAME("PetscSolverGlobalBlockMatrix::initSolver()");
KSPCreate(mpiCommGlobal, &ksp);
KSPSetOperators(ksp, getMatInterior(), getMatInterior(),
SAME_NONZERO_PATTERN);
KSPSetOptionsPrefix(ksp, kspPrefix.c_str());
KSPSetFromOptions(ksp);
}
void PetscSolverGlobalBlockMatrix::exitSolver(KSP ksp)
{
FUNCNAME("PetscSolverGlobalBlockMatrix::exitSolver()");
KSPDestroy(&ksp);
}
void PetscSolverGlobalBlockMatrix::initPreconditioner(PC pc)
{
FUNCNAME("PetscSolverGlobalBlockMatrix::initPreconditioner()");
PCSetFromOptions(pc);
}
void PetscSolverGlobalBlockMatrix::exitPreconditioner(PC pc)
{
FUNCNAME("PetscSolverGlobalBlockMatrix::exitPreconditioner()");
}
void PetscSolverGlobalBlockMatrix::solvePetscMatrix(SystemVector &vec,
AdaptInfo *adaptInfo)
{
FUNCNAME("PetscSolverGlobalBlockMatrix::solvePetscMatrix()");
KSPGetPC(kspInterior, &pcInterior);
setBlockPreconditioner(pcInterior);
const FiniteElemSpace *feSpace = componentSpaces[0];
VecDuplicate(getVecRhsInterior(), &petscSolVec);
......@@ -181,7 +213,9 @@ namespace AMDiS {
matDestroy();
KSPDestroy(&kspInterior);
exitPreconditioner(pcInterior);
exitSolver(kspInterior);
}
......
......@@ -58,12 +58,14 @@ namespace AMDiS {
/// Takes a DOF vector and sends its values to a given PETSc vector.
void setDofVector(Vec& petscVec, DOFVector<double>* vec);
virtual void initSolver(KSP &ksp);
virtual void setBlockPreconditioner(PC &pc)
{
PCSetFromOptions(pc);
}
virtual void exitSolver(KSP ksp);
virtual void initPreconditioner(PC pc);
virtual void exitPreconditioner(PC pc);
protected:
vector<Mat> nestMat;
......
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