LCOV - code coverage report
Current view: top level - src/postprocessors - ScalarL2Error.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 18 19 94.7 %
Date: 2025-07-17 01:28:37 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       14539 : ScalarL2Error::validParams()
      21             : {
      22       14539 :   InputParameters params = GeneralPostprocessor::validParams();
      23       14539 :   params.addClassDescription("Compute L2 error of a scalar variable using analytic function.");
      24       14539 :   params.addRequiredParam<VariableName>("variable", "The name of the scalar variable");
      25       14539 :   params.addRequiredParam<FunctionName>("function", "The analytic solution to compare against");
      26       14539 :   return params;
      27           0 : }
      28             : 
      29         137 : ScalarL2Error::ScalarL2Error(const InputParameters & parameters)
      30             :   : GeneralPostprocessor(parameters),
      31         137 :     _var(_subproblem.getScalarVariable(_tid, getParam<VariableName>("variable"))),
      32         274 :     _func(getFunction("function"))
      33             : {
      34         137 : }
      35             : 
      36             : void
      37       10946 : ScalarL2Error::initialize()
      38             : {
      39       10946 : }
      40             : 
      41             : void
      42       10946 : ScalarL2Error::execute()
      43             : {
      44       10946 : }
      45             : 
      46             : Real
      47       10946 : ScalarL2Error::getValue() const
      48             : {
      49       10946 :   _var.reinit();
      50       10946 :   Real diff = (_var.sln()[0] - _func.value(_t));
      51       10946 :   return std::sqrt(diff * diff);
      52             : }

Generated by: LCOV version 1.14