LCOV - code coverage report
Current view: top level - src/functions - CosineHumpFunction.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 31 33 93.9 %
Date: 2025-07-30 13:02:48 Functions: 3 4 75.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 "CosineHumpFunction.h"
      11             : 
      12             : registerMooseObject("ThermalHydraulicsApp", CosineHumpFunction);
      13             : 
      14             : InputParameters
      15         177 : CosineHumpFunction::validParams()
      16             : {
      17         177 :   InputParameters params = Function::validParams();
      18             : 
      19         354 :   MooseEnum axis("x=0 y=1 z=2");
      20         354 :   params.addRequiredParam<MooseEnum>("axis", axis, "Coordinate axis on which the hump occurs");
      21         354 :   params.addRequiredParam<Real>("hump_center_position", "Hump center position on selected axis");
      22         354 :   params.addRequiredParam<Real>("hump_width", "Width of the hump");
      23         354 :   params.addRequiredParam<Real>("hump_begin_value", "Value before and after the hump");
      24         354 :   params.addRequiredParam<Real>("hump_center_value", "Value at the center of the hump");
      25             : 
      26         177 :   params.addClassDescription("Computes a cosine hump of a user-specified width and height");
      27             : 
      28         177 :   return params;
      29         177 : }
      30             : 
      31          92 : CosineHumpFunction::CosineHumpFunction(const InputParameters & parameters)
      32             :   : Function(parameters),
      33             : 
      34          92 :     _component(getParam<MooseEnum>("axis")),
      35         184 :     _hump_width(getParam<Real>("hump_width")),
      36         184 :     _hump_center_position(getParam<Real>("hump_center_position")),
      37             : 
      38         184 :     _hump_begin_value(getParam<Real>("hump_begin_value")),
      39         184 :     _hump_center_value(getParam<Real>("hump_center_value")),
      40             : 
      41          92 :     _cosine_amplitude(0.5 * (_hump_center_value - _hump_begin_value)),
      42          92 :     _hump_mid_value(0.5 * (_hump_center_value + _hump_begin_value)),
      43          92 :     _hump_left_end(_hump_center_position - 0.5 * _hump_width),
      44          92 :     _hump_right_end(_hump_center_position + 0.5 * _hump_width)
      45             : {
      46          92 : }
      47             : 
      48             : Real
      49        1670 : CosineHumpFunction::value(Real /*t*/, const Point & p) const
      50             : {
      51        1670 :   const Real x = p(_component);
      52             : 
      53        1670 :   if (x < _hump_left_end)
      54         532 :     return _hump_begin_value;
      55        1138 :   else if (x > _hump_right_end)
      56         494 :     return _hump_begin_value;
      57             :   else
      58         644 :     return _hump_mid_value -
      59         644 :            _cosine_amplitude *
      60         644 :                std::cos(2 * M_PI / _hump_width * (x - _hump_center_position + 0.5 * _hump_width));
      61             : }
      62             : 
      63             : RealVectorValue
      64           0 : CosineHumpFunction::gradient(Real /*t*/, const Point & /*p*/) const
      65             : {
      66           0 :   mooseError(name(), ": ", __PRETTY_FUNCTION__, " is not implemented.");
      67             : }

Generated by: LCOV version 1.14