14 SNESGetApplicationContext(snes, &nl_context_ptr);
20 auto active_set_source_function = lbs_solver.GetActiveSetSourceFunction();
21 auto& front_gs = groupsets.front();
23 auto& q_moments_local = lbs_solver.QMomentsLocal();
24 auto& phi_old_local = lbs_solver.PhiOldLocal();
25 auto phi_temp = phi_old_local;
27 const auto& phi_l = nl_context_ptr->
phi_l_;
28 const auto& phi_lph_i = nl_context_ptr->
phi_lph_i_;
30 const auto& k_l = nl_context_ptr->
k_l;
31 const auto& Sf = nl_context_ptr->
Sf_;
34 auto SetLBSFissionSource = [&active_set_source_function,&front_gs]
38 active_set_source_function(front_gs, output,
44 auto SetLBSScatterSource = [&active_set_source_function,&front_gs]
48 active_set_source_function(front_gs, output,
57 auto SetPhi0FissionSource = [&front_gs,&lbs_solver,&phi_temp,
58 &SetLBSFissionSource,&q_moments_local]
62 lbs_solver.GSProjectBackPhi0(front_gs, input,
65 SetLBSFissionSource(phi_temp, q_moments_local);
67 auto output = lbs_solver.WGSCopyOnlyPhi0(front_gs, q_moments_local);
71 auto SetPhi0ScatterSource = [&front_gs,&lbs_solver,&phi_temp,
72 &SetLBSScatterSource,&q_moments_local]
73 (
const VecDbl& input,
bool suppress_wgs)
76 lbs_solver.GSProjectBackPhi0(front_gs, input,
79 SetLBSScatterSource(phi_temp, q_moments_local,
82 auto output = lbs_solver.WGSCopyOnlyPhi0(front_gs, q_moments_local);
86 auto Phi0FissionProdL2Norm = [&front_gs,&lbs_solver,&phi_temp]
90 lbs_solver.GSProjectBackPhi0(front_gs,
94 return lbs_solver.ComputeFissionProduction(phi_temp);
101 auto epsilon = delta_phi;
103 auto Ss_res = SetPhi0ScatterSource(phi_lph_ip1-phi_lph_i,
false);
104 auto Sscat = SetPhi0ScatterSource(delta_phi,
true);
106 auto Sfaux = SetPhi0FissionSource(delta_phi + phi_lph_ip1);
107 double lambda = Phi0FissionProdL2Norm(delta_phi + phi_lph_ip1);
108 Scale(Sfaux, 1.0 / lambda);
110 diff_solver.Assemble_b(Sscat + Sfaux + Ss_res - Sf);
111 diff_solver.Solve(epsilon,
true);
std::vector< LBSGroupset > & Groupsets()
void Scale(VecDbl &x, const double &val)
void Set(VecDbl &x, const double &val)
PetscErrorCode NLKEigenAccResidualFunction(SNES snes, Vec phi, Vec r, void *ctx)
@ APPLY_AGS_FISSION_SOURCES
@ APPLY_WGS_FISSION_SOURCES
@ APPLY_WGS_SCATTER_SOURCES
@ APPLY_AGS_SCATTER_SOURCES
std::vector< double > VecDbl
KResidualFunctionContext kresid_func_context_
VecDbl PhiVecToSTLVec(Vec phi) const
DiffusionMIPSolver & diff_solver_
void STLVecToPhiVec(const VecDbl &input, Vec phi) const