https://mooseframework.inl.gov
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 
10 #include "MultiSystemSolveObject.h"
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  params.addParamNamesToGroup("system_names", "Multiple solver system");
23  return params;
24 }
25 
27 {
28  // Retrieve pointers to all the systems from the problem by default
29  const auto & nl_sys_names = _problem.getNonlinearSystemNames();
30  const auto & linear_sys_names = _problem.getLinearSystemNames();
31  if (!isParamValid("system_names"))
32  {
33  for (const auto & sys_name : nl_sys_names)
34  _systems.push_back(&_problem.getSolverSystem(_problem.solverSysNum(sys_name)));
35  for (const auto & sys_name : linear_sys_names)
36  _systems.push_back(&_problem.getSolverSystem(_problem.solverSysNum(sys_name)));
37  _num_nl_systems = nl_sys_names.size();
38  }
39  else
40  {
41  _num_nl_systems = 0;
42  // Retrieve pointers to all the user-specified systems in the order that the user specified them
43  for (const auto & sys_name : getParam<std::vector<SolverSystemName>>("system_names"))
44  {
45  if (std::find(nl_sys_names.begin(), nl_sys_names.end(), sys_name) != nl_sys_names.end())
46  {
47  _systems.push_back(&_problem.getSolverSystem(_problem.solverSysNum(sys_name)));
49  }
50  else if (std::find(linear_sys_names.begin(), linear_sys_names.end(), sys_name) !=
51  linear_sys_names.end())
52  _systems.push_back(&_problem.getSolverSystem(_problem.solverSysNum(sys_name)));
53  else
54  paramError("system_names",
55  "System '" + sys_name +
56  "' was not found in the Problem. Did you forget to declare it in the "
57  "[Problem] block?");
58  }
59  }
60 }
static InputParameters validParams()
const std::vector< NonlinearSystemName > & getNonlinearSystemNames() const
FEProblemBase & _problem
Reference to FEProblem.
Definition: SolveObject.h:47
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters emptyInputParameters()
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
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 ...
const std::vector< LinearSystemName > & getLinearSystemNames() const
unsigned int solverSysNum(const SolverSystemName &solver_sys_name) const override
unsigned int _num_nl_systems
Number of nonlinear systems.
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
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...
MultiSystemSolveObject(Executioner &ex)
std::vector< SolverSystem * > _systems
Vector of pointers to the 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...