Chi-Tech
wgs_context.h
Go to the documentation of this file.
1#ifndef CHITECH_WGS_CONTEXT_H
2#define CHITECH_WGS_CONTEXT_H
3
5
6#include <vector>
7#include <functional>
8#include <memory>
9
10namespace lbs
11{
12 class LBSGroupset;
13 class LBSSolver;
14}
15
16typedef std::function<void(lbs::LBSGroupset&,
17 std::vector<double>&,
18 const std::vector<double>&,
20
21namespace lbs
22{
23
24template<class MatType, class VecType, class SolverType>
25struct WGSContext : public chi_math::LinearSolverContext<MatType, VecType>
26{
32 bool log_info_ = true;
34
35 WGSContext(LBSSolver& lbs_solver,
36 LBSGroupset& groupset,
37 const SetSourceFunction& set_source_function,
38 int lhs_scope, int rhs_scope,
39 bool log_info) :
40 lbs_solver_(lbs_solver),
41 groupset_(groupset),
42 set_source_function_(set_source_function),
43 lhs_src_scope_(lhs_scope),
44 rhs_src_scope_(rhs_scope),
45 log_info_(log_info)
46 {
49 }
50
51 virtual void PreSetupCallback() {};
52 virtual void SetPreconditioner(SolverType& solver) {};
53 virtual void PostSetupCallback() {};
54
55 virtual void PreSolveCallback() {};
56
57 int MatrixAction(MatType& matrix,
58 VecType& action_vector,
59 VecType& action) override;
60
61 virtual std::pair<int64_t, int64_t> SystemSize() = 0;
62
63 /**This operation applies the inverse of the transform operator in the form
64 * Ay = x where the the vector x's underlying implementing is always LBS's
65 * q_moments_local vextor.*/
66 virtual void ApplyInverseTransportOperator(int scope) = 0;
67
68 virtual void PostSolveCallback() {};
69};
70
71}//namespace lbs
72
73#endif //CHITECH_WGS_CONTEXT_H
SolverType
Definition: lbs_structs.h:27
std::function< void(LBSGroupset &groupset, std::vector< double > &destination_q, const std::vector< double > &phi, SourceFlags source_flags)> SetSourceFunction
Definition: lbs_structs.h:110
LBSGroupset & groupset_
Definition: wgs_context.h:28
virtual void PostSetupCallback()
Definition: wgs_context.h:53
virtual void ApplyInverseTransportOperator(int scope)=0
size_t counter_applications_of_inv_op_
Definition: wgs_context.h:33
virtual void PreSolveCallback()
Definition: wgs_context.h:55
virtual void PostSolveCallback()
Definition: wgs_context.h:68
virtual std::pair< int64_t, int64_t > SystemSize()=0
int MatrixAction(MatType &matrix, VecType &action_vector, VecType &action) override
LBSSolver & lbs_solver_
Definition: wgs_context.h:27
const SetSourceFunction & set_source_function_
Definition: wgs_context.h:29
virtual void PreSetupCallback()
Definition: wgs_context.h:51
virtual void SetPreconditioner(SolverType &solver)
Definition: wgs_context.h:52
WGSContext(LBSSolver &lbs_solver, LBSGroupset &groupset, const SetSourceFunction &set_source_function, int lhs_scope, int rhs_scope, bool log_info)
Definition: wgs_context.h:35
std::function< void(lbs::LBSGroupset &, std::vector< double > &, const std::vector< double > &, int)> SetSourceFunction
Definition: wgs_context.h:19