LCOV - code coverage report
Current view: top level - src/postprocessors - ScalarL2Error.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 18 19 94.7 %
Date: 2026-05-29 20:35:17 Functions: 5 5 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 "ScalarL2Error.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "Function.h"
      14             : #include "MooseVariableScalar.h"
      15             : #include "SubProblem.h"
      16             : 
      17             : registerMooseObject("MooseApp", ScalarL2Error);
      18             : 
      19             : InputParameters
      20        3305 : ScalarL2Error::validParams()
      21             : {
      22        3305 :   InputParameters params = GeneralPostprocessor::validParams();
      23        6610 :   params.addClassDescription("Compute L2 error of a scalar variable using analytic function.");
      24       13220 :   params.addRequiredParam<VariableName>("variable", "The name of the scalar variable");
      25        9915 :   params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
      26        3305 :   return params;
      27           0 : }
      28             : 
      29         122 : ScalarL2Error::ScalarL2Error(const InputParameters & parameters)
      30             :   : GeneralPostprocessor(parameters),
      31         122 :     _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
      32         366 :     _func(getFunction("function"))
      33             : {
      34         122 : }
      35             : 
      36             : void
      37        8847 : ScalarL2Error::initialize()
      38             : {
      39        8847 : }
      40             : 
      41             : void
      42        8847 : ScalarL2Error::execute()
      43             : {
      44        8847 : }
      45             : 
      46             : Real
      47        8847 : ScalarL2Error::getValue() const
      48             : {
      49        8847 :   _var.reinit();
      50        8847 :   Real diff = (_var.sln()[0] - _func.value(_t));
      51        8847 :   return std::sqrt(diff * diff);
      52             : }

Generated by: LCOV version 1.14