16#define SNESTypes Mat,Vec,SNES
17#define CheckContext(x) \
19throw std::runtime_error(std::string(__PRETTY_FUNCTION__) + \
20": context casting failure")
21#define GetNLKAGSContextPtr(x) \
22 std::dynamic_pointer_cast<NLKEigenAGSContext<Vec,SNES>>(x); \
33 auto& lbs_solver = nl_context_ptr->lbs_solver_;
34 for (
auto& groupset : lbs_solver.Groupsets())
35 nl_context_ptr->groupset_ids.push_back(groupset.id_);
43 auto& lbs_solver = nl_context_ptr->lbs_solver_;
44 if (lbs_solver.Options().verbose_outer_iterations)
46 &nl_context_ptr->kresid_func_context_,
nullptr);
48 if (lbs_solver.Options().verbose_inner_iterations)
51 SNESGetKSP(nl_solver_, &ksp);
53 &nl_context_ptr->kresid_func_context_,
nullptr);
62 auto& lbs_solver = nl_context_ptr->lbs_solver_;
63 auto sizes = lbs_solver.GetNumPhiIterativeUnknowns();
65 num_local_dofs_ =
static_cast<int64_t
>(sizes.first);
66 num_globl_dofs_ =
static_cast<int64_t
>(sizes.second);
75 VecDuplicate(x_, &r_);
84 &nl_context_ptr->kresid_func_context_);
90 MatCreateSNESMF(nl_solver_, &J_);
91 SNESSetJacobian(nl_solver_, J_, J_, MatMFFDComputeJacobian,
nullptr);
99 auto& lbs_solver = nl_context_ptr->lbs_solver_;
100 const auto& groupset_ids = nl_context_ptr->groupset_ids;
102 lbs_solver.SetMultiGSPETScVecFromPrimarySTLvector(
111 auto& lbs_solver = nl_context_ptr->lbs_solver_;
114 const auto& groups = lbs_solver.Groups();
115 lbs_solver.SetPrimarySTLvectorFromGroupScopedPETScVec(
116 groups.front().id_, groups.back().id_, x_, lbs_solver.PhiOldLocal());
119 double k_eff = lbs_solver.ComputeFissionProduction(lbs_solver.PhiOldLocal());
121 PetscInt number_of_func_evals;
122 SNESGetNumberFunctionEvals(nl_solver_, &number_of_func_evals);
126 <<
" Final k-eigenvalue : "
127 << std::fixed << std::setw(10) << std::setprecision(7)
129 <<
" (num_TrOps:" << number_of_func_evals <<
")"
LogStream Log(LOG_LVL level=LOG_0)
void PostSolveCallback() override
void SetFunction() override
void PreSetupCallback() override
void SetSystem() override
void SetJacobian() override
void SetMonitor() override
void SetInitialGuess() override
void SetSystemSize() override
Vec CreateVector(int64_t local_size, int64_t global_size)
PetscErrorCode NLKEigenResidualFunction(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 GetNLKAGSContextPtr(x)