LCOV - code coverage report
Current view: top level - src/ics - FunctionNodalAverageIC.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 14 15 93.3 %
Date: 2026-05-29 20:41:18 Functions: 3 3 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 "FunctionNodalAverageIC.h"
      11             : #include "Function.h"
      12             : 
      13             : registerMooseObject("ThermalHydraulicsApp", FunctionNodalAverageIC);
      14             : 
      15             : InputParameters
      16        1305 : FunctionNodalAverageIC::validParams()
      17             : {
      18        1305 :   InputParameters params = InitialCondition::validParams();
      19             : 
      20        1305 :   params.addClassDescription(
      21             :       "Initial conditions for an elemental variable from a function using nodal average.");
      22             : 
      23        2610 :   params.addRequiredParam<FunctionName>("function", "The initial condition function.");
      24             : 
      25        1305 :   return params;
      26           0 : }
      27             : 
      28         693 : FunctionNodalAverageIC::FunctionNodalAverageIC(const InputParameters & parameters)
      29         693 :   : InitialCondition(parameters), _func(getFunction("function"))
      30             : {
      31         693 : }
      32             : 
      33             : Real
      34       21996 : FunctionNodalAverageIC::value(const Point & /*p*/)
      35             : {
      36       21996 :   const unsigned int n_nodes = _current_elem->n_nodes();
      37             : 
      38             :   Real sum = 0.0;
      39       65988 :   for (unsigned int i = 0; i < n_nodes; i++)
      40             :   {
      41       43992 :     const Node & node = _current_elem->node_ref(i);
      42       43992 :     sum += _func.value(_t, node);
      43             :   }
      44             : 
      45       21996 :   return sum / n_nodes;
      46             : }

Generated by: LCOV version 1.14