https://mooseframework.inl.gov
ElementL2FunctorError.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 "ElementL2FunctorError.h"
11 #include "MooseFunctor.h"
12 #include "metaphysicl/raw_type.h"
13 
16 
17 template <bool is_ad>
20 {
22  params.addRequiredParam<MooseFunctorName>("approximate",
23  "The approximate functor. This functor has to be an "
24  "ADFunctor, like a variable or an ADFunction");
25  params.addRequiredParam<MooseFunctorName>("exact", "The analytic solution to compare against");
26  params.addClassDescription(
27  "Computes L2 error between an 'approximate' functor and an 'exact' functor");
28  return params;
29 }
30 
31 template <bool is_ad>
33  : ElementIntegralPostprocessor(parameters),
34  _approx(getFunctor<ADReal>("approximate")),
35  _exact(getFunctor<GenericReal<is_ad>>("exact"))
36 {
37 }
38 
39 template <bool is_ad>
40 Real
42 {
44 }
45 
46 template <bool is_ad>
47 Real
49 {
50  Moose::ElemQpArg elem_qp = {_current_elem, _qp, _qrule, _q_point[_qp]};
51  Real diff = MetaPhysicL::raw_value(_approx(elem_qp, determineState())) -
52  MetaPhysicL::raw_value(_exact(elem_qp, determineState()));
53  return diff * diff;
54 }
55 
This postprocessor computes a volume integral of the specified variable.
Moose::GenericType< Real, is_ad > GenericReal
Definition: MooseTypes.h:648
static InputParameters validParams()
registerMooseObject("MooseApp", ElementL2FunctorError)
virtual Real computeQpIntegral() override
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
auto raw_value(const Eigen::Map< T > &in)
Definition: EigenADReal.h:73
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
DualNumber< Real, DNDerivativeType, true > ADReal
Definition: ADRealForward.h:47
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...
Argument for requesting functor evaluation at a quadrature point location in an element.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Computes L2 error between an &#39;approximate&#39; functor and an &#39;exact&#39; functor.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
ElementL2FunctorErrorTempl(const InputParameters &parameters)
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...