https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ScalarL2Error.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 "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
36void
40
41void
45
46Real
48{
49 _var.reinit();
50 Real diff = (_var.sln()[0] - _func.value(_t));
51 return std::sqrt(diff * diff);
52}
registerMooseObject("MooseApp", ScalarL2Error)
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:30
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
static InputParameters validParams()
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
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...
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.
const VariableValue & sln() const
void reinit(bool reinit_for_derivative_reordering=false)
Fill out the VariableValue arrays from the system solution vector.
Postprocessor for computing the error in a scalar value relative to a known Function's value.
MooseVariableScalar & _var
virtual Real getValue() const override
Get the L2 Error.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
virtual void execute() override
Execute method.
static InputParameters validParams()
ScalarL2Error(const InputParameters &parameters)
const Function & _func