LCOV - code coverage report
Current view: top level - src/postprocessors - ElementL2FunctorError.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 17 18 94.4 %
Date: 2025-08-08 20:01:16 Functions: 5 8 62.5 %
Legend: Lines: hit not hit

          Line data    Source code
       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       31068 : ElementL2FunctorErrorTempl<is_ad>::validParams()
      20             : {
      21       31068 :   InputParameters params = ElementIntegralPostprocessor::validParams();
      22       31068 :   params.addRequiredParam<MooseFunctorName>("approximate",
      23             :                                             "The approximate functor. This functor has to be an "
      24             :                                             "ADFunctor, like a variable or an ADFunction");
      25       31068 :   params.addRequiredParam<MooseFunctorName>("exact", "The analytic solution to compare against");
      26       31068 :   params.addClassDescription(
      27             :       "Computes L2 error between an 'approximate' functor and an 'exact' functor");
      28       31068 :   return params;
      29           0 : }
      30             : 
      31             : template <bool is_ad>
      32        1272 : ElementL2FunctorErrorTempl<is_ad>::ElementL2FunctorErrorTempl(const InputParameters & parameters)
      33             :   : ElementIntegralPostprocessor(parameters),
      34        1272 :     _approx(getFunctor<ADReal>("approximate")),
      35        2544 :     _exact(getFunctor<GenericReal<is_ad>>("exact"))
      36             : {
      37        1272 : }
      38             : 
      39             : template <bool is_ad>
      40             : Real
      41        1264 : ElementL2FunctorErrorTempl<is_ad>::getValue() const
      42             : {
      43        1264 :   return std::sqrt(ElementIntegralPostprocessor::getValue());
      44             : }
      45             : 
      46             : template <bool is_ad>
      47             : Real
      48      268950 : ElementL2FunctorErrorTempl<is_ad>::computeQpIntegral()
      49             : {
      50      268950 :   Moose::ElemQpArg elem_qp = {_current_elem, _qp, _qrule, _q_point[_qp]};
      51      268950 :   Real diff = MetaPhysicL::raw_value(_approx(elem_qp, determineState())) -
      52      268950 :               MetaPhysicL::raw_value(_exact(elem_qp, determineState()));
      53      268950 :   return diff * diff;
      54             : }
      55             : 
      56             : template class ElementL2FunctorErrorTempl<false>;
      57             : template class ElementL2FunctorErrorTempl<true>;

Generated by: LCOV version 1.14