https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
11#include "MooseFunctor.h"
12#include "metaphysicl/raw_type.h"
13
16
17template <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");
27 "Computes L2 error between an 'approximate' functor and an 'exact' functor");
28 return params;
29}
30
31template <bool is_ad>
33 : ElementIntegralPostprocessor(parameters),
34 _approx(getFunctor<ADReal>("approximate")),
35 _exact(getFunctor<GenericReal<is_ad>>("exact"))
36{
37}
38
39template <bool is_ad>
40Real
45
46template <bool is_ad>
47Real
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
DualNumber< Real, DNDerivativeType, true > ADReal
registerMooseObject("MooseApp", ElementL2FunctorError)
Moose::GenericType< Real, is_ad > GenericReal
Definition MooseTypes.h:698
This postprocessor computes a volume integral of the specified variable.
virtual Real getValue() const override
This will get called to actually grab the final value the postprocessor has calculated.
Computes L2 error between an 'approximate' functor and an 'exact' functor.
ElementL2FunctorErrorTempl(const InputParameters &parameters)
virtual Real computeQpIntegral() override
static InputParameters validParams()
virtual Real getValue() const 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.
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.
auto raw_value(const Eigen::Map< T > &in)
Argument for requesting functor evaluation at a quadrature point location in an element.