LCOV - code coverage report
Current view: top level - src/postprocessors - ElementL2FunctorError.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 17 18 94.4 %
Date: 2025-07-17 01:28:37 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       30716 : ElementL2FunctorErrorTempl<is_ad>::validParams()
      20             : {
      21       30716 :   InputParameters params = ElementIntegralPostprocessor::validParams();
      22       30716 :   params.addRequiredParam<MooseFunctorName>("approximate",
      23             :                                             "The approximate functor. This functor has to be an "
      24             :                                             "ADFunctor, like a variable or an ADFunction");
      25       30716 :   params.addRequiredParam<MooseFunctorName>("exact", "The analytic solution to compare against");
      26       30716 :   params.addClassDescription(
      27             :       "Computes L2 error between an 'approximate' functor and an 'exact' functor");
      28       30716 :   return params;
      29           0 : }
      30             : 
      31             : template <bool is_ad>
      32        1096 : ElementL2FunctorErrorTempl<is_ad>::ElementL2FunctorErrorTempl(const InputParameters & parameters)
      33             :   : ElementIntegralPostprocessor(parameters),
      34        1096 :     _approx(getFunctor<ADReal>("approximate")),
      35        2192 :     _exact(getFunctor<GenericReal<is_ad>>("exact"))
      36             : {
      37        1096 : }
      38             : 
      39             : template <bool is_ad>
      40             : Real
      41        1082 : ElementL2FunctorErrorTempl<is_ad>::getValue() const
      42             : {
      43        1082 :   return std::sqrt(ElementIntegralPostprocessor::getValue());
      44             : }
      45             : 
      46             : template <bool is_ad>
      47             : Real
      48      258500 : ElementL2FunctorErrorTempl<is_ad>::computeQpIntegral()
      49             : {
      50      258500 :   Moose::ElemQpArg elem_qp = {_current_elem, _qp, _qrule, _q_point[_qp]};
      51      258500 :   Real diff = MetaPhysicL::raw_value(_approx(elem_qp, determineState())) -
      52      258500 :               MetaPhysicL::raw_value(_exact(elem_qp, determineState()));
      53      258500 :   return diff * diff;
      54             : }
      55             : 
      56             : template class ElementL2FunctorErrorTempl<false>;
      57             : template class ElementL2FunctorErrorTempl<true>;

Generated by: LCOV version 1.14