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 "PiecewiseTabularBase.h" 11 : #include "JSONFileReader.h" 12 : 13 : InputParameters 14 78957 : PiecewiseTabularBase::validParams() 15 : { 16 78957 : InputParameters params = PiecewiseBase::validParams(); 17 78957 : params += PiecewiseTabularInterface::validParams(); 18 : 19 236871 : params.addParam<Real>("scale_factor", 1.0, "Scale factor to be applied to the output values"); 20 236871 : params.declareControllable("scale_factor"); 21 : 22 78957 : return params; 23 0 : } 24 : 25 2095 : PiecewiseTabularBase::PiecewiseTabularBase(const InputParameters & parameters) 26 : : PiecewiseBase(parameters), 27 2095 : PiecewiseTabularInterface(*this, _raw_x, _raw_y), 28 4170 : _scale_factor(getParam<Real>("scale_factor")) 29 : { 30 : // load the data 31 6225 : if (isParamValid("data_file")) 32 270 : buildFromFile(_communicator); 33 8851 : else if (isParamValid("x") && isParamValid("y")) 34 1718 : buildFromXandY(); 35 261 : else if (isParamValid("xy_data")) 36 69 : buildFromXY(); 37 54 : else if (!isParamValid("json_uo")) 38 4 : mooseError("Unknown X-Y data source. Are you missing a parameter? Did you misspell one?"); 39 : // JSON data is not available at construction as we rely on a user object 40 2023 : } 41 : 42 : void 43 1945 : PiecewiseTabularBase::initialSetup() 44 : { 45 : // For JSON UO input, we need to wait for initialSetup to load the data 46 5835 : if (!isParamValid("json_uo")) 47 1931 : return; 48 : else 49 42 : buildFromJSON(getUserObject<JSONFileReader>("json_uo")); 50 : }