www.mooseframework.org
Residual.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "Residual.h"
11 
12 #include "FEProblem.h"
13 #include "SubProblem.h"
14 #include "NonlinearSystem.h"
15 
16 registerMooseObject("MooseApp", Residual);
17 
18 template <>
21 {
22  MooseEnum residual_types("FINAL INITIAL_BEFORE_PRESET INITIAL_AFTER_PRESET", "FINAL");
23 
25  params.addParam<MooseEnum>("residual_type",
26  residual_types,
27  "Type of residual to be reported. Choices are: " +
28  residual_types.getRawNames());
29  return params;
30 }
31 
33  : GeneralPostprocessor(parameters), _residual_type(getParam<MooseEnum>("residual_type"))
34 {
35 }
36 
37 Real
39 {
40  Real residual = 0.0;
41  if (_residual_type == "FINAL")
43  else
44  {
45  FEProblemBase * fe_problem = dynamic_cast<FEProblemBase *>(&_subproblem);
46  if (!fe_problem)
47  mooseError("Dynamic cast to FEProblemBase failed in Residual Postprocessor");
48  if (_residual_type == "INITIAL_BEFORE_PRESET")
50  else if (_residual_type == "INITIAL_AFTER_PRESET")
52  else
53  mooseError("Invalid residual_type option in Residual Postprocessor: ", _residual_type);
54  }
55  return residual;
56 }
NonlinearSystemBase & getNonlinearSystemBase()
InputParameters validParams< Residual >()
Definition: Residual.C:20
virtual Real finalNonlinearResidual() const
Definition: SubProblem.C:564
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
registerMooseObject("MooseApp", Residual)
std::string getRawNames() const
Method for returning the raw name strings for this instance.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
SubProblem & _subproblem
Reference to the Subproblem for this user object.
Definition: UserObject.h:138
virtual Real getValue() override
This will return the final nonlinear residual.
Definition: Residual.C:38
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:31
Residual(const InputParameters &parameters)
Definition: Residual.C:32
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...
MooseEnum _residual_type
Definition: Residual.h:34