https://mooseframework.inl.gov
VariableResidual.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 "VariableResidual.h"
11 
12 // MOOSE includes
13 #include "MooseVariable.h"
14 #include "NonlinearSystemBase.h"
15 
16 // libMesh includes
17 #include "libmesh/enum_norm_type.h"
18 
20 
23 {
25  params.addRequiredParam<VariableName>("variable",
26  "The name of the variable to compute the residual for");
27 
28  params.addClassDescription(
29  "Computes the L2 norm of the residual of a single variable in the solution vector.");
30  return params;
31 }
32 
34  : GeneralPostprocessor(parameters),
35  _var(_fe_problem.getVariable(_tid,
36  getParam<VariableName>("variable"),
39 {
41  "VariableResidual is deprecated. Please use DiscreteVariableResidualNorm instead.");
42 }
43 
44 void
46 {
47  _var_residual = 0;
48 }
49 
50 void
52 {
55 }
56 
59 {
60  return _var_residual;
61 }
VarFieldType
Definition: MooseTypes.h:722
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
unsigned int number() const
Get variable number coming from libMesh.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
MooseVariableFEBase & _var
MOOSE variable we compute the residual for.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
Nonlinear system to be solved.
static InputParameters validParams()
static InputParameters validParams()
void mooseDeprecated(Args &&... args) const
Definition: MooseBase.h:310
VariableResidual(const InputParameters &parameters)
VarKindType
Framework-wide stuff.
Definition: MooseTypes.h:715
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:202
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
NonlinearSystemBase & getNonlinearSystemBase(const unsigned int sys_num)
SystemBase & _sys
Reference to the system object for this user object.
Definition: UserObject.h:215
unsigned int number() const
Gets the number of this system.
Definition: SystemBase.C:1149
virtual PostprocessorValue getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual NumericVector< Number > & RHS()=0
virtual void execute() override
Execute method.
FEProblemBase & _fe_problem
Reference to the FEProblemBase for this user object.
Definition: UserObject.h:211
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
Real _var_residual
The residual of the variable.
registerMooseObject("MooseApp", VariableResidual)
virtual libMesh::System & system() override
Get the reference to the libMesh system.