https://mooseframework.inl.gov
PiecewiseTabularBase.C
Go to the documentation of this file.
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 
15 {
18 
19  params.addParam<Real>("scale_factor", 1.0, "Scale factor to be applied to the output values");
20  params.declareControllable("scale_factor");
21 
22  return params;
23 }
24 
26  : PiecewiseBase(parameters),
27  PiecewiseTabularInterface(*this, _raw_x, _raw_y),
28  _scale_factor(getParam<Real>("scale_factor"))
29 {
30  // load the data
31  if (isParamValid("data_file"))
33  else if (isParamValid("x") && isParamValid("y"))
35  else if (isParamValid("xy_data"))
36  buildFromXY();
37  else if (!isParamValid("json_uo"))
38  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 }
41 
42 void
44 {
45  // For JSON UO input, we need to wait for initialSetup to load the data
46  if (!isParamValid("json_uo"))
47  return;
48  else
49  buildFromJSON(getUserObject<JSONFileReader>("json_uo"));
50 }
static InputParameters validParams()
Function base which provides a piecewise approximation to a specified (x,y) point data set...
Definition: PiecewiseBase.h:20
PiecewiseTabularBase(const InputParameters &parameters)
static InputParameters validParams()
Definition: PiecewiseBase.C:14
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
const Parallel::Communicator & _communicator
static InputParameters validParams()
void buildFromFile(const libMesh::Parallel::Communicator &comm)
Reads data from supplied CSV file.
void initialSetup() override
Needed to load data from user objects that are not available at construction.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void buildFromXandY()
Builds data from &#39;x&#39; and &#39;y&#39; parameters.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
Definition: MooseBase.h:271
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:199
void buildFromXY()
Builds data from &#39;xy_data&#39; parameter.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
void buildFromJSON(const JSONFileReader &json_uo)
Reads data from supplied JSON reader.