14#define CheckContext(x) \
16throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + \
17": context casting failure")
18#define GetNLKDiffContextPtr(x) \
19 std::dynamic_pointer_cast<NLKEigenDiffContext>(x); \
29 if (nl_context_ptr->verbosity_level_ >= 1)
31 &nl_context_ptr->kresid_func_context_,
nullptr);
33 if (nl_context_ptr->verbosity_level_ >= 2)
38 &nl_context_ptr->kresid_func_context_,
nullptr);
46 auto& diff_solver = nl_context_ptr->diff_solver_;
47 auto sizes = diff_solver.GetNumPhiIterativeUnknowns();
59 VecDuplicate(
x_, &
r_);
68 &nl_context_ptr->kresid_func_context_);
74 SNESSetJacobian(
nl_solver_,
J_,
J_, MatMFFDComputeJacobian,
nullptr);
86 auto& lbs_solver = nl_context_ptr->lbs_solver_;
87 auto& groupsets = lbs_solver.Groupsets();
88 auto& front_gs = groupsets.front();
90 auto& phi_old_local = lbs_solver.PhiOldLocal();
91 auto& phi_new_local = lbs_solver.PhiNewLocal();
93 auto delta_phi = nl_context_ptr->PhiVecToSTLVec(
x_);
94 auto& phi_lph_ip1 = nl_context_ptr->phi_lph_ip1_;
97 auto phi_lp1_temp = phi_lph_ip1 + delta_phi;
98 lbs_solver.GSProjectBackPhi0(front_gs, phi_lp1_temp, phi_new_local);
99 lbs_solver.GSScopedCopyPrimarySTLvectors(front_gs, phi_new_local, phi_old_local);
102 double k_eff = nl_context_ptr->kresid_func_context_.k_eff;
104 const double production = lbs_solver.ComputeFissionProduction(phi_old_local);
108 PetscInt number_of_func_evals;
109 SNESGetNumberFunctionEvals(
nl_solver_, &number_of_func_evals);
112 if (nl_context_ptr->verbosity_level_ >= 1)
114 <<
" Final lambda-eigenvalue : "
115 << std::fixed << std::setw(10) << std::setprecision(7)
117 <<
" (num_DOps:" << number_of_func_evals <<
")"
LogStream Log(LOG_LVL level=LOG_0)
NLSolverContextPtr context_ptr_
void SetJacobian() override
void PostSolveCallback() override
void SetInitialGuess() override
void SetSystemSize() override
void SetFunction() override
void SetSystem() override
void SetMonitor() override
Vec CreateVector(int64_t local_size, int64_t global_size)
PetscErrorCode NLKEigenAccResidualFunction(SNES snes, Vec phi, Vec r, void *ctx)
PetscErrorCode KEigenSNESMonitor(SNES, PetscInt iter, PetscReal rnorm, void *ctx)
PetscErrorCode KEigenKSPMonitor(KSP ksp, PetscInt iter, PetscReal rnorm, void *ctx)
#define GetNLKDiffContextPtr(x)