https://mooseframework.inl.gov
Loading...
Searching...
No Matches
src
postprocessors
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
14
registerMooseObject
(
"MooseApp"
,
ElementL2FunctorError
);
15
registerMooseObject
(
"MooseApp"
,
ADElementL2FunctorError
);
16
17
template
<
bool
is_ad>
18
InputParameters
19
ElementL2FunctorErrorTempl<is_ad>::validParams
()
20
{
21
InputParameters
params =
ElementIntegralPostprocessor::validParams
();
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>
32
ElementL2FunctorErrorTempl<is_ad>::ElementL2FunctorErrorTempl
(
const
InputParameters
& parameters)
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
41
ElementL2FunctorErrorTempl<is_ad>::getValue
()
const
42
{
43
return
std::sqrt(
ElementIntegralPostprocessor::getValue
());
44
}
45
46
template
<
bool
is_ad>
47
Real
48
ElementL2FunctorErrorTempl<is_ad>::computeQpIntegral
()
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
56
template
class
ElementL2FunctorErrorTempl<false>
;
57
template
class
ElementL2FunctorErrorTempl<true>
;
ADReal
DualNumber< Real, DNDerivativeType, true > ADReal
Definition
ADRealForward.h:42
registerMooseObject
registerMooseObject("MooseApp", ElementL2FunctorError)
ElementL2FunctorError.h
MooseFunctor.h
GenericReal
Moose::GenericType< Real, is_ad > GenericReal
Definition
MooseTypes.h:698
ElementIntegralPostprocessor
This postprocessor computes a volume integral of the specified variable.
Definition
ElementIntegralPostprocessor.h:21
ElementIntegralPostprocessor::getValue
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition
ElementIntegralPostprocessor.C:39
ElementIntegralPostprocessor::validParams
static InputParameters validParams()
Definition
ElementIntegralPostprocessor.C:15
ElementL2FunctorErrorTempl
Computes L2 error between an 'approximate' functor and an 'exact' functor.
Definition
ElementL2FunctorError.h:19
ElementL2FunctorErrorTempl::ElementL2FunctorErrorTempl
ElementL2FunctorErrorTempl(const InputParameters ¶meters)
Definition
ElementL2FunctorError.C:32
ElementL2FunctorErrorTempl::computeQpIntegral
virtual Real computeQpIntegral() override
Definition
ElementL2FunctorError.C:48
ElementL2FunctorErrorTempl::validParams
static InputParameters validParams()
Definition
ElementL2FunctorError.C:19
ElementL2FunctorErrorTempl::getValue
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Definition
ElementL2FunctorError.C:41
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition
InputParameters.h:68
InputParameters::addRequiredParam
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...
Definition
InputParameters.h:1806
InputParameters::addClassDescription
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.
Definition
InputParameters.C:81
MetaPhysicL::raw_value
auto raw_value(const Eigen::Map< T > &in)
Definition
EigenADReal.h:100
Moose::ElemQpArg
Argument for requesting functor evaluation at a quadrature point location in an element.
Definition
MooseFunctorArguments.h:284
Generated on Fri Aug 21 2026 13:33:59 for https://mooseframework.inl.gov by
1.9.8