https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ElementW1pError.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 "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
33Real
38
39Real
41{
42 RealGradient graddiff = _grad_u[_qp] - _func.gradient(_t, _q_point[_qp]);
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}
registerMooseObject("MooseApp", ElementW1pError)
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
This postprocessor computes a volume integral of the specified variable.
const VariableGradient & _grad_u
Holds the solution gradient at the current quadrature points.
const VariableValue & _u
Holds the solution at current quadrature points.
const MooseArray< Point > & _q_point
This postprocessor computes the Sobolev norm W^{1,p} of the difference between the computed solution ...
virtual Real computeQpIntegral() override
ElementW1pError(const InputParameters &parameters)
const Function & _func
static InputParameters validParams()
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
virtual RealGradient gradient(Real t, const Point &p) const
Function objects can optionally provide a gradient at a point.
Definition Function.C:62
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.
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition Moose.h:165
MooseUnits pow(const MooseUnits &, int)
Definition Units.C:537