Chi-Tech
wgs_linear_solver.h
Go to the documentation of this file.
1#ifndef CHITECH_WGSLINSOLVEBASE_H
2#define CHITECH_WGSLINSOLVEBASE_H
3
5
6#include "wgs_context.h"
7
8#include <memory>
9#include <vector>
10#include <functional>
11
12namespace lbs
13{
14
15//################################################################### Class def
16/**Linear Solver specialization for Within GroupSet (WGS) solves.*/
17template<class MatType, class VecType, class SolverType>
18class WGSLinearSolver : public
19 chi_math::LinearSolver<MatType,VecType,SolverType>
20{
21protected:
22 std::vector<double> saved_q_moments_local_;
23
24public:
25 typedef std::shared_ptr<WGSContext<MatType,VecType,SolverType>> WGSContextPtr;
26
27 /**Constructor.
28 * \param gs_context_ptr Context Pointer to abstract context.*/
29 explicit WGSLinearSolver(WGSContextPtr gs_context_ptr) :
30 chi_math::LinearSolver<MatType,VecType,SolverType>
31 (IterativeMethodPETScName(gs_context_ptr->groupset_.iterative_method_),
32 gs_context_ptr)
33 {
34 auto& groupset = gs_context_ptr->groupset_;
35 auto& solver_tol_options = this->ToleranceOptions();
36 solver_tol_options.residual_absolute = groupset.residual_tolerance_;
37 solver_tol_options.maximum_iterations = groupset.max_iterations_;
38 solver_tol_options.gmres_restart_interval = groupset.gmres_restart_intvl_;
39 }
40
41protected:
42 void PreSetupCallback() override; //Customized via context
43 /*virtual void SetOptions();*/
44 /*virtual void SetSolverContext();*/ //Generic
45 void SetConvergenceTest() override; //Generic
46 /*virtual void SetMonitor();*/
47
48 virtual void SetSystemSize() override; //Customized via context
49 virtual void SetSystem() override; //Generic
50
51 void SetPreconditioner() override; //Customized via context
52
53 void PostSetupCallback() override; //Customized via context
54public:
55 /*virtual void Setup();*/
56
57protected:
58 void PreSolveCallback() override; //Customized via context
59 void SetRHS() override; //Generic + with context elements
60 void SetInitialGuess() override; //Generic
61 void PostSolveCallback() override; //Generic + with context elements
62public:
63 /*virtual void Solve();*/
64
65 virtual ~WGSLinearSolver() override;
66};
67
68}//namespace lbs
69
70#endif //CHITECH_WGSLINSOLVEBASE_H
const std::string iterative_method_
Definition: linear_solver.h:26
ToleranceOptions & ToleranceOptions()
Definition: linear_solver.h:76
LinearSolver(const std::string &iterative_method, LinSolveContextPtr context_ptr)
Definition: linear_solver.h:57
void PreSolveCallback() override
void PostSolveCallback() override
void PreSetupCallback() override
virtual ~WGSLinearSolver() override
std::shared_ptr< WGSContext< MatType, VecType, SolverType > > WGSContextPtr
void SetConvergenceTest() override
virtual void SetSystemSize() override
WGSLinearSolver(WGSContextPtr gs_context_ptr)
void PostSetupCallback() override
std::vector< double > saved_q_moments_local_
void SetRHS() override
void SetInitialGuess() override
virtual void SetSystem() override
void SetPreconditioner() override
SolverType
Definition: lbs_structs.h:27
std::string IterativeMethodPETScName(IterativeMethod it_method)