https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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"))
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
42void
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}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void declareControllable(const std::string &name, std::set< ExecFlagType > execute_flags={})
Declare the given parameters as controllable.
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
Function base which provides a piecewise approximation to a specified (x,y) point data set.
static InputParameters validParams()
void buildFromXY()
Builds data from 'xy_data' parameter.
static InputParameters validParams()
void buildFromXandY()
Builds data from 'x' and 'y' parameters.
void initialSetup() override
Needed to load data from user objects that are not available at construction.
PiecewiseTabularBase(const InputParameters &parameters)
void buildFromFile(const libMesh::Parallel::Communicator &comm)
Reads data from supplied CSV file.
void buildFromJSON(const JSONFileReader &json_uo)
Reads data from supplied JSON reader.
static InputParameters validParams()
const Parallel::Communicator & _communicator