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 "PiecewiseBase.h" 13 : #include "LinearInterpolation.h" 14 : 15 : /** 16 : * Function base which provides a piecewise approximation to a provided (x,y) point data set via 17 : * input parameter specifications. Derived classes, which control the order (constant, linear) of 18 : * the approximation and how the (x,y) data set is generated, should be used directly. 19 : */ 20 : class PiecewiseTabularBase : public PiecewiseBase 21 : { 22 : public: 23 : static InputParameters validParams(); 24 : 25 : PiecewiseTabularBase(const InputParameters & parameters); 26 : 27 : /// Needed to load data from user objects that are not available at construction 28 : void initialSetup() override; 29 : 30 : protected: 31 : /// function value scale factor 32 : const Real & _scale_factor; 33 : 34 : ///@{ if _has_axis is true point component to use as function argument, otherwise use t 35 : int _axis; 36 : const bool _has_axis; 37 : ///@} 38 : 39 : /// Returns whether the raw data has been loaded already 40 4440 : bool isRawDataLoaded() const { return _raw_data_loaded; }; 41 : 42 : private: 43 : /// Reads data from supplied CSV file. 44 : void buildFromFile(); 45 : 46 : /// Reads data from supplied JSON reader. 47 : void buildFromJSON(); 48 : 49 : /// Builds data from 'x' and 'y' parameters. 50 : void buildFromXandY(); 51 : 52 : /// Builds data from 'xy_data' parameter. 53 : void buildFromXY(); 54 : 55 : /// Boolean to keep track of whether the data has been loaded 56 : bool _raw_data_loaded; 57 : };