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 
19 template <>
22 {
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  Point p;
51  Real diff = (_var.sln()[0] - _func.value(_t, p));
52  return std::sqrt(diff * diff);
53 }
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: ScalarL2Error.C:37
virtual Real value(Real t, const Point &p)
Override this to evaluate the scalar function at point (t,x,y,z), by default this returns zero...
Definition: Function.C:38
VariableValue & sln()
registerMooseObject("MooseApp", ScalarL2Error)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Function & _func
Definition: ScalarL2Error.h:42
InputParameters validParams< GeneralPostprocessor >()
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...
virtual Real getValue() override
Get the L2 Error.
Definition: ScalarL2Error.C:47
InputParameters validParams< ScalarL2Error >()
Definition: ScalarL2Error.C:21
MooseVariableScalar & _var
Definition: ScalarL2Error.h:41
ScalarL2Error(const InputParameters &parameters)
Definition: ScalarL2Error.C:29
Postprocessor for computing the error in a scalar value relative to a known Function&#39;s value...
Definition: ScalarL2Error.h:27