00001
00002
00003
00004
00005
00006 #ifndef AMROC_F77_INTERPOLATION_H
00007 #define AMROC_F77_INTERPOLATION_H
00008
00016 #include "Interpolation.h"
00017
00024 template <class VectorType, int dim>
00025 class F77Interpolation : public Interpolation<VectorType,dim> {
00026 typedef Interpolation<VectorType,dim> base;
00027 typedef typename VectorType::InternalDataType DataType;
00028 public:
00029 typedef typename base::vec_grid_data_type vec_grid_data_type;
00030 typedef typename base::grid_data_type grid_data_type;
00031 typedef typename base::point_type point_type;
00032 typedef typename base::bool_grid_data_type bool_grid_data_type;
00033
00034 typedef generic_fortran_func generic_func_type;
00035
00036 typedef void (*int_1_func_type) ( const DOUBLE q[], const INTEGER &mx,
00037 const INTEGER &meqn, const INTEGER &nc,
00038 DOUBLE qint[], const DOUBLE xc[],
00039 const DOUBLE corn[], const DOUBLE dx[],
00040 const DOUBLE& ev);
00041
00042 typedef void (*int_2_func_type) ( const DOUBLE q[], const INTEGER &mx,
00043 const INTEGER &my,
00044 const INTEGER &meqn, const INTEGER &nc,
00045 DOUBLE qint[], const DOUBLE xc[],
00046 const DOUBLE corn[], const DOUBLE dx[],
00047 const DOUBLE& ev);
00048
00049 typedef void (*int_3_func_type) ( const DOUBLE q[], const INTEGER &mx,
00050 const INTEGER &my, const INTEGER &mz,
00051 const INTEGER &meqn, const INTEGER &nc,
00052 DOUBLE qint[], const DOUBLE xc[],
00053 const DOUBLE corn[], const DOUBLE dx[],
00054 const DOUBLE& ev);
00055
00056 F77Interpolation() : base(), f_intpol(0) {}
00057 F77Interpolation(generic_func_type intpol) : base(), f_intpol(intpol){}
00058
00059 virtual ~F77Interpolation() {}
00060
00061 virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu, const int& nc,
00062 const point_type* xc, VectorType* uv, const DataType& ErrorValue) {
00063 if (!f_intpol) return;
00064 DCoords dx = GH.worldStep(gdu.stepsize());
00065 DCoords corn = GH.worldCoords(gdu.lower(),gdu.stepsize());
00066 int mx[3];
00067 for (register int d=0; d<dim; d++)
00068 mx[d] = gdu.extents(d);
00069
00070 if (dim == 1)
00071 ((int_1_func_type) f_intpol)((DataType*)(gdu.data()),AA(1,mx),base::NEquations(),nc,
00072 uv[0].data(),xc[0].data(),corn(),dx(),ErrorValue);
00073 else if (dim == 2)
00074 ((int_2_func_type) f_intpol)((DataType*)(gdu.data()),AA(2,mx),base::NEquations(),nc,
00075 uv[0].data(),xc[0].data(),corn(),dx(),ErrorValue);
00076 else if (dim == 3)
00077 ((int_3_func_type) f_intpol)((DataType*)(gdu.data()),AA(3,mx),base::NEquations(),nc,
00078 uv[0].data(),xc[0].data(),corn(),dx(),ErrorValue);
00079 }
00080
00081 virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu,
00082 grid_data_type& gdphi, const int& nc, const point_type* xc,
00083 VectorType* uv, const DataType& ErrorValue) {
00084 base::Interpolate(GH,gdu,gdphi,nc,xc,uv,ErrorValue);
00085 }
00086
00087 virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu,
00088 bool_grid_data_type& gdflg, const int& nc, const point_type* xc,
00089 VectorType* uv, const DataType& ErrorValue) {
00090 base::Interpolate(GH,gdu,gdflg,nc,xc,uv,ErrorValue);
00091 }
00092
00093 virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd, const int& nc,
00094 const point_type* xc, DataType* u, const DataType& ErrorValue) {
00095 if (!f_intpol) return;
00096 DCoords dx = GH.worldStep(gd.stepsize());
00097 DCoords corn = GH.worldCoords(gd.lower(),gd.stepsize());
00098 int mx[3];
00099 for (register int d=0; d<dim; d++)
00100 mx[d] = gd.extents(d);
00101 int meqn = 1;
00102
00103 if (dim == 1)
00104 ((int_1_func_type) f_intpol)(gd.data(),AA(1,mx),meqn,nc,
00105 u,xc[0].data(),corn(),dx(),ErrorValue);
00106 else if (dim == 2)
00107 ((int_2_func_type) f_intpol)(gd.data(),AA(2,mx),meqn,nc,
00108 u,xc[0].data(),corn(),dx(),ErrorValue);
00109 else if (dim == 3)
00110 ((int_3_func_type) f_intpol)(gd.data(),AA(3,mx),meqn,nc,
00111 u,xc[0].data(),corn(),dx(),ErrorValue);
00112 }
00113
00114 virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd,
00115 grid_data_type& gdphi, const int& nc, const point_type* xc,
00116 DataType* u, const DataType& ErrorValue) {
00117 base::Interpolate(GH,gd,gdphi,nc,xc,u,ErrorValue);
00118 }
00119
00120 virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd,
00121 bool_grid_data_type& gdflg, const int& nc, const point_type* xc,
00122 DataType* u, const DataType& ErrorValue) {
00123 base::Interpolate(GH,gd,gdflg,nc,xc,u,ErrorValue);
00124 }
00125
00126 inline void SetIntPolFunc(generic_func_type intpol) { f_intpol = intpol; }
00127 generic_func_type GetIntPolFunc() const { return f_intpol; }
00128
00129 protected:
00130 generic_func_type f_intpol;
00131 };
00132
00133
00134 #endif
00135