Chi-Tech
nl_keigen.cc
Go to the documentation of this file.
1#include "nl_keigen.h"
2
3#include "ChiObjectFactory.h"
4#include "chi_log.h"
5
7
8namespace lbs
9{
10
12
14{
16
18 "Generalized implementation of a non-linear k-Eigenvalue solver");
19 params.SetDocGroup("LBSExecutors");
20
21 params.ChangeExistingParamToOptional("name", "XXPowerIterationKEigen");
22
23 params.AddRequiredParameter<size_t>("lbs_solver_handle",
24 "Handle to an existing lbs solver");
25
27 "nl_abs_tol", 1.0e-8, "Non-linear absolute tolerance");
29 "nl_rel_tol", 1.0e-8, "Non-linear relative tolerance");
31 "nl_sol_tol", 1.0e-50, "Non-linear solution tolerance");
33 "nl_max_its", 50, "Non-linear maximum iterations");
34
35 params.AddOptionalParameter("l_abs_tol", 1.0e-8, "Linear absolute tolerance");
36 params.AddOptionalParameter("l_rel_tol", 1.0e-8, "Linear relative tolerance");
38 "l_div_tol", 1.0e6, "Linear divergence tolerance");
39 params.AddOptionalParameter("l_max_its", 50, "Linear maximum iterations");
41 "l_gmres_restart_intvl", 30, "GMRes restart interval");
43 "l_gmres_breakdown_tol", 1.0e6, "GMRes breakdown tolerance");
44
46 "reinit_phi_1", true, "If true, reinitializes scalar phi fluxes to 1");
47
48 params.AddOptionalParameter("num_free_power_iterations",
49 0,
50 "The number of free power iterations to execute "
51 "before entering the non-linear algorithm");
52
53 return params;
54}
55
57 : chi_physics::Solver(params),
58 lbs_solver_(Chi::GetStackItem<LBSSolver>(
59 Chi::object_stack, params.GetParamValue<size_t>("lbs_solver_handle"))),
60 nl_context_(std::make_shared<NLKEigenAGSContext<Vec, SNES>>(lbs_solver_)),
61 nl_solver_(nl_context_),
62 reinit_phi_1_(params.GetParamValue<bool>("reinit_phi_1")),
63 num_free_power_its_(params.GetParamValue<int>("num_free_power_iterations"))
64{
65 auto& tolerances = nl_solver_.ToleranceOptions();
66
67 tolerances.nl_abs_tol_ = params.GetParamValue<double>("nl_abs_tol");
68 tolerances.nl_rel_tol_ = params.GetParamValue<double>("nl_rel_tol");
69 tolerances.nl_sol_tol_ = params.GetParamValue<double>("nl_sol_tol");
70 tolerances.nl_max_its_ = params.GetParamValue<int>("nl_max_its");
71
72 tolerances.l_rel_tol_ = params.GetParamValue<double>("l_rel_tol");
73 tolerances.l_abs_tol_ = params.GetParamValue<double>("l_abs_tol");
74 tolerances.l_div_tol_ = params.GetParamValue<double>("l_div_tol");
75 tolerances.l_max_its_ = params.GetParamValue<int>("l_max_its");
76 tolerances.l_gmres_restart_intvl_ =
77 params.GetParamValue<int>("l_gmres_restart_intvl");
78 tolerances.l_gmres_breakdown_tol_ =
79 params.GetParamValue<double>("l_gmres_breakdown_tol");
80}
81
83
85{
86 if (reinit_phi_1_)
88
89 if (num_free_power_its_ > 0)
90 {
91 double k_eff = 1.0;
95 k_eff);
96 }
97
100
102 {
105 1.0 / nl_context_->kresid_func_context_.k_eff);
106 }
107
109
110 Chi::log.Log()
111 << "LinearBoltzmann::KEigenvalueSolver execution completed\n\n";
112}
113
114} // namespace lbs
static chi::ChiLog & log
Definition: chi_runtime.h:81
LogStream Log(LOG_LVL level=LOG_0)
Definition: chi_log.cc:35
void SetDocGroup(const std::string &doc_group)
void AddRequiredParameter(const std::string &name, const std::string &doc_string)
void AddOptionalParameter(const std::string &name, T value, const std::string &doc_string)
void SetGeneralDescription(const std::string &description)
void ChangeExistingParamToOptional(const std::string &name, T value, const std::string &doc_string="")
T GetParamValue(const std::string &param_name) const
NonLinearSolverOptions & ToleranceOptions()
static chi::InputParameters GetInputParameters()
Definition: chi_solver.cc:16
std::vector< double > & PrecursorsNewLocal()
virtual void SetPhiVectorScalarValues(std::vector< double > &phi_vector, double value)
void Initialize() override
lbs::Options & Options()
std::vector< double > & PhiOldLocal()
LBSSolver & lbs_solver_
Definition: nl_keigen.h:16
void Initialize() override
Definition: nl_keigen.cc:82
static chi::InputParameters GetInputParameters()
Definition: nl_keigen.cc:13
NLKEigenvalueAGSSolver< Mat, Vec, SNES > nl_solver_
Definition: nl_keigen.h:18
XXNonLinearKEigen(const chi::InputParameters &params)
Definition: nl_keigen.cc:56
std::shared_ptr< NLKEigenAGSContext< Vec, SNES > > nl_context_
Definition: nl_keigen.h:17
void Execute() override
Definition: nl_keigen.cc:84
void Scale(VecDbl &x, const double &val)
void PowerIterationKEigen(LBSSolver &lbs_solver, double tolerance, int max_iterations, double &k_eff)
RegisterChiObject(lbs, DiffusionDFEMSolver)
struct _p_Vec * Vec
bool use_precursors
Definition: lbs_structs.h:138