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 
17 {
19  params.addRangeCheckedParam<Real>("p", 2.0, "p>=1", "The exponent used in the norm.");
20  params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
21  params.addClassDescription("Computes the W1p norm of the difference between a variable and an "
22  "analytic solution, as a function");
23  return params;
24 }
25 
28  _p(getParam<Real>("p")),
29  _func(getFunction("function"))
30 {
31 }
32 
33 Real
35 {
37 }
38 
39 Real
41 {
43  Real funcdiff = _u[_qp] - _func.value(_t, _q_point[_qp]);
44 
45  // Raise the absolute function value difference to the pth power
46  Real val = std::pow(std::abs(funcdiff), _p);
47 
48  // Add all of the absolute gradient component differences to the pth power
49  for (const auto i : make_range(Moose::dim))
50  val += std::pow(std::abs(graddiff(i)), _p);
51 
52  return val;
53 }
const MooseArray< Point > & _q_point
registerMooseObject("MooseApp", ElementW1pError)
This postprocessor computes a volume integral of the specified variable.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:148
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)
ADRealEigenVector< T, D, asd > abs(const ADRealEigenVector< T, D, asd > &)
static InputParameters validParams()
const VariableValue & _u
Holds the solution at current quadrature points.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Function & _func
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
IntRange< T > make_range(T beg, T end)
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition: Function.C:73
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...
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 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:41
MooseUnits pow(const MooseUnits &, int)
Definition: Units.C:537
This postprocessor computes the Sobolev norm W^{1,p} of the difference between the computed solution ...