LCOV - code coverage report
Current view: top level - src/postprocessors - NodalL2Error.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 24 25 96.0 %
Date: 2025-08-08 20:01:16 Functions: 7 7 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 "NodalL2Error.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("MooseApp", NodalL2Error);
      14             : 
      15             : InputParameters
      16       15337 : NodalL2Error::validParams()
      17             : {
      18       15337 :   InputParameters params = NodalVariablePostprocessor::validParams();
      19       15337 :   params.addClassDescription(
      20             :       "The L2-norm of the difference between a variable and a function computed at nodes.");
      21       15337 :   params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
      22             : 
      23       15337 :   return params;
      24           0 : }
      25             : 
      26         554 : NodalL2Error::NodalL2Error(const InputParameters & parameters)
      27         554 :   : NodalVariablePostprocessor(parameters), _func(getFunction("function"))
      28             : {
      29         554 : }
      30             : 
      31             : void
      32        3763 : NodalL2Error::initialize()
      33             : {
      34        3763 :   _integral_value = 0.;
      35        3763 : }
      36             : 
      37             : void
      38      372751 : NodalL2Error::execute()
      39             : {
      40      372751 :   Real diff = _u[0] - _func.value(_t, *_current_node);
      41      372751 :   _integral_value += diff * diff;
      42      372751 : }
      43             : 
      44             : Real
      45        3474 : NodalL2Error::getValue() const
      46             : {
      47        3474 :   return std::sqrt(_integral_value);
      48             : }
      49             : 
      50             : void
      51         289 : NodalL2Error::threadJoin(const UserObject & y)
      52             : {
      53         289 :   const auto & pps = static_cast<const NodalL2Error &>(y);
      54         289 :   _integral_value += pps._integral_value;
      55         289 : }
      56             : 
      57             : void
      58        3474 : NodalL2Error::finalize()
      59             : {
      60        3474 :   gatherSum(_integral_value);
      61        3474 : }

Generated by: LCOV version 1.14