vtf-logo

F77GFMInterpolation.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2003-2007 California Institute of Technology
00004 // Ralf Deiterding, ralf@amroc.net
00005 
00006 #ifndef AMROC_F77_GFM_INTERPOLATION_H
00007 #define AMROC_F77_GFM_INTERPOLATION_H
00008 
00016 #include "F77Interfaces/F77Interpolation.h"
00017 
00024 template <class VectorType, int dim>
00025 class F77GFMInterpolation : public F77Interpolation<VectorType,dim> {
00026   typedef F77Interpolation<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 (*intex_1_func_type) ( const DOUBLE q[], const INTEGER &mx, 
00037                                       const INTEGER &meqn, const DOUBLE phi[], const INTEGER &nc, 
00038                                       DOUBLE qint[], const DOUBLE xc[],
00039                                       const DOUBLE corn[], const DOUBLE dx[], 
00040                                       const DOUBLE& ev);
00041 
00042   typedef void (*intex_2_func_type) ( const DOUBLE q[], const INTEGER &mx, 
00043                                       const INTEGER &my, 
00044                                       const INTEGER &meqn, const DOUBLE phi[], const INTEGER &nc, 
00045                                       DOUBLE qint[], const DOUBLE xc[],
00046                                       const DOUBLE corn[], const DOUBLE dx[], 
00047                                       const DOUBLE& ev);
00048 
00049   typedef void (*intex_3_func_type) ( const DOUBLE q[], const INTEGER &mx, 
00050                                       const INTEGER &my, const INTEGER &mz, 
00051                                       const INTEGER &meqn, const DOUBLE phi[], const INTEGER &nc, 
00052                                       DOUBLE qint[], const DOUBLE xc[],
00053                                       const DOUBLE corn[], const DOUBLE dx[], 
00054                                       const DOUBLE& ev);
00055 
00056   F77GFMInterpolation() : base(), f_intexpol(0) {}
00057   F77GFMInterpolation(generic_func_type intexpol) : base(), f_intexpol(intexpol) {}
00058   F77GFMInterpolation(generic_func_type intpol, generic_func_type intexpol) : base(intpol), 
00059     f_intexpol(intexpol) {}
00060   
00061   virtual ~F77GFMInterpolation() {}
00062   
00063   virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu, const int& nc, 
00064                            const point_type* xc, VectorType* uv, const DataType& ErrorValue) {
00065     base::Interpolate(GH,gdu,nc,xc,uv,ErrorValue);
00066   }    
00067 
00068   virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu, 
00069                            grid_data_type& gdphi, const int& nc, const point_type* xc, 
00070                            VectorType* uv, const DataType& ErrorValue) {
00071     if (!f_intexpol) return;
00072     DCoords dx = GH.worldStep(gdu.stepsize());
00073     DCoords corn = GH.worldCoords(gdu.lower(),gdu.stepsize());
00074     int mx[3];
00075     for (register int d=0; d<dim; d++) 
00076       mx[d] = gdu.extents(d);
00077 
00078     if (dim == 1)
00079       ((intex_1_func_type) f_intexpol)((DataType*)(gdu.data()),AA(1,mx),base::NEquations(),
00080                                        gdphi.data(),nc,uv[0].data(),xc[0].data(),corn(),dx(),
00081                                        ErrorValue); 
00082     else if (dim == 2) 
00083       ((intex_2_func_type) f_intexpol)((DataType*)(gdu.data()),AA(2,mx),base::NEquations(),
00084                                        gdphi.data(),nc,uv[0].data(),xc[0].data(),corn(),dx(),
00085                                        ErrorValue); 
00086     else if (dim == 3) 
00087       ((intex_3_func_type) f_intexpol)((DataType*)(gdu.data()),AA(3,mx),base::NEquations(),
00088                                        gdphi.data(),nc,uv[0].data(),xc[0].data(),corn(),dx(),
00089                                        ErrorValue); 
00090   }    
00091 
00092   virtual void Interpolate(GridHierarchy& GH, vec_grid_data_type& gdu, 
00093                            bool_grid_data_type& gdflg, const int& nc, const point_type* xc, 
00094                            VectorType* uv, const DataType& ErrorValue) {
00095     if (!f_intexpol) return;
00096     grid_data_type phihelp(gdflg.bbox());
00097     base::SetPhiFromBool(phihelp,gdflg);
00098     Interpolate(GH,gdu,phihelp,nc,xc,uv,ErrorValue);
00099   }
00100 
00101   virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd, const int& nc, 
00102                            const point_type* xc, DataType* u, const DataType& ErrorValue) {
00103     base::Interpolate(GH,gd,nc,xc,u,ErrorValue);
00104   }
00105 
00106   virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd, 
00107                            grid_data_type& gdphi, const int& nc, const point_type* xc, 
00108                            DataType* u, const DataType& ErrorValue) {
00109     if (!f_intexpol) return;
00110     DCoords dx = GH.worldStep(gd.stepsize());
00111     DCoords corn = GH.worldCoords(gd.lower(),gd.stepsize());
00112     int mx[3];
00113     for (register int d=0; d<dim; d++) 
00114       mx[d] = gd.extents(d);
00115     int meqn = 1;
00116 
00117     if (dim == 1) 
00118       ((intex_1_func_type) f_intexpol)(gd.data(),AA(1,mx),meqn,gdphi.data(),nc,
00119                                        u,xc[0].data(),corn(),dx(),ErrorValue); 
00120     else if (dim == 2) 
00121       ((intex_2_func_type) f_intexpol)(gd.data(),AA(2,mx),meqn,gdphi.data(),nc,
00122                                        u,xc[0].data(),corn(),dx(),ErrorValue); 
00123     else if (dim == 3) 
00124       ((intex_3_func_type) f_intexpol)(gd.data(),AA(3,mx),meqn,gdphi.data(),nc,
00125                                        u,xc[0].data(),corn(),dx(),ErrorValue); 
00126   }
00127 
00128   virtual void Interpolate(GridHierarchy& GH, grid_data_type& gd, 
00129                            bool_grid_data_type& gdflg, const int& nc, const point_type* xc, 
00130                            DataType* u, const DataType& ErrorValue) {
00131     if (!f_intexpol) return;
00132     grid_data_type phihelp(gdflg.bbox());
00133     base::SetPhiFromBool(phihelp,gdflg);
00134     Interpolate(GH,gd,phihelp,nc,xc,u,ErrorValue);
00135   }
00136 
00137   inline void SetIntExPolFunc(generic_func_type intexpol) { f_intexpol = intexpol; }
00138   generic_func_type GetIntExPolFunc() const { return f_intexpol; }
00139 
00140 protected:
00141   generic_func_type f_intexpol;
00142 };
00143 
00144 
00145 #endif
00146 

Generated on Fri Aug 24 13:00:49 2007 for AMROC Fluid-solver Framework - by  doxygen 1.4.7