1#ifndef included_AMP_ScalarProperty
2#define included_AMP_ScalarProperty
4#include "AMP/materials/Property.h"
19std::vector<std::array<double, 2>>
getDefaultRanges( std::vector<std::array<double, 2>> ranges,
20 const std::vector<std::string> &vars );
26 StringProperty( std::string_view name, std::string value, std::string_view source =
"" );
27 bool isString()
const override {
return true; }
43 std::string_view source =
"" );
47 std::string_view source =
"" );
62 std::string_view source,
64 std::vector<double> params = {},
65 std::vector<std::string> args = {},
66 std::vector<std::array<double, 2>> ranges = {},
67 std::vector<AMP::Units> argUnits = {} );
71 std::vector<double>
d_p;
81 const std::string &var_name,
82 std::vector<double> x,
83 std::vector<double> y,
84 const std::array<double, 2> range,
87 std::string_view source =
"",
88 std::string_view method =
"linear" );
92 std::vector<double>
d_x;
93 std::vector<double>
d_y;
104 std::shared_ptr<const MathExpr> eq,
106 std::vector<std::array<double, 2>> ranges = {},
107 std::vector<AMP::Units> argUnits = {},
108 std::string_view source =
"" );
110 const std::string &expression,
112 std::vector<std::string> args = {},
113 std::vector<std::array<double, 2>> ranges = {},
114 std::vector<AMP::Units> argUnits = {},
115 std::string_view source =
"" );
119 std::shared_ptr<const MathExpr>
d_eq;
124template<
class... Args>
129 std::function<
double( Args... )> fun,
131 std::vector<std::string> args = {},
132 std::vector<std::array<double, 2>> ranges = {},
133 std::vector<AMP::Units> argUnits = {},
134 const std::vector<double> &default_values = {},
135 std::string_view source =
"" )
142 std::move( argUnits ) ),
150 constexpr std::size_t N =
sizeof...( Args );
151 static_assert( N <= 5,
"More than 5 arguments is not supported yet" );
152 if constexpr ( N == 0 ) {
156 for (
size_t i = 0; i < result.
length(); i++ ) {
157 const double *x = &args( 0, i );
158 if constexpr ( N == 1 )
159 result( i ) =
d_fun( x[0] );
160 else if constexpr ( N == 2 )
161 result( i ) =
d_fun( x[0], x[1] );
162 else if constexpr ( N == 3 )
163 result( i ) =
d_fun( x[0], x[1], x[2] );
164 else if constexpr ( N == 4 )
165 result( i ) =
d_fun( x[0], x[1], x[2], x[3] );
166 else if constexpr ( N == 5 )
167 result( i ) =
d_fun( x[0], x[1], x[2], x[3], x[4] );
172 std::function<double( Args... )>
d_fun;
ARRAY_INLINE void fill(const TYPE &y)
ARRAY_INLINE size_t length() const
Return the size of the Array.
Equation based property class.
void eval(AMP::Array< double > &result, const AMP::Array< double > &args) const override
EquationProperty(std::string_view name, const std::string &expression, const AMP::Units &unit={}, std::vector< std::string > args={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={}, std::string_view source="")
std::shared_ptr< const MathExpr > d_eq
EquationProperty(std::string_view name, std::shared_ptr< const MathExpr > eq, const AMP::Units &unit={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={}, std::string_view source="")
Function based property class.
void eval(AMP::Array< double > &result, const AMP::Array< double > &args) const override
FunctionProperty(std::string_view name, std::function< double(Args...)> fun, const AMP::Units &unit={}, std::vector< std::string > args={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={}, const std::vector< double > &default_values={}, std::string_view source="")
std::function< double(Args...)> d_fun
Interpolated property class.
std::vector< double > d_x
std::vector< double > d_y
void eval(AMP::Array< double > &result, const AMP::Array< double > &) const override
InterpolatedProperty(std::string_view name, const AMP::Units &unit, const std::string &var_name, std::vector< double > x, std::vector< double > y, const std::array< double, 2 > range, const AMP::Units &argUnit, double default_value, std::string_view source="", std::string_view method="linear")
Polynomial based property class.
PolynomialProperty(std::string_view name, std::string_view source, const AMP::Units &unit={}, std::vector< double > params={}, std::vector< std::string > args={}, std::vector< std::array< double, 2 > > ranges={}, std::vector< AMP::Units > argUnits={})
std::vector< double > d_p
void eval(AMP::Array< double > &result, const AMP::Array< double > &args) const override
Provides material properties of scalar type.
void set_defaults(std::vector< double > defaults)
Set the defaults.
size_t get_number_arguments() const
Return the number of arguments to eval.
Scalar property class (fixed value)
ScalarProperty(std::string_view name, double value, const AMP::Units &unit=AMP::Units(), std::string_view source="")
const AMP::Array< double > & getValue() const
ScalarProperty(std::string_view name, AMP::Array< double > value, const AMP::Units &unit=AMP::Units(), std::string_view source="")
AMP::Array< double > d_value
void eval(AMP::Array< double > &result, const AMP::Array< double > &) const override
std::string evalString() const override
Get the string value of the property.
bool isString() const override
Indicator for scalar evaluator.
void eval(AMP::Array< double > &, const AMP::Array< double > &) const override
StringProperty(std::string_view name, std::string value, std::string_view source="")
Provides a class for storing units.
#define AMP_ASSERT(EXP)
Assert error.
std::vector< std::array< double, 2 > > getDefaultRanges(std::vector< std::array< double, 2 > > ranges, const std::vector< std::string > &vars)