https://mooseframework.inl.gov
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 {
19  params.addClassDescription(
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 
31 void
33 {
34  _integral_value = 0.;
35 }
36 
37 void
39 {
40  Real diff = _u[0] - _func.value(_t, *_current_node);
41  _integral_value += diff * diff;
42 }
43 
44 Real
46 {
47  return std::sqrt(_integral_value);
48 }
49 
50 void
52 {
53  const auto & pps = static_cast<const NodalL2Error &>(y);
54  _integral_value += pps._integral_value;
55 }
56 
57 void
59 {
61 }
void gatherSum(T &value)
Gather the parallel sum of the variable passed in.
virtual void finalize() override
This is called after execute() and after threadJoin()! This is probably where you want to do MPI comm...
Definition: NodalL2Error.C:58
This is a base class for other classes which compute post-processed values based on nodal solution va...
Real _integral_value
Definition: NodalL2Error.h:31
const Node *const & _current_node
Reference to current node pointer.
NodalL2Error(const InputParameters &parameters)
Definition: NodalL2Error.C:26
const VariableValue & _u
Holds the solution at current quadrature points.
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...
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition: NodalL2Error.C:45
static InputParameters validParams()
Definition: NodalL2Error.C:16
virtual void threadJoin(const UserObject &y) override
Must override.
Definition: NodalL2Error.C:51
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
registerMooseObject("MooseApp", NodalL2Error)
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:30
const Function & _func
Definition: NodalL2Error.h:32
virtual void execute() override
Execute method.
Definition: NodalL2Error.C:38
static InputParameters validParams()
Base class for user-specific data.
Definition: UserObject.h:19
virtual void initialize() override
Called before execute() is ever called so that data can be cleared.
Definition: NodalL2Error.C:32