LCOV - code coverage report
Current view: top level - include/utils - SplineInterpolation.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 1 1 100.0 %
Date: 2025-07-17 01:28:37 Functions: 2 2 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             : #pragma once
      11             : 
      12             : #include "SplineInterpolationBase.h"
      13             : #include <string>
      14             : 
      15             : /**
      16             :  * This class interpolates tabulated functions with cubic splines
      17             :  *
      18             :  * Adopted from Numerical Recipes in C (section 3.3).
      19             :  */
      20             : class SplineInterpolation : public SplineInterpolationBase
      21             : {
      22             : public:
      23             :   SplineInterpolation();
      24             :   /**
      25             :    * Construct the object
      26             :    * @param x Tabulated function (x-positions)
      27             :    * @param y Tabulated function (y-positions)
      28             :    * @param yp1 First derivative of the interpolating function at point 1
      29             :    * @param ypn First derivative of the interpolating function at point n
      30             :    *
      31             :    * If yp1, ypn are not specified or greater or equal that _deriv_bound, we use natural spline
      32             :    */
      33             :   SplineInterpolation(const std::vector<Real> & x,
      34             :                       const std::vector<Real> & y,
      35             :                       Real yp1 = _deriv_bound,
      36             :                       Real ypn = _deriv_bound);
      37             : 
      38         548 :   virtual ~SplineInterpolation() = default;
      39             : 
      40             :   /**
      41             :    * Set the x-, y- values and first derivatives
      42             :    */
      43             :   void setData(const std::vector<Real> & x,
      44             :                const std::vector<Real> & y,
      45             :                Real yp1 = _deriv_bound,
      46             :                Real ypn = _deriv_bound);
      47             : 
      48             :   void errorCheck();
      49             : 
      50             :   /**
      51             :    * This function will take an independent variable input and will return the dependent variable
      52             :    * based on the generated fit
      53             :    */
      54             :   Real sample(Real x) const;
      55             :   ADReal sample(const ADReal & x) const;
      56             : 
      57             :   Real sampleDerivative(Real x) const;
      58             : 
      59             :   Real sample2ndDerivative(Real x) const;
      60             : 
      61             :   /**
      62             :    * This function returns the size of the array holding the points, i.e. the number of sample
      63             :    * points
      64             :    */
      65             :   unsigned int getSampleSize();
      66             : 
      67             :   Real domain(int i) const;
      68             :   Real range(int i) const;
      69             : 
      70             : protected:
      71             :   std::vector<Real> _x;
      72             :   std::vector<Real> _y;
      73             :   /// boundary conditions
      74             :   Real _yp1, _ypn;
      75             :   /// Second derivatives
      76             :   std::vector<Real> _y2;
      77             : 
      78             :   void solve();
      79             : 
      80             :   static int _file_number;
      81             : };

Generated by: LCOV version 1.14