www.mooseframework.org
ElementW1pError.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "ElementW1pError.h"
16 #include "Function.h"
17 
18 template <>
21 {
23  params.addRangeCheckedParam<Real>("p", 2.0, "p>=1", "The exponent used in the norm.");
24  params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
25  return params;
26 }
27 
30  _p(getParam<Real>("p")),
31  _func(getFunction("function"))
32 {
33 }
34 
35 Real
37 {
38  return std::pow(ElementIntegralPostprocessor::getValue(), 1. / _p);
39 }
40 
41 Real
43 {
45  Real funcdiff = _u[_qp] - _func.value(_t, _q_point[_qp]);
46 
47  // Raise the absolute function value difference to the pth power
48  Real val = std::pow(std::abs(funcdiff), _p);
49 
50  // Add all of the absolute gradient component differences to the pth power
51  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
52  val += std::pow(std::abs(graddiff(i)), _p);
53 
54  return val;
55 }
RealVectorValue RealGradient
Definition: Assembly.h:43
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:43
virtual RealGradient gradient(Real t, const Point &p)
Function objects can optionally provide a gradient at a point.
Definition: Function.C:49
const MooseArray< Point > & _q_point
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
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.