Skip to content
Snippets Groups Projects
Commit 7d77f672 authored by wenqing's avatar wenqing
Browse files

[Mat] Changed the size of function pointer array

parent 07ca1742
No related branches found
No related tags found
No related merge requests found
......@@ -61,7 +61,7 @@ public:
{
assert(var == PropertyVariableType::T || var == PropertyVariableType::pg);
const int func_id = (var == PropertyVariableType::T) ? 0 : 1;
const int func_id = static_cast<int> (var);
return (this->*_derivative_functions[func_id])(
var_vals[static_cast<int> (PropertyVariableType::T)],
var_vals[static_cast<int> (PropertyVariableType::pg)]);
......@@ -91,11 +91,12 @@ private:
const double) const;
/// An array of pointers to derivative functions.
static DerivativeFunctionPointer _derivative_functions[2];
static DerivativeFunctionPointer _derivative_functions[PropertyVariableNumber];
};
IdealGasLaw::DerivativeFunctionPointer IdealGasLaw::_derivative_functions[2]
= {&IdealGasLaw::dIdealGasLaw_dT,&IdealGasLaw::dIdealGasLaw_dp};
IdealGasLaw::DerivativeFunctionPointer IdealGasLaw
::_derivative_functions[PropertyVariableNumber]
= {&IdealGasLaw::dIdealGasLaw_dT, nullptr, &IdealGasLaw::dIdealGasLaw_dp};
} // end namespace
} // end namespace
#endif
......@@ -60,12 +60,9 @@ public:
* [4] $f E_0 $f
*/
explicit LiquidDensity(std::array<double,5>& parameters)
:
_beta(parameters[0]),
_rho0(parameters[1]),
_temperature0(parameters[2]),
_p0(parameters[3]),
_bulk_modulus(parameters[4])
: _beta (parameters[0]), _rho0 (parameters[1]),
_temperature0 (parameters[2]), _p0 (parameters[3]),
_bulk_modulus (parameters[4])
{
}
......@@ -96,7 +93,7 @@ public:
{
assert(var == PropertyVariableType::T || var == PropertyVariableType::pl);
const int func_id = (var == PropertyVariableType::T) ? 0 : 1;
const int func_id = static_cast<int> (var);
const double T = var_vals[static_cast<int> (PropertyVariableType::T)];
const double p = var_vals[static_cast<int> (PropertyVariableType::pl)];
return (this->*_derivative_functions[func_id])(T, p);
......@@ -147,11 +144,12 @@ private:
const double) const;
/// An array of pointers to derivative functions.
static DerivativeFunctionPointer _derivative_functions[2];
static DerivativeFunctionPointer _derivative_functions[PropertyVariableNumber];
};
LiquidDensity::DerivativeFunctionPointer LiquidDensity::_derivative_functions[2]
= {&LiquidDensity::dLiquidDensity_dT,&LiquidDensity::dLiquidDensity_dp};
LiquidDensity::DerivativeFunctionPointer LiquidDensity
::_derivative_functions[PropertyVariableNumber]
= {&LiquidDensity::dLiquidDensity_dT, &LiquidDensity::dLiquidDensity_dp, nullptr};
} // end of namespace
} // end of namespace
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment