MPD78
11-02-2009, 08:16 AM
Hello all,
I have an application that involves interpolating in 2 dimensions on a table of steam superheat enthalpy values.
The enthalpy is interpolated with a temperature (C) and a pressure (MPa).
I followed the example of how to get the routine working but I am having trouble with arrays.
I have x1[] as the temperature (C) array.
I have x2[] as the pressure (MPa) array.
I have yy[m][n] as the enthalpy (kJ/kg) array.
Here is my main function.
#include "interp_2d.h"
int main()
{
Doub pause; // Dummy variable to keep the output window visible
Doub ans; // Interpolatd results
Doub x1[] = {50,100,150,200,250,300,400,500,600,700}; // Temperature array (C)
Doub x2[] = {.010, 0.050, 0.10}; // Pressure array (MPa)
const Int m = sizeof(x1)/sizeof(x1[0]); // Obtain the size of the array x1
const Int n = sizeof(x2)/sizeof(x2[0]); // Obtain the size of the array x2
Doub yy[m][n] = {{2592.6, 0, 0}, {2687.5, 2682.5, 2676.2}, {2783.0, 2780.1, 2776.4}, {2879.5, 2877.7, 2875.3},
{2977.3, 2976.0, 2974.3}, {3076.5, 3075.5, 3074.3}, {3279.6, 3278.9, 3278.2}, {3489.1, 3488.7, 3488.1},
{3705.4, 3705.1, 3704.7}, {3928.7, 3928.5, 3928.2}}; // Enthalpy array (kJ/kg)
Doub xx1 = 175; // Temperature to interpolate with.
Doub xx2 = 0.025; // Pressure to interpolate with.
MatDoub yy(m,n);
VecDoub x1(m);
VecDoub x2(n);
Bilin_interp myfunc(x1,x2,yy); // Instance the Bilin_interp struct
ans = myfunc.interp(xx1,xx2);
cout << "Interpolated answer is " << ans << endl;
cin >> pause; // Dummy input to keep the output window visible
return 0;
}
When this code is compiled, I recieve the following error messages.
:error C2040: 'yy' : 'MatDoub' differs in levels of indirection from 'Doub [10][3]'
:error C2040: 'x1' : 'VecDoub' differs in levels of indirection from 'Doub [10]'
:error C2040: 'x2' : 'VecDoub' differs in levels of indirection from 'Doub [3]'
I am not sure what I have done wrong. As always, any help would be greatly appreciated.
Thanks
Matt
I have an application that involves interpolating in 2 dimensions on a table of steam superheat enthalpy values.
The enthalpy is interpolated with a temperature (C) and a pressure (MPa).
I followed the example of how to get the routine working but I am having trouble with arrays.
I have x1[] as the temperature (C) array.
I have x2[] as the pressure (MPa) array.
I have yy[m][n] as the enthalpy (kJ/kg) array.
Here is my main function.
#include "interp_2d.h"
int main()
{
Doub pause; // Dummy variable to keep the output window visible
Doub ans; // Interpolatd results
Doub x1[] = {50,100,150,200,250,300,400,500,600,700}; // Temperature array (C)
Doub x2[] = {.010, 0.050, 0.10}; // Pressure array (MPa)
const Int m = sizeof(x1)/sizeof(x1[0]); // Obtain the size of the array x1
const Int n = sizeof(x2)/sizeof(x2[0]); // Obtain the size of the array x2
Doub yy[m][n] = {{2592.6, 0, 0}, {2687.5, 2682.5, 2676.2}, {2783.0, 2780.1, 2776.4}, {2879.5, 2877.7, 2875.3},
{2977.3, 2976.0, 2974.3}, {3076.5, 3075.5, 3074.3}, {3279.6, 3278.9, 3278.2}, {3489.1, 3488.7, 3488.1},
{3705.4, 3705.1, 3704.7}, {3928.7, 3928.5, 3928.2}}; // Enthalpy array (kJ/kg)
Doub xx1 = 175; // Temperature to interpolate with.
Doub xx2 = 0.025; // Pressure to interpolate with.
MatDoub yy(m,n);
VecDoub x1(m);
VecDoub x2(n);
Bilin_interp myfunc(x1,x2,yy); // Instance the Bilin_interp struct
ans = myfunc.interp(xx1,xx2);
cout << "Interpolated answer is " << ans << endl;
cin >> pause; // Dummy input to keep the output window visible
return 0;
}
When this code is compiled, I recieve the following error messages.
:error C2040: 'yy' : 'MatDoub' differs in levels of indirection from 'Doub [10][3]'
:error C2040: 'x1' : 'VecDoub' differs in levels of indirection from 'Doub [10]'
:error C2040: 'x2' : 'VecDoub' differs in levels of indirection from 'Doub [3]'
I am not sure what I have done wrong. As always, any help would be greatly appreciated.
Thanks
Matt