www.mooseframework.org
Residual.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "Residual.h"
16 
17 #include "FEProblem.h"
18 #include "SubProblem.h"
19 #include "NonlinearSystem.h"
20 
21 template <>
24 {
25  MooseEnum residual_types("FINAL INITIAL_BEFORE_PRESET INITIAL_AFTER_PRESET", "FINAL");
26 
28  params.addParam<MooseEnum>("residual_type",
29  residual_types,
30  "Type of residual to be reported. Choices are: " +
31  residual_types.getRawNames());
32  return params;
33 }
34 
36  : GeneralPostprocessor(parameters), _residual_type(getParam<MooseEnum>("residual_type"))
37 {
38 }
39 
40 Real
42 {
43  Real residual = 0.0;
44  if (_residual_type == "FINAL")
46  else
47  {
48  FEProblemBase * fe_problem = dynamic_cast<FEProblemBase *>(&_subproblem);
49  if (!fe_problem)
50  mooseError("Dynamic cast to FEProblemBase failed in Residual Postprocessor");
51  if (_residual_type == "INITIAL_BEFORE_PRESET")
53  else if (_residual_type == "INITIAL_AFTER_PRESET")
55  else
56  mooseError("Invalid residual_type option in Residual Postprocessor: ", _residual_type);
57  }
58  return residual;
59 }
NonlinearSystemBase & getNonlinearSystemBase()
InputParameters validParams< Residual >()
Definition: Residual.C:23
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:146
virtual Real getValue() override
This will return the final nonlinear residual.
Definition: Residual.C:41
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
std::string getRawNames() const
Method for returning the raw name strings for this instance.
Residual(const InputParameters &parameters)
Definition: Residual.C:35
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
virtual Real finalNonlinearResidual()
Definition: SubProblem.C:293
MooseEnum _residual_type
Definition: Residual.h:40