ElementH1ErrorFunctionAux.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
6 //*
9
10 // MOOSE includes
12 #include "Function.h"
13
15
17
18 template <>
21 {
24  "Computes the H1 or W^{1,p} error between an exact function and a coupled variable.");
25
26  return params;
27 }
28
31 {
32 }
33
34 void
36 {
38
39  if (isNodal())
40  mooseError("ElementH1ErrorFunctionAux only makes sense as an Elemental AuxVariable.");
41
42  Real summed_value = 0;
43  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
44  {
45  Real val = computeValue(); // already raised to the p, see below.
46  summed_value += _JxW[_qp] * _coord[_qp] * val;
47  }
48
49  _var.setNodalValue(std::pow(summed_value, 1. / _p));
50 }
51
52 Real
54 {
56  Real funcdiff = _func.value(_t, _q_point[_qp]) - _coupled_var[_qp];
57
58  // Raise the absolute function value difference to the pth power
59  Real val = std::pow(std::abs(funcdiff), _p);
60
61  // Add all of the absolute gradient component differences to the pth power
62  for (unsigned int i = 0; i < LIBMESH_DIM; ++i)
64
65  return val;
66 }
MooseVariableFE< ComputeValueType > & _var
This is a regular kernel so we cast to a regular MooseVariable.
Definition: AuxKernel.h:167
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)
Function objects can optionally provide a gradient at a point.
Definition: Function.C:44
const MooseArray< Real > & _coord
Definition: AuxKernel.h:200
A class for computing the element-wise H1 error (actually W^{1,p} error, if you set the value of p to...
A class for computing the element-wise L^2 error (actually L^p error, if you set the value of p to so...
registerMooseObject("MooseApp", ElementH1ErrorFunctionAux)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const VariableValue & _coupled_var
A reference to the variable to compute the norm of.
InputParameters validParams< ElementL2ErrorFunctionAux >()
void mooseError(Args &&... args) const
Definition: MooseObject.h:147
ElementH1ErrorFunctionAux(const InputParameters &parameters)
Class constructor.
const MooseArray< Real > & _JxW
Transformed Jacobian weights.
Definition: AuxKernel.h:199
virtual void compute() override
Overrides ElementLpNormAux since we want to raise to a power in computeValue() instead.
The gradient of the computed solution.
Real pow(Real x, int e)
Definition: MathUtils.C:211
virtual void precalculateValue()
This callback is used for AuxKernelTempls that need to perform a per-element calculation.
Definition: AuxKernel.h:154
Function & _func
Function representing the exact solution.
virtual Real computeValue() override
Computes the error at the current qp.
bool isNodal()
Nodal or elemental kernel?
Definition: AuxKernel.h:84
const QBase *const & _qrule