https://mooseframework.inl.gov
SolutionContainer.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 "SolutionContainer.h"
11 #include "NonlinearSystemBase.h"
12 
13 registerMooseObject("StochasticToolsApp", SolutionContainer);
14 
17 {
19  params.addClassDescription(
20  "Class responsible for collecting distributed solution vectors into a container. We append "
21  "a new distributed solution vector (containing all variables) at every execution.");
22  MooseEnum system_type("nonlinear aux", "nonlinear");
23  params.addParam<MooseEnum>(
24  "system", system_type, "The system whose solution should be collected.");
25 
26  return params;
27 }
28 
30  : SnapshotContainerBase(parameters), _system_type(getParam<MooseEnum>("system"))
31 {
32  if (isParamSetByUser("nonlinear_system_name") && _system_type == "aux")
33  paramError("nonlinear_system_name",
34  "This should not be set when 'system_type' is 'aux'. This parameter is only "
35  "applicable to nonlinear systems.");
36 }
37 
38 std::unique_ptr<NumericVector<Number>>
40 {
41  std::unique_ptr<NumericVector<Number>> cloned_solution;
42 
43  // Clone the current solution
44  if (_system_type == "nonlinear")
45  cloned_solution =
47  else
48  cloned_solution = _fe_problem.systemBaseAuxiliary().solution().clone();
49 
50  return cloned_solution;
51 }
registerMooseObject("StochasticToolsApp", SolutionContainer)
static InputParameters validParams()
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
NumericVector< Number > & solution()
const MooseEnum _system_type
Enum to switch between collecting the solution vectors of auxiliary and nonlinear systems...
virtual std::unique_ptr< NumericVector< Number > > clone() const =0
static InputParameters validParams()
Base class for storing and managing numerical data like solutions, residuals, and Jacobians...
virtual const SystemBase & systemBaseAuxiliary() const override
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
void paramError(const std::string &param, Args... args) const
SolutionContainer(const InputParameters &parameters)
bool isParamSetByUser(const std::string &nm) const
FEProblemBase & _fe_problem
virtual std::unique_ptr< NumericVector< Number > > collectSnapshot() override
Clone the current snapshot vector.
void addClassDescription(const std::string &doc_string)
This class is responsible for collecting solution vectors in one place.
const unsigned int _nonlinear_system_number
The nonlinear system&#39;s number whose solution shall be collected.