LCOV - code coverage report
Current view: top level - src/postprocessors - ElementW1pError.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 19 20 95.0 %
Date: 2026-05-29 20:35:17 Functions: 4 4 100.0 %
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 "ElementW1pError.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", ElementW1pError);
      14             : 
      15             : InputParameters
      16        6957 : ElementW1pError::validParams()
      17             : {
      18        6957 :   InputParameters params = ElementIntegralVariablePostprocessor::validParams();
      19       41742 :   params.addRangeCheckedParam<Real>("p", 2.0, "p>=1", "The exponent used in the norm.");
      20       27828 :   params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
      21        6957 :   params.addClassDescription("Computes the W1p norm of the difference between a variable and an "
      22             :                              "analytic solution, as a function");
      23        6957 :   return params;
      24           0 : }
      25             : 
      26         434 : ElementW1pError::ElementW1pError(const InputParameters & parameters)
      27             :   : ElementIntegralVariablePostprocessor(parameters),
      28         434 :     _p(getParam<Real>("p")),
      29        1302 :     _func(getFunction("function"))
      30             : {
      31         434 : }
      32             : 
      33             : Real
      34         588 : ElementW1pError::getValue() const
      35             : {
      36         588 :   return std::pow(ElementIntegralPostprocessor::getValue(), 1. / _p);
      37             : }
      38             : 
      39             : Real
      40     1389743 : ElementW1pError::computeQpIntegral()
      41             : {
      42     1389743 :   RealGradient graddiff = _grad_u[_qp] - _func.gradient(_t, _q_point[_qp]);
      43     1389743 :   Real funcdiff = _u[_qp] - _func.value(_t, _q_point[_qp]);
      44             : 
      45             :   // Raise the absolute function value difference to the pth power
      46     1389743 :   Real val = std::pow(std::abs(funcdiff), _p);
      47             : 
      48             :   // Add all of the absolute gradient component differences to the pth power
      49     5558972 :   for (const auto i : make_range(Moose::dim))
      50     4169229 :     val += std::pow(std::abs(graddiff(i)), _p);
      51             : 
      52     1389743 :   return val;
      53             : }

Generated by: LCOV version 1.14