www.mooseframework.org
PiecewiseLinear.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "PiecewiseLinear.h"
16 
17 template <>
20 {
22  params.addClassDescription("Linearly interpolates between pairs of x-y data");
23  return params;
24 }
25 
26 PiecewiseLinear::PiecewiseLinear(const InputParameters & parameters) : Piecewise(parameters) {}
27 
28 Real
29 PiecewiseLinear::value(Real t, const Point & p)
30 {
31  Real func_value;
32  if (_has_axis)
33  {
34  func_value = _linear_interp->sample(p(_axis));
35  }
36  else
37  {
38  func_value = _linear_interp->sample(t);
39  }
40  return _scale_factor * func_value;
41 }
42 
43 Real
44 PiecewiseLinear::timeDerivative(Real t, const Point & p)
45 {
46  Real func_value;
47  if (_has_axis)
48  {
49  func_value = _linear_interp->sampleDerivative(p(_axis));
50  }
51  else
52  {
53  func_value = _linear_interp->sampleDerivative(t);
54  }
55  return _scale_factor * func_value;
56 }
57 
58 Real
60 {
61  return _scale_factor * _linear_interp->integrate();
62 }
63 
64 Real
66 {
67  return integral() /
68  (_linear_interp->domain(_linear_interp->getSampleSize() - 1) - _linear_interp->domain(0));
69 }
virtual Real timeDerivative(Real t, const Point &pt) override
Get the time derivative of the function (based on time only)
virtual Real value(Real t, const Point &pt) override
Get the value of the function (based on time only)
int _axis
Definition: Piecewise.h:63
bool _has_axis
Definition: Piecewise.h:64
const Real _scale_factor
Definition: Piecewise.h:61
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual Real average() override
InputParameters validParams< Piecewise >()
Definition: Piecewise.C:22
PiecewiseLinear(const InputParameters &parameters)
std::unique_ptr< LinearInterpolation > _linear_interp
Definition: Piecewise.h:62
virtual Real integral() override
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
InputParameters validParams< PiecewiseLinear >()
Function which provides a piecewise approximation to a provided (x,y) point data set.
Definition: Piecewise.h:31