www.mooseframework.org
ScalarL2Error.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 "ScalarL2Error.h"
16 
17 // MOOSE includes
18 #include "Function.h"
19 #include "MooseVariableScalar.h"
20 #include "SubProblem.h"
21 
22 template <>
25 {
27  params.addRequiredParam<VariableName>("variable", "The name of the scalar variable");
28  params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
29  return params;
30 }
31 
33  : GeneralPostprocessor(parameters),
34  _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
35  _func(getFunction("function"))
36 {
37 }
38 
39 void
41 {
42 }
43 
44 void
46 {
47 }
48 
49 Real
51 {
52  _var.reinit();
53  Point p;
54  Real diff = (_var.sln()[0] - _func.value(_t, p));
55  return std::sqrt(diff * diff);
56 }
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: ScalarL2Error.C:40
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:43
VariableValue & sln()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Function & _func
Definition: ScalarL2Error.h:48
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:45
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:50
InputParameters validParams< ScalarL2Error >()
Definition: ScalarL2Error.C:24
MooseVariableScalar & _var
Definition: ScalarL2Error.h:47
ScalarL2Error(const InputParameters &parameters)
Definition: ScalarL2Error.C:32