Chi-Tech
wgs_context_matrix_action.cc
Go to the documentation of this file.
1#include "wgs_context.h"
2
4
5#include <petscksp.h>
6
7namespace lbs
8{
9
10template<>
12 Vec& action_vector,
13 Vec& action)
14{
15 WGSContext* gs_context_ptr;
16 MatShellGetContext(matrix, &gs_context_ptr);
17
18 //Shorten some names
19 lbs::LBSSolver& lbs_solver = gs_context_ptr->lbs_solver_;
20 LBSGroupset& groupset = gs_context_ptr->groupset_;
21
22 //============================================= Copy krylov action_vector
23 // into local
24 lbs_solver.SetPrimarySTLvectorFromGSPETScVec(groupset,
25 action_vector,
27
28 //============================================= Setting the source using
29 // updated phi_old
30 auto& q_moments_local = lbs_solver_.QMomentsLocal();
31 q_moments_local.assign(q_moments_local.size(), 0.0);
32 set_source_function_(groupset, q_moments_local,
33 lbs_solver.PhiOldLocal(),
34 lhs_src_scope_);
35
36 //============================================= Apply transport operator
37 gs_context_ptr->ApplyInverseTransportOperator(lhs_src_scope_);
38
39 //============================================= Copy local into
40 // operating vector
41 // We copy the STL data to the operating vector
42 // petsc_phi_delta first because it's already sized.
43 // pc_output is not necessarily initialized yet.
44 lbs_solver.SetGSPETScVecFromPrimarySTLvector(groupset,
45 action,
47
48 //============================================= Computing action
49 // A = [I - DLinvMS]
50 // Av = [I - DLinvMS]v
51 // = v - DLinvMSv
52 VecAYPX(action, -1.0, action_vector);
53
54 return 0;
55}
56
57}
58
virtual void SetGSPETScVecFromPrimarySTLvector(LBSGroupset &groupset, Vec x, PhiSTLOption which_phi)
virtual void SetPrimarySTLvectorFromGSPETScVec(LBSGroupset &groupset, Vec x_src, PhiSTLOption which_phi)
std::vector< double > & PhiOldLocal()
struct _p_Mat * Mat
struct _p_Vec * Vec
LBSGroupset & groupset_
Definition: wgs_context.h:28
virtual void ApplyInverseTransportOperator(int scope)=0
int MatrixAction(MatType &matrix, VecType &action_vector, VecType &action) override
LBSSolver & lbs_solver_
Definition: wgs_context.h:27