19 KSPSetTolerances(solver_,
20 tolerance_options_.residual_relative,
21 tolerance_options_.residual_absolute,
22 tolerance_options_.residual_divergence,
23 tolerance_options_.maximum_iterations);
37 KSPSetApplicationContext(solver_, &(*context_ptr_));
43 KSPSetConvergenceTest(solver_, &KSPConvergedDefault,
nullptr,
nullptr);
62 if (IsSystemSet())
return;
63 this->PreSetupCallback();
65 KSPCreate(PETSC_COMM_WORLD, &solver_);
66 KSPSetType(solver_, iterative_method_.c_str());
68 this->ApplyToleranceOptions();
70 if (iterative_method_ ==
"gmres")
72 KSPGMRESSetRestart(solver_, tolerance_options_.gmres_restart_interval);
73 KSPGMRESSetBreakdownTolerance(solver_,
74 tolerance_options_.gmres_breakdown_tolerance);
77 KSPSetInitialGuessNonzero(solver_, PETSC_FALSE);
81 this->SetSolverContext();
82 this->SetConvergenceTest();
85 this->SetSystemSize();
88 this->SetPreconditioner();
90 this->PostSetupCallback();
106 this->PreSolveCallback();
107 this->SetInitialGuess();
110 if (not suppress_kspsolve_)
111 KSPSolve(solver_, b_, x_);
112 this->PostSolveCallback();
virtual void PreSetupCallback()
virtual void PreSolveCallback()
virtual void SetOptions()
void ApplyToleranceOptions()
virtual void SetPreconditioner()
virtual void SetConvergenceTest()
virtual void SetSolverContext()
virtual void PostSetupCallback()
virtual void PostSolveCallback()
virtual void SetMonitor()