Skip to content

Commit

Permalink
Refactor PiecewiseBase (idaholab#14220)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen authored and loganharbour committed Jan 16, 2020
1 parent 977d602 commit 4814670
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 288 deletions.
50 changes: 0 additions & 50 deletions framework/include/functions/Piecewise.h

This file was deleted.

25 changes: 21 additions & 4 deletions framework/include/functions/PiecewiseBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,37 @@ class PiecewiseBase : public Function

PiecewiseBase(const InputParameters & parameters);

virtual void initialSetup();
virtual Real functionSize() const;
virtual Real domain(const int i) const;
virtual Real range(const int i) const;

/**
* Provides a means for explicitly setting the x and y data. This must
* be called in the constructor of inhereted classes.
* be called in the constructor of inherited classes.
*/
void setData(const std::vector<Real> & x, const std::vector<Real> & y);

protected:
std::unique_ptr<LinearInterpolation> _linear_interp;
///@{ raw function data as read
std::vector<Real> _raw_x;
std::vector<Real> _raw_y;
///@}

/// function value scale factor
const Real _scale_factor;

///@{ if _has_axis is true point component to use as function argument, otherwise use t
int _axis;
const bool _has_axis;
bool _data_set;
///@}

private:
/// Reads data from supplied CSV file.
void buildFromFile();

/// Builds data from 'x' and 'y' parameters.
void buildFromXandY();

/// Builds data from 'xy_data' parameter.
void buildFromXY();
};
4 changes: 2 additions & 2 deletions framework/include/functions/PiecewiseConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "Piecewise.h"
#include "PiecewiseBase.h"

// Forward declarations
class PiecewiseConstant;
Expand All @@ -21,7 +21,7 @@ InputParameters validParams<PiecewiseConstant>();
* Function which provides a piecewise continuous constant interpolation
* of a provided (x,y) point data set.
*/
class PiecewiseConstant : public Piecewise
class PiecewiseConstant : public PiecewiseBase
{
public:
static InputParameters validParams();
Expand Down
7 changes: 5 additions & 2 deletions framework/include/functions/PiecewiseLinear.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#pragma once

#include "Piecewise.h"
#include "PiecewiseBase.h"

// Forward declarations
class PiecewiseLinear;
Expand All @@ -21,13 +21,16 @@ InputParameters validParams<PiecewiseLinear>();
* Function which provides a piecewise continuous linear interpolation
* of a provided (x,y) point data set.
*/
class PiecewiseLinear : public Piecewise
class PiecewiseLinear : public PiecewiseBase
{
public:
static InputParameters validParams();

PiecewiseLinear(const InputParameters & parameters);

/// helper object to perform the linear interpolation of the function data
std::unique_ptr<LinearInterpolation> _linear_interp;

/**
* Get the value of the function (based on time only)
* \param t The time
Expand Down
158 changes: 0 additions & 158 deletions framework/src/functions/Piecewise.C

This file was deleted.

0 comments on commit 4814670

Please sign in to comment.