www.mooseframework.org
ScalarL2Error.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 "ScalarL2Error.h"
11 
12 // MOOSE includes
13 #include "Function.h"
14 #include "MooseVariableScalar.h"
15 #include "SubProblem.h"
16 
18 
21 {
23  params.addClassDescription("Compute L2 error of a scalar variable using analytic function.");
24  params.addRequiredParam<VariableName>("variable", "The name of the scalar variable");
25  params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
26  return params;
27 }
28 
30  : GeneralPostprocessor(parameters),
31  _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
32  _func(getFunction("function"))
33 {
34 }
35 
36 void
38 {
39 }
40 
41 void
43 {
44 }
45 
46 Real
48 {
49  _var.reinit();
50  Real diff = (_var.sln()[0] - _func.value(_t));
51  return std::sqrt(diff * diff);
52 }
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: ScalarL2Error.C:37
static InputParameters validParams()
Definition: ScalarL2Error.C:20
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
registerMooseObject("MooseApp", ScalarL2Error)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
ADRealEigenVector< T, D, asd > sqrt(const ADRealEigenVector< T, D, asd > &)
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
virtual void execute() override
Execute method.
Definition: ScalarL2Error.C:42
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...
static InputParameters validParams()
const Function & _func
Definition: ScalarL2Error.h:40
virtual Real getValue() const override
Get the L2 Error.
Definition: ScalarL2Error.C:47
MooseVariableScalar & _var
Definition: ScalarL2Error.h:39
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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...
virtual Real value(Real t, const Point &p) const
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:41
ScalarL2Error(const InputParameters &parameters)
Definition: ScalarL2Error.C:29
const VariableValue & sln() const
Postprocessor for computing the error in a scalar value relative to a known Function&#39;s value...
Definition: ScalarL2Error.h:23