https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MultiSystemSolveObject.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
11#include "FEProblemBase.h"
12#include "LinearSystem.h"
13#include "NonlinearSystem.h"
14
17{
19 params.addParam<std::vector<SolverSystemName>>(
20 "system_names",
21 "Names of the solver systems (both linear and nonlinear) that will be solved");
22 // Multi-system fixed point
23 // Defaults to false because of the difficulty of defining a good multi-system convergence
24 // criterion, unless we add a default one to the simulation?
25 params.addParam<bool>(
26 "multi_system_fixed_point",
27 false,
28 "Whether to perform fixed point (Picard) iterations between the nonlinear systems.");
29 params.addRangeCheckedParam<std::vector<Real>>(
30 "multi_system_fixed_point_relaxation_factor",
31 {1.0},
32 "multi_system_fixed_point_relaxation_factor>0 & multi_system_fixed_point_relaxation_factor<2",
33 "Relaxation factor(s) applied to system solution updates during multi-system fixed point "
34 "iterations; 1 disables relaxation. If one value is provided it is applied to every system; "
35 "otherwise the vector must match the number/order of systems being solved.");
36 params.addParam<ConvergenceName>(
37 "multi_system_fixed_point_convergence",
38 "Convergence object to determine the convergence of the multi-system fixed point iteration.");
39
41 "system_names multi_system_fixed_point multi_system_fixed_point_convergence "
42 "multi_system_fixed_point_relaxation_factor",
43 "Multiple solver system");
44 return params;
45}
46
48 : SolveObject(ex),
49 _using_multi_sys_fp_iterations(getParam<bool>("multi_system_fixed_point")),
50 _multi_sys_fp_convergence(nullptr) // has not been created yet
51
52{
53 // Retrieve pointers to all the systems from the problem by default
54 const auto & nl_sys_names = _problem.getNonlinearSystemNames();
55 const auto & linear_sys_names = _problem.getLinearSystemNames();
56 if (!isParamValid("system_names"))
57 {
58 for (const auto & sys_name : nl_sys_names)
60 for (const auto & sys_name : linear_sys_names)
62 _num_nl_systems = nl_sys_names.size();
63 }
64 else
65 {
67 // Retrieve pointers to all the user-specified systems in the order that the user specified them
68 for (const auto & sys_name : getParam<std::vector<SolverSystemName>>("system_names"))
69 {
70 if (std::find(nl_sys_names.begin(), nl_sys_names.end(), sys_name) != nl_sys_names.end())
71 {
74 }
75 else if (std::find(linear_sys_names.begin(), linear_sys_names.end(), sys_name) !=
76 linear_sys_names.end())
78 else
79 paramError("system_names",
80 "System '" + sys_name +
81 "' was not found in the Problem. Did you forget to declare it in the "
82 "[Problem] block?");
83 }
84 }
85
86 if (_pars.isParamSetByUser("multi_system_fixed_point_relaxation_factor") &&
88 paramError("Can't use relaxation factors because multisystem fixed point iteration hasn't been "
89 "enabled!");
90
92}
93
94void
96{
98 getParam<std::vector<Real>>("multi_system_fixed_point_relaxation_factor");
99 if (_multi_sys_fp_relax_factors.size() == 1)
101 else if (_multi_sys_fp_relax_factors.size() != _systems.size())
102 paramError("multi_system_fixed_point_relaxation_factor",
103 "Must provide either 1 value or " + Moose::stringify(_systems.size()) +
104 " values (one per system in the solve order).");
105
106 // For each solver system; record whether to perform relaxation (relaxation_factor != 1)
107 _perform_multi_sys_fp_relaxation.resize(_systems.size(), false);
108 for (const auto i : make_range(_systems.size()))
110 !MooseUtils::absoluteFuzzyEqual(_multi_sys_fp_relax_factors[i], 1.0))
112}
InputParameters emptyInputParameters()
Executioners are objects that do the actual work of solving your problem.
Definition Executioner.h:37
unsigned int solverSysNum(const SolverSystemName &solver_sys_name) const override
const std::vector< LinearSystemName > & getLinearSystemNames() const
const std::vector< NonlinearSystemName > & getNonlinearSystemNames() const
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
bool isParamSetByUser(const std::string &name) const
Method returns true if the parameter was set by the user.
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.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
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:457
const InputParameters & _pars
The object's parameters.
Definition MooseBase.h:384
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition MooseBase.h:199
const bool _using_multi_sys_fp_iterations
Whether we are using fixed point iterations for multi-system.
unsigned int _num_nl_systems
Number of nonlinear systems.
std::vector< Real > _multi_sys_fp_relax_factors
Per-system relaxation factors for multi-system fixed point iterations (expanded to match the number/o...
void setupMultiSystemFixedPointRelaxationFactors()
Initializes/expands the multi-system fixed point relaxation factors.
std::vector< bool > _perform_multi_sys_fp_relaxation
Whether to perform relaxation for each solve system, indexed over solve system.
MultiSystemSolveObject(Executioner &ex)
static InputParameters validParams()
std::vector< SolverSystem * > _systems
Vector of pointers to the systems.
FEProblemBase & _problem
Reference to FEProblem.
Definition SolveObject.h:47
std::string stringify(const T &t)
conversion to string
Definition Conversion.h:64