Chi-Tech
wgs_context_matrix_action.cc
Go to the documentation of this file.
1
#include "
wgs_context.h
"
2
3
#include "
A_LBSSolver/lbs_solver.h
"
4
5
#include <petscksp.h>
6
7
namespace
lbs
8
{
9
10
template
<>
11
int
WGSContext<Mat, Vec, KSP>::MatrixAction
(
Mat
& matrix,
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,
26
PhiSTLOption::PHI_OLD
);
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,
46
PhiSTLOption::PHI_NEW
);
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
lbs::LBSGroupset
Definition:
lbs_groupset.h:36
lbs::LBSSolver
Definition:
lbs_solver.h:50
lbs::LBSSolver::SetGSPETScVecFromPrimarySTLvector
virtual void SetGSPETScVecFromPrimarySTLvector(LBSGroupset &groupset, Vec x, PhiSTLOption which_phi)
Definition:
lbs_07_vectorassembly.cc:56
lbs::LBSSolver::SetPrimarySTLvectorFromGSPETScVec
virtual void SetPrimarySTLvectorFromGSPETScVec(LBSGroupset &groupset, Vec x_src, PhiSTLOption which_phi)
Definition:
lbs_07_vectorassembly.cc:100
lbs::LBSSolver::PhiOldLocal
std::vector< double > & PhiOldLocal()
Definition:
lbs_00_constrdestr.cc:224
lbs_solver.h
lbs
Definition:
acceleration.cc:10
lbs::PhiSTLOption::PHI_OLD
@ PHI_OLD
lbs::PhiSTLOption::PHI_NEW
@ PHI_NEW
Mat
struct _p_Mat * Mat
Definition:
petsc_forward_declarations.h:10
Vec
struct _p_Vec * Vec
Definition:
petsc_forward_declarations.h:9
lbs::WGSContext
Definition:
wgs_context.h:26
lbs::WGSContext::groupset_
LBSGroupset & groupset_
Definition:
wgs_context.h:28
lbs::WGSContext::ApplyInverseTransportOperator
virtual void ApplyInverseTransportOperator(int scope)=0
lbs::WGSContext::MatrixAction
int MatrixAction(MatType &matrix, VecType &action_vector, VecType &action) override
lbs::WGSContext::lbs_solver_
LBSSolver & lbs_solver_
Definition:
wgs_context.h:27
wgs_context.h
modules
LinearBoltzmannSolvers
A_LBSSolver
IterativeMethods
wgs_context_matrix_action.cc
Generated by
1.9.3