www.mooseframework.org
ElementW1pError.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 "ElementW1pError.h"
11 #include "Function.h"
12 
14 
15 template <>
18 {
20  params.addRangeCheckedParam<Real>("p", 2.0, "p>=1", "The exponent used in the norm.");
21  params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
22  return params;
23 }
24 
27  _p(getParam<Real>("p")),
28  _func(getFunction("function"))
29 {
30 }
31 
32 Real
34 {
36 }
37 
38 Real
40 {
41  RealGradient graddiff = _grad_u[_qp] - _func.gradient(_t, _q_point[_qp]);
42  Real funcdiff = _u[_qp] - _func.value(_t, _q_point[_qp]);
43 
44  // Raise the absolute function value difference to the pth power
45  Real val = std::pow(std::abs(funcdiff), _p);
46 
47  // Add all of the absolute gradient component differences to the pth power
48  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
49  val += std::pow(std::abs(graddiff(i)), _p);
50 
51  return val;
52 }
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
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
virtual RealGradient gradient(Real t, const Point &p)
Function objects can optionally provide a gradient at a point.
Definition: Function.C:44
const MooseArray< Point > & _q_point
registerMooseObject("MooseApp", ElementW1pError)
This postprocessor computes a volume integral of the specified variable.
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VariableGradient & _grad_u
Holds the solution gradient at the current quadrature points.
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...
ElementW1pError(const InputParameters &parameters)
Function & _func
Real pow(Real x, int e)
Definition: MathUtils.C:211
const VariableValue & _u
Holds the solution at current quadrature points.
InputParameters validParams< ElementW1pError >()
InputParameters validParams< ElementIntegralVariablePostprocessor >()
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
virtual Real computeQpIntegral() override
virtual Real getValue() override
This will get called to actually grab the final value the postprocessor has calculated.
This postprocessor computes the Sobolev norm W^{1,p} of the difference between the computed solution ...