https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
14
17{
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
38std::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)
virtual const SystemBase & systemBaseAuxiliary() const override
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
bool isParamSetByUser(const std::string &name) const
Base class for storing and managing numerical data like solutions, residuals, and Jacobians.
static InputParameters validParams()
const unsigned int _nonlinear_system_number
The nonlinear system's number whose solution shall be collected.
This class is responsible for collecting solution vectors in one place.
static InputParameters validParams()
const MooseEnum _system_type
Enum to switch between collecting the solution vectors of auxiliary and nonlinear systems.
SolutionContainer(const InputParameters &parameters)
virtual std::unique_ptr< NumericVector< Number > > collectSnapshot() override
Clone the current snapshot vector.
NumericVector< Number > & solution()
FEProblemBase & _fe_problem
virtual std::unique_ptr< NumericVector< T > > clone() const=0