https://mooseframework.inl.gov
Loading...
Searching...
No Matches
NodalL2Error.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 "NodalL2Error.h"
11#include "Function.h"
12
14
17{
20 "The L2-norm of the difference between a variable and a function computed at nodes.");
21 params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
22
23 return params;
24}
25
27 : NodalVariablePostprocessor(parameters), _func(getFunction("function"))
28{
29}
30
31void
36
37void
39{
40 Real diff = _u[0] - _func.value(_t, *_current_node);
41 _integral_value += diff * diff;
42}
43
44Real
46{
47 return std::sqrt(_integral_value);
48}
49
50void
52{
53 const auto & pps = static_cast<const NodalL2Error &>(y);
55}
56
57void
registerMooseObject("MooseApp", NodalL2Error)
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
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.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual void execute() override
Execute method.
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
static InputParameters validParams()
virtual void threadJoin(const UserObject &y) override
Must override.
Real _integral_value
NodalL2Error(const InputParameters &parameters)
const Function & _func
const Node *const & _current_node
Reference to current node pointer.
This is a base class for other classes which compute post-processed values based on nodal solution va...
const VariableValue & _u
Holds the solution at current quadrature points.
static InputParameters validParams()
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
Base class for user-specific data.
Definition UserObject.h:20