LCOV - code coverage report
Current view: top level - src/utils - WeightedTransition.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #30301 (3b550b) with base 2ad78d Lines: 20 20 100.0 %
Date: 2025-07-30 13:02:48 Functions: 4 4 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 "WeightedTransition.h"
      11             : 
      12         226 : WeightedTransition::WeightedTransition(const Real & x_center, const Real & transition_width)
      13         226 :   : SmoothTransition(x_center, transition_width)
      14             : {
      15         226 : }
      16             : 
      17             : Real
      18        3386 : WeightedTransition::value(const Real & x, const Real & f1, const Real & f2) const
      19             : {
      20        3386 :   if (x <= _x1)
      21         732 :     return f1;
      22        2654 :   else if (x >= _x2)
      23        1424 :     return f2;
      24             :   else
      25             :   {
      26        1230 :     const Real w = weight(x);
      27        1230 :     return w * f1 + (1.0 - w) * f2;
      28             :   }
      29             : }
      30             : 
      31             : Real
      32        1270 : WeightedTransition::derivative(
      33             :     const Real & x, const Real & f1, const Real & f2, const Real & df1dx, const Real & df2dx) const
      34             : {
      35        1270 :   if (x <= _x1)
      36         460 :     return df1dx;
      37         810 :   else if (x >= _x2)
      38         450 :     return df2dx;
      39             :   else
      40             :   {
      41         360 :     const Real w = weight(x);
      42         360 :     const Real dwdx = -0.5 * std::sin(M_PI / (_x2 - _x1) * (x - _x1)) * M_PI / (_x2 - _x1);
      43         360 :     return w * df1dx + (1.0 - w) * df2dx + dwdx * (f1 - f2);
      44             :   }
      45             : }
      46             : 
      47             : Real
      48        1590 : WeightedTransition::weight(const Real & x) const
      49             : {
      50        1590 :   return 0.5 * (std::cos(M_PI / (_x2 - _x1) * (x - _x1)) + 1.0);
      51             : }

Generated by: LCOV version 1.14