https://mooseframework.inl.gov
FEProblemSolve.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "FEProblemSolve.h"
11 
12 #include "FEProblem.h"
13 #include "NonlinearSystemBase.h"
14 #include "LinearSystem.h"
15 #include "Convergence.h"
16 #include "Executioner.h"
18 #include "MooseUtils.h"
19 
20 std::set<std::string> const FEProblemSolve::_moose_line_searches = {"contact", "project"};
21 
22 const std::set<std::string> &
24 {
25  return _moose_line_searches;
26 }
27 
30 {
32 
33  params.addParam<unsigned int>("nl_max_its", 50, "Max Nonlinear Iterations");
34  params.addParam<unsigned int>("nl_forced_its", 0, "The Number of Forced Nonlinear Iterations");
35  params.addParam<unsigned int>("nl_max_funcs", 10000, "Max Nonlinear solver function evaluations");
36  params.addParam<Real>("nl_abs_tol", 1.0e-50, "Nonlinear Absolute Tolerance");
37  params.addParam<Real>("nl_rel_tol", 1.0e-8, "Nonlinear Relative Tolerance");
38  params.addParam<Real>(
39  "nl_div_tol",
40  1.0e10,
41  "Nonlinear Relative Divergence Tolerance. A negative value disables this check.");
42  params.addParam<Real>(
43  "nl_abs_div_tol",
44  1.0e50,
45  "Nonlinear Absolute Divergence Tolerance. A negative value disables this check.");
46  params.addParam<Real>("nl_abs_step_tol", 0., "Nonlinear Absolute step Tolerance");
47  params.addParam<Real>("nl_rel_step_tol", 0., "Nonlinear Relative step Tolerance");
48  params.addParam<unsigned int>("n_max_nonlinear_pingpong",
49  100,
50  "The maximum number of times the nonlinear residual can ping pong "
51  "before requesting halting the current evaluation and requesting "
52  "timestep cut for transient simulations");
53 
54  params.addParamNamesToGroup(
55  "nl_max_its nl_forced_its nl_max_funcs nl_abs_tol nl_rel_tol "
56  "nl_rel_step_tol nl_abs_step_tol nl_div_tol nl_abs_div_tol n_max_nonlinear_pingpong",
57  "Nonlinear Solver");
58 
59  return params;
60 }
61 
64 {
67 
68  std::set<std::string> line_searches = mooseLineSearches();
69 
70  std::set<std::string> alias_line_searches = {"default", "none", "basic"};
71  line_searches.insert(alias_line_searches.begin(), alias_line_searches.end());
72  std::set<std::string> petsc_line_searches = Moose::PetscSupport::getPetscValidLineSearches();
73  line_searches.insert(petsc_line_searches.begin(), petsc_line_searches.end());
74  std::string line_search_string = Moose::stringify(line_searches, " ");
75  MooseEnum line_search(line_search_string, "default");
76  std::string addtl_doc_str(" (Note: none = basic)");
77  params.addParam<MooseEnum>(
78  "line_search", line_search, "Specifies the line search type" + addtl_doc_str);
79  MooseEnum line_search_package("petsc moose", "petsc");
80  params.addParam<MooseEnum>("line_search_package",
81  line_search_package,
82  "The solver package to use to conduct the line-search");
83 
84  params.addParam<unsigned>("contact_line_search_allowed_lambda_cuts",
85  2,
86  "The number of times lambda is allowed to be cut in half in the "
87  "contact line search. We recommend this number be roughly bounded by 0 "
88  "<= allowed_lambda_cuts <= 3");
89  params.addParam<Real>("contact_line_search_ltol",
90  "The linear relative tolerance to be used while the contact state is "
91  "changing between non-linear iterations. We recommend that this tolerance "
92  "be looser than the standard linear tolerance");
93 
95  params.addParam<Real>("l_tol", 1.0e-5, "Linear Relative Tolerance");
96  params.addParam<Real>("l_abs_tol", 1.0e-50, "Linear Absolute Tolerance");
97  params.addParam<unsigned int>("l_max_its", 10000, "Max Linear Iterations");
98  params.addParam<std::vector<ConvergenceName>>(
99  "nonlinear_convergence",
100  "Name of the Convergence object(s) to use to assess convergence of the "
101  "nonlinear system(s) solve. If not provided, the default Convergence "
102  "associated with the Problem will be constructed internally.");
103  params.addParam<std::vector<ConvergenceName>>(
104  "linear_convergence",
105  "Name of the Convergence object(s) to use to assess convergence of the "
106  "linear system(s) solve. If not provided, the linear solver tolerance parameters are used");
107  params.addParam<bool>(
108  "snesmf_reuse_base",
109  true,
110  "Specifies whether or not to reuse the base vector for matrix-free calculation");
111  params.addParam<bool>(
112  "skip_exception_check", false, "Specifies whether or not to skip exception check");
113  params.addParam<bool>(
114  "use_pre_SMO_residual",
115  false,
116  "Compute the pre-SMO residual norm and use it in the relative convergence check. The "
117  "pre-SMO residual is computed at the begining of the time step before solution-modifying "
118  "objects are executed. Solution-modifying objects include preset BCs, constraints, "
119  "predictors, etc.");
120  params.addParam<bool>("automatic_scaling", "Whether to use automatic scaling for the variables.");
121  params.addParam<std::vector<bool>>(
122  "compute_scaling_once",
123  {true},
124  "Whether the scaling factors should only be computed once at the beginning of the simulation "
125  "through an extra Jacobian evaluation. If this is set to false, then the scaling factors "
126  "will be computed during an extra Jacobian evaluation at the beginning of every time step. "
127  "Vector entries correspond to each nonlinear system.");
128  params.addParam<std::vector<bool>>(
129  "off_diagonals_in_auto_scaling",
130  {false},
131  "Whether to consider off-diagonals when determining automatic scaling factors. Vector "
132  "entries correspond to each nonlinear system.");
133  params.addRangeCheckedParam<std::vector<Real>>(
134  "resid_vs_jac_scaling_param",
135  {0},
136  "0<=resid_vs_jac_scaling_param<=1",
137  "A parameter that indicates the weighting of the residual vs the Jacobian in determining "
138  "variable scaling parameters. A value of 1 indicates pure residual-based scaling. A value of "
139  "0 indicates pure Jacobian-based scaling. Vector entries correspond to each nonlinear "
140  "system.");
141  params.addParam<std::vector<std::vector<std::vector<std::string>>>>(
142  "scaling_group_variables",
143  "Name of variables that are grouped together for determining scale factors. (Multiple "
144  "groups can be provided, separated by semicolon). Vector entries correspond to each "
145  "nonlinear system.");
146  params.addParam<std::vector<std::vector<std::string>>>(
147  "ignore_variables_for_autoscaling",
148  "List of variables that do not participate in autoscaling. Vector entries correspond to each "
149  "nonlinear system.");
150  params.addRangeCheckedParam<unsigned int>(
151  "num_grids",
152  1,
153  "num_grids>0",
154  "The number of grids to use for a grid sequencing algorithm. This includes the final grid, "
155  "so num_grids = 1 indicates just one solve in a time-step");
156  params.addParam<std::vector<bool>>("residual_and_jacobian_together",
157  {false},
158  "Whether to compute the residual and Jacobian together. "
159  "Vector entries correspond to each nonlinear system.");
160 
161  params.addParam<bool>("reuse_preconditioner",
162  false,
163  "If true reuse the previously calculated "
164  "preconditioner for the linearized "
165  "system across multiple solves "
166  "spanning nonlinear iterations and time steps. "
167  "The preconditioner resets as controlled by "
168  "reuse_preconditioner_max_linear_its");
169  params.addParam<unsigned int>("reuse_preconditioner_max_linear_its",
170  25,
171  "Reuse the previously calculated "
172  "preconditioner for the linear system "
173  "until the number of linear iterations "
174  "exceeds this number");
175 
176  // Multi-system fixed point
177  // Defaults to false because of the difficulty of defining a good multi-system convergence
178  // criterion, unless we add a default one to the simulation?
179  params.addParam<bool>(
180  "multi_system_fixed_point",
181  false,
182  "Whether to perform fixed point (Picard) iterations between the nonlinear systems.");
183  params.addRangeCheckedParam<std::vector<Real>>(
184  "multi_system_fixed_point_relaxation_factor",
185  {1.0},
186  "multi_system_fixed_point_relaxation_factor>0 & multi_system_fixed_point_relaxation_factor<2",
187  "Relaxation factor(s) applied to system solution updates during multi-system fixed point "
188  "iterations; 1 disables relaxation. If one value is provided it is applied to every system; "
189  "otherwise the vector must match the number/order of systems being solved.");
190  params.addParam<ConvergenceName>(
191  "multi_system_fixed_point_convergence",
192  "Convergence object to determine the convergence of the multi-system fixed point iteration. "
193  "If unspecified, defaults to checking that every system is converged (based on their own "
194  "convergence criterion)");
195 
196  params.addParamNamesToGroup("l_tol l_abs_tol l_max_its reuse_preconditioner "
197  "reuse_preconditioner_max_linear_its",
198  "Linear Solver");
199  params.addParamNamesToGroup(
200  "solve_type snesmf_reuse_base use_pre_SMO_residual "
201  "num_grids residual_and_jacobian_together nonlinear_convergence linear_convergence",
202  "Nonlinear Solver");
203  params.addParamNamesToGroup(
204  "automatic_scaling compute_scaling_once off_diagonals_in_auto_scaling "
205  "scaling_group_variables resid_vs_jac_scaling_param ignore_variables_for_autoscaling",
206  "Solver variable scaling");
207  params.addParamNamesToGroup("line_search line_search_package contact_line_search_ltol "
208  "contact_line_search_allowed_lambda_cuts",
209  "Solver line search");
210  params.addParamNamesToGroup("multi_system_fixed_point multi_system_fixed_point_convergence "
211  "multi_system_fixed_point_relaxation_factor",
212  "Multiple solver system");
213  params.addParamNamesToGroup("skip_exception_check", "Advanced");
214 
215  return params;
216 }
217 
220  _num_grid_steps(cast_int<unsigned int>(getParam<unsigned int>("num_grids") - 1)),
221  _using_multi_sys_fp_iterations(getParam<bool>("multi_system_fixed_point")),
222  _multi_sys_fp_convergence(nullptr) // has not been created yet
223 {
224  if (_pars.isParamSetByUser("multi_system_fixed_point_relaxation_factor") &&
226  paramError("Can't use relaxation factors because multisystem fixed point iteration hasn't been "
227  "enabled!");
228 
230 
231  if (_moose_line_searches.find(getParam<MooseEnum>("line_search").operator std::string()) !=
232  _moose_line_searches.end())
234 
235  auto set_solver_params = [this, &ex](const SolverSystem & sys)
236  {
237  const auto prefix = sys.prefix();
238  if (dynamic_cast<const LinearSystem *>(&sys))
242 
243  // Set solver parameter prefix and system number
244  auto & solver_params = _problem.solverParams(sys.number());
245  solver_params._prefix = prefix;
246  solver_params._solver_sys_num = sys.number();
247  };
248 
249  // Extract and store PETSc related settings on FEProblemBase
250  for (const auto * const sys : _systems)
251  set_solver_params(*sys);
252 
253  // Set linear solve parameters in the equation system
254  // Nonlinear solve parameters are added in the DefaultNonlinearConvergence
255  EquationSystems & es = _problem.es();
256  es.parameters.set<Real>("linear solver tolerance") = getParam<Real>("l_tol");
257  es.parameters.set<Real>("linear solver absolute tolerance") = getParam<Real>("l_abs_tol");
258  es.parameters.set<unsigned int>("linear solver maximum iterations") =
259  getParam<unsigned int>("l_max_its");
260  es.parameters.set<bool>("reuse preconditioner") = getParam<bool>("reuse_preconditioner");
261  es.parameters.set<unsigned int>("reuse preconditioner maximum linear iterations") =
262  getParam<unsigned int>("reuse_preconditioner_max_linear_its");
263 
264  // Transfer to the Problem misc nonlinear solve optimization parameters
265  _problem.setSNESMFReuseBase(getParam<bool>("snesmf_reuse_base"),
266  _pars.isParamSetByUser("snesmf_reuse_base"));
267  _problem.skipExceptionCheck(getParam<bool>("skip_exception_check"));
268 
269  if (isParamValid("nonlinear_convergence"))
270  {
272  mooseError("The selected problem does not allow 'nonlinear_convergence' to be set.");
274  getParam<std::vector<ConvergenceName>>("nonlinear_convergence"));
275  }
276  else
278  if (isParamValid("linear_convergence"))
279  {
280  if (_problem.numLinearSystems() == 0)
281  paramError(
282  "linear_convergence",
283  "Setting 'linear_convergence' is currently only possible for solving linear systems");
285  getParam<std::vector<ConvergenceName>>("linear_convergence"));
286  }
287 
288  // Check whether the user has explicitly requested automatic scaling and is using a solve type
289  // without a matrix. If so, then we warn them
290  if ((_pars.isParamSetByUser("automatic_scaling") && getParam<bool>("automatic_scaling")) &&
291  std::all_of(_systems.begin(),
292  _systems.end(),
293  [this](const auto & solver_sys)
294  { return _problem.solverParams(solver_sys->number())._type == Moose::ST_JFNK; }))
295  {
296  paramWarning("automatic_scaling",
297  "Automatic scaling isn't implemented for the case where you do not have a "
298  "preconditioning matrix. No scaling will be applied");
299  _problem.automaticScaling(false);
300  }
301  else
302  // Check to see whether automatic_scaling has been specified anywhere, including at the
303  // application level. No matter what: if we don't have a matrix, we don't do scaling
305  isParamValid("automatic_scaling")
306  ? getParam<bool>("automatic_scaling")
307  : (getMooseApp().defaultAutomaticScaling() &&
308  std::any_of(_systems.begin(),
309  _systems.end(),
310  [this](const auto & solver_sys)
311  {
312  return _problem.solverParams(solver_sys->number())._type !=
314  })));
315 
316  if (!_using_multi_sys_fp_iterations && isParamValid("multi_system_fixed_point_convergence"))
317  paramError("multi_system_fixed_point_convergence",
318  "Cannot set a convergence object for multi-system fixed point iterations if "
319  "'multi_system_fixed_point' is set to false");
320  if (_using_multi_sys_fp_iterations && !isParamValid("multi_system_fixed_point_convergence"))
321  paramError("multi_system_fixed_point_convergence",
322  "Must set a convergence object for multi-system fixed point iterations if using "
323  "multi-system fixed point iterations");
324 
325  // Set the same parameters to every nonlinear system by default
326  int i_nl_sys = -1;
327  for (const auto i_sys : index_range(_systems))
328  {
329  auto nl_ptr = dynamic_cast<NonlinearSystemBase *>(_systems[i_sys]);
330  // Linear systems have very different parameters at the moment
331  if (!nl_ptr)
332  continue;
333  auto & nl = *nl_ptr;
334  i_nl_sys++;
335 
336  nl.setPreSMOResidual(getParam<bool>("use_pre_SMO_residual"));
337 
338  const auto res_and_jac =
339  getParamFromNonlinearSystemVectorParam<bool>("residual_and_jacobian_together", i_nl_sys);
340  if (res_and_jac)
341  nl.residualAndJacobianTogether();
342 
343  // Automatic scaling parameters
344  nl.computeScalingOnce(
345  getParamFromNonlinearSystemVectorParam<bool>("compute_scaling_once", i_nl_sys));
346  nl.autoScalingParam(
347  getParamFromNonlinearSystemVectorParam<Real>("resid_vs_jac_scaling_param", i_nl_sys));
348  nl.offDiagonalsInAutoScaling(
349  getParamFromNonlinearSystemVectorParam<bool>("off_diagonals_in_auto_scaling", i_nl_sys));
350  if (isParamValid("scaling_group_variables"))
351  nl.scalingGroupVariables(
352  getParamFromNonlinearSystemVectorParam<std::vector<std::vector<std::string>>>(
353  "scaling_group_variables", i_nl_sys));
354  if (isParamValid("ignore_variables_for_autoscaling"))
355  {
356  // Before setting ignore_variables_for_autoscaling, check that they are not present in
357  // scaling_group_variables
358  if (isParamValid("scaling_group_variables"))
359  {
360  const auto & ignore_variables_for_autoscaling =
361  getParamFromNonlinearSystemVectorParam<std::vector<std::string>>(
362  "ignore_variables_for_autoscaling", i_nl_sys);
363  const auto & scaling_group_variables =
364  getParamFromNonlinearSystemVectorParam<std::vector<std::vector<std::string>>>(
365  "scaling_group_variables", i_nl_sys);
366  for (const auto & group : scaling_group_variables)
367  for (const auto & var_name : group)
368  if (std::find(ignore_variables_for_autoscaling.begin(),
369  ignore_variables_for_autoscaling.end(),
370  var_name) != ignore_variables_for_autoscaling.end())
371  paramError("ignore_variables_for_autoscaling",
372  "Variables cannot be in a scaling grouping and also be ignored");
373  }
374  nl.ignoreVariablesForAutoscaling(
375  getParamFromNonlinearSystemVectorParam<std::vector<std::string>>(
376  "ignore_variables_for_autoscaling", i_nl_sys));
377  }
378  }
379 
380  // Multi-grid options
382 }
383 
384 template <typename T>
385 T
387  unsigned int index) const
388 {
389  const auto & param_vec = getParam<std::vector<T>>(param_name);
390  if (index > _num_nl_systems)
391  paramError(param_name,
392  "Vector parameter is requested at index (" + std::to_string(index) +
393  ") which is larger than number of nonlinear systems (" +
394  std::to_string(_num_nl_systems) + ").");
395  if (param_vec.size() == 0)
396  paramError(
397  param_name,
398  "This parameter was passed to a routine which cannot handle empty vector parameters");
399  if (param_vec.size() != 1 && param_vec.size() != _num_nl_systems)
400  paramError(param_name,
401  "Vector parameter size (" + std::to_string(param_vec.size()) +
402  ") is different than the number of nonlinear systems (" +
403  std::to_string(_num_nl_systems) + ").");
404 
405  // User passed only one parameter, assume it applies to all nonlinear systems
406  if (param_vec.size() == 1)
407  return param_vec[0];
408  else
409  return param_vec[index];
410 }
411 
412 void
414 {
417  // Keep track of the solution warnings from the setup
418  // before a count reset at the beginning of the time step
419  if (!_app.isRecovering())
420  {
424  }
425 }
426 
427 void
429 {
430  // nonlinear
431  const auto conv_names = _problem.getNonlinearConvergenceNames();
432  for (const auto & conv_name : conv_names)
433  {
434  auto & conv = _problem.getConvergence(conv_name);
436  }
437 
438  // linear
439  if (isParamValid("linear_convergence"))
440  {
441  const auto conv_names = getParam<std::vector<ConvergenceName>>("linear_convergence");
442  for (const auto & conv_name : conv_names)
443  {
444  auto & conv = _problem.getConvergence(conv_name);
446  }
447  }
448 
449  // multisystem fixed point
450  if (isParamValid("multi_system_fixed_point_convergence"))
451  {
453  &_problem.getConvergence(getParam<ConvergenceName>("multi_system_fixed_point_convergence"));
456  }
457 }
458 
459 void
461 {
463  getParam<std::vector<Real>>("multi_system_fixed_point_relaxation_factor");
464  if (_multi_sys_fp_relax_factors.size() == 1)
466  else if (_multi_sys_fp_relax_factors.size() != _systems.size())
467  paramError("multi_system_fixed_point_relaxation_factor",
468  "Must provide either 1 value or " + Moose::stringify(_systems.size()) +
469  " values (one per system in the solve order).");
470 }
471 
472 bool
474 {
475  // Outer loop for multi-grid convergence
476  bool converged = false;
477  unsigned int num_fp_multisys_iters = 0;
478 
479  for (MooseIndex(_num_grid_steps) grid_step = 0; grid_step <= _num_grid_steps; ++grid_step)
480  {
481  // Multi-system fixed point loop
482  // Use a convergence object if provided, if not, use a reasonable default of every nested system
483  // being converged
484  num_fp_multisys_iters = 0;
485  converged = false;
486  while (!converged)
487  {
488  // Loop over each system
489  for (const auto sys_i : index_range(_systems))
490  {
491  auto * const sys = _systems[sys_i];
492  const bool is_nonlinear = (dynamic_cast<NonlinearSystemBase *>(sys) != nullptr);
493  const Real fp_relax =
495  const bool apply_fp_relax =
496  _using_multi_sys_fp_iterations && !MooseUtils::absoluteFuzzyEqual(fp_relax, 1.0);
497  if (apply_fp_relax)
498  {
499  sys->setFixedPointRelaxationFactor(fp_relax);
500  sys->saveOldSolutionForFixedPointRelaxation();
501  }
502 
503  // Call solve on the problem for that system
504  if (is_nonlinear)
505  _problem.solve(sys->number());
506  else
507  {
508  const auto linear_sys_number =
509  cast_int<unsigned int>(sys->number() - _problem.numNonlinearSystems());
510  _problem.solveLinearSystem(linear_sys_number, &_problem.getPetscOptions());
511  }
512 
513  // Check convergence
514  const auto solve_name =
515  _systems.size() == 1 ? " Solve" : "System " + sys->name() + ": Solve";
516  if (_problem.shouldSolve())
517  {
518  if (_problem.converged(sys->number()))
519  {
520  if (apply_fp_relax)
521  sys->applyFixedPointRelaxation();
522  _console << COLOR_GREEN << solve_name << " Converged!" << COLOR_DEFAULT << std::endl;
523  }
524  else
525  {
526  _console << COLOR_RED << solve_name << " Did NOT Converge!" << COLOR_DEFAULT
527  << std::endl;
528  if (apply_fp_relax)
529  sys->clearFixedPointRelaxation();
530  return false;
531  }
532  }
533  else
534  _console << COLOR_GREEN << solve_name << " Skipped!" << COLOR_DEFAULT << std::endl;
535 
536  if (!is_nonlinear)
537  {
538  const auto linear_sys_number =
539  cast_int<unsigned int>(sys->number() - _problem.numNonlinearSystems());
540  auto & linear_sys = _problem.getLinearSystem(linear_sys_number);
541 
542  // This is for postprocessing purposes in case none of the objects request the gradients.
543  // TODO: Somehow collect information if the postprocessors need gradients and if nothing
544  // needs this, just skip it
545  linear_sys.computeGradients();
546  }
547 
548  if (apply_fp_relax)
549  sys->clearFixedPointRelaxation();
550  }
551 
552  // Assess convergence of the multi-system fixed point iteration
554  converged = true;
555  else
556  {
557  converged = _multi_sys_fp_convergence->checkConvergence(num_fp_multisys_iters) ==
559  if (_multi_sys_fp_convergence->checkConvergence(num_fp_multisys_iters) ==
561  break;
562  }
563  num_fp_multisys_iters++;
564  }
565 
566  if (grid_step != _num_grid_steps)
568  }
569 
571  return (_multi_sys_fp_convergence->checkConvergence(num_fp_multisys_iters) ==
573  else
574  return converged;
575 }
static InputParameters validParams()
bool shouldSolve() const
const std::vector< ConvergenceName > & getNonlinearConvergenceNames() const
Gets the nonlinear system convergence object name(s).
FEProblemBase & _problem
Reference to FEProblem.
Definition: SolveObject.h:47
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition: KokkosUtils.h:40
void accumulateTimeStepIntoTotalOccurences(const unsigned int timestep_index)
Pass the number of solution invalid occurrences from current timestep to cumulative timestep counter ...
const InputParameters & _pars
The object&#39;s parameters.
Definition: MooseBase.h:394
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
std::string _prefix
Definition: SolverParams.h:35
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseBase.h:416
virtual std::size_t numNonlinearSystems() const override
std::set< std::string > getPetscValidLineSearches()
Returns the valid petsc line search options as a set of strings.
void accumulateIterationIntoTimeStepOccurences()
Pass the number of solution invalid occurrences from current iteration to cumulative counters...
virtual MooseConvergenceStatus checkConvergence(unsigned int iter)=0
Returns convergence status.
static std::set< std::string > const _moose_line_searches
Moose provided line searches.
std::vector< Real > _multi_sys_fp_relax_factors
Per-system relaxation factors for multi-system fixed point iterations (expanded to match the number/o...
virtual bool onlyAllowDefaultNonlinearConvergence() const
Returns true if an error will result if the user supplies &#39;nonlinear_convergence&#39;.
virtual bool solve() override
Picard solve the FEProblem.
FEProblemSolve(Executioner &ex)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void initialSetup()
Method that should be executed once, before any solve calls.
Definition: SolveObject.h:32
const unsigned int _num_grid_steps
The number of steps to perform in a grid sequencing algorithm.
virtual void solve(const unsigned int nl_sys_num)
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition: MooseBase.h:87
void computeGradients()
Compute and store raw and requested limited Green-Gauss gradients for linear FV variables.
InputParameters emptyInputParameters()
Nonlinear system to be solved.
void skipExceptionCheck(bool skip_exception_check)
Set a flag that indicates if we want to skip exception and stop solve.
virtual void addLineSearch(const InputParameters &)
add a MOOSE line search
void setConvergedReasonFlags(FEProblemBase &fe_problem, std::string prefix)
Set flags that will instruct the user on the reason their simulation diverged from PETSc&#39;s perspectiv...
Definition: PetscSupport.C:804
void syncIteration()
Sync iteration counts to main processor Sum across all processors.
void uniformRefine()
uniformly refine the problem mesh(es).
void numGridSteps(unsigned int num_grid_steps)
Set the number of steps in a grid sequences.
Convergence * _multi_sys_fp_convergence
Convergence object to assess the convergence of the multi-system fixed point iteration.
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
Definition: MooseApp.h:184
Jacobian-Free Newton Krylov.
Definition: MooseTypes.h:894
virtual libMesh::EquationSystems & es() override
virtual bool converged(const unsigned int sys_num)
Eventually we want to convert this virtual over to taking a solver system number argument.
Definition: SubProblem.h:113
static InputParameters feProblemDefaultConvergenceParams()
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:54
void setLinearConvergenceNames(const std::vector< ConvergenceName > &convergence_names)
Sets the linear convergence object name(s) if there is one.
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
virtual void checkIterationType(IterationType) const
Perform checks related to the iteration type.
Definition: Convergence.h:48
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:385
void setNonlinearConvergenceNames(const std::vector< ConvergenceName > &convergence_names)
Sets the nonlinear convergence object name(s) if there is one.
static InputParameters validParams()
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
void setNeedToAddDefaultNonlinearConvergence()
Sets _need_to_add_default_nonlinear_convergence to true.
LinearSystem & getLinearSystem(unsigned int sys_num)
Get non-constant reference to a linear system.
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
void dontAddCommonSNESOptions(FEProblemBase &fe_problem)
Function to ensure that common SNES options are not added to the PetscOptions storage object to be la...
void setupMultiSystemFixedPointRelaxationFactors()
Initializes/expands the multi-system fixed point relaxation factors.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
InputParameters getPetscValidParams()
Returns the PETSc options that are common between Executioners and Preconditioners.
T getParamFromNonlinearSystemVectorParam(const std::string &param_name, unsigned int index) const
Helper routine to get the nonlinear system parameter at the right index.
T & set(const std::string &)
unsigned int _num_nl_systems
Number of nonlinear systems.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:281
SolverParams & solverParams(unsigned int solver_sys_num=0)
Get the solver parameters.
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
const bool _using_multi_sys_fp_iterations
Whether we are using fixed point iterations for multi-system.
void convergenceSetup()
Performs setup related to Convergence objects.
virtual std::size_t numLinearSystems() const override
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:209
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
void automaticScaling(bool automatic_scaling) override
Automatic scaling setter.
void paramWarning(const std::string &param, Args... args) const
void storePetscOptions(FEProblemBase &fe_problem, const std::string &prefix, const ParallelParamObject &param_object)
Stores the PETSc options supplied from the parameter object on the problem.
Definition: PetscSupport.C:677
void setSNESMFReuseBase(bool reuse, bool set_by_user)
If or not to reuse the base vector for matrix-free calculation.
virtual void solveLinearSystem(const unsigned int linear_sys_num, const Moose::PetscSupport::PetscOptions *po=nullptr)
Build and solve a linear system.
bool isRecovering() const
Whether or not this is a "recover" calculation.
Definition: MooseApp.C:1493
void ErrorVector unsigned int
auto index_range(const T &sizable)
const std::string & _type
The type of this class.
Definition: MooseBase.h:388
std::vector< SolverSystem * > _systems
Vector of pointers to the systems.
virtual void initialSetup() override
Method that should be executed once, before any solve calls.
void setPreSMOResidual(bool use)
Set whether to evaluate the pre-SMO residual and use it in the subsequent relative convergence checks...
Tnew cast_int(Told oldvar)
static const std::set< std::string > & mooseLineSearches()
A solve object for use when wanting to solve multiple systems.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...