vtf-logo

F77GFMLevelSet.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_GFMLEVELSET_H
00007 #define AMROC_F77_GFMLEVELSET_H
00008 
00016 #include "GFMLevelSet.h"
00017 
00024 template <class DataType, int dim>
00025 class F77GFMLevelSet : public GFMLevelSet<DataType,dim> {
00026   typedef GFMLevelSet<DataType,dim> base;
00027 
00028 public:
00029   typedef typename base::grid_fct_type grid_fct_type;  
00030   typedef typename base::grid_data_type grid_data_type;
00031 
00032   typedef generic_fortran_func generic_func_type; 
00033 
00034   typedef void (*lset_1_func_type) ( const INTEGER& maxmx, 
00035                                      const INTEGER& mbc,
00036                                      const INTEGER& mx, 
00037                                      const DOUBLE x[], 
00038                                      const DOUBLE& dx, 
00039                                      DataType q[], const DOUBLE& t); 
00040   typedef void (*lset_2_func_type) ( const INTEGER& maxmx, const INTEGER& maxmy, 
00041                                      const INTEGER& mbc,
00042                                      const INTEGER& mx, const INTEGER& my, 
00043                                      const DOUBLE x[], const DOUBLE y[], 
00044                                      const DOUBLE& dx, const DOUBLE& dy, 
00045                                      DataType q[], const DOUBLE& t);
00046   typedef void (*lset_3_func_type) ( const INTEGER& maxmx, const INTEGER& maxmy, const INTEGER& maxmz,
00047                                      const INTEGER& mbc,
00048                                      const INTEGER& mx, const INTEGER& my, const INTEGER& mz,
00049                                      const DOUBLE x[], const DOUBLE y[], const DOUBLE z[],
00050                                      const DOUBLE& dx, const DOUBLE& dy, const DOUBLE& dz, 
00051                                      DataType q[], const DOUBLE& t);
00052 
00053   F77GFMLevelSet() : base(), f_lset(0), inverse(0) {}
00054   F77GFMLevelSet(generic_func_type lset) : base(), f_lset(lset), inverse(0) {}
00055 
00056   virtual ~F77GFMLevelSet() {}
00057   
00058   virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00059     base::LocCtrl = Ctrl.getSubDevice(prefix+"F77LevelSet");
00060     RegisterAt(base::LocCtrl,"PlotPhi",base::_PlotPhi);
00061     RegisterAt(base::LocCtrl,"Stationary",base::_Stationary);
00062     RegisterAt(base::LocCtrl,"Inverse",inverse);
00063   } 
00064   virtual void register_at(ControlDevice& Ctrl) {
00065     register_at(Ctrl, "");
00066   }
00067 
00068   virtual void SetGrid(grid_data_type& gdphi, const int& level, const double& t) {   
00069     assert(f_lset != (generic_func_type) 0);
00070     Coords ex = gdphi.extents();
00071     DCoords lbcorner = base::GH().worldCoords(gdphi.lower(), gdphi.stepsize());
00072     DCoords dx = base::GH().worldStep(gdphi.stepsize());
00073     int maxm[3], mx[3], d;
00074     DataType* x[3];
00075     for (d=0; d<dim; d++) {
00076       maxm[d] = ex(d);
00077       mx[d] = ex(d)-2*base::NGhosts();
00078       x[d] = new DataType[maxm[d]];
00079       for (int i=0; i<maxm[d]; i++) x[d][i] = (i+0.5)*dx(d)+lbcorner(d);
00080     }
00081 
00082     if (dim == 1) 
00083       ((lset_1_func_type) f_lset)(AA(1,mx), base::NGhosts(), AA(1,mx), 
00084                                   AA(1,x), AA(1,dx), gdphi.data(), t); 
00085     else if (dim == 2)
00086       ((lset_2_func_type) f_lset)(AA(2,mx), base::NGhosts(), AA(2,mx), 
00087                                   AA(2,x), AA(2,dx), gdphi.data(), t);
00088     else if (dim == 3)
00089       ((lset_3_func_type) f_lset)(AA(3,mx), base::NGhosts(), AA(3,mx), 
00090                                   AA(3,x), AA(3,dx), gdphi.data(), t);
00091 
00092     if (inverse) gdphi.multiply(-1.0);
00093 
00094     for (d=0; d<dim; d++) 
00095       delete [] x[d];
00096   }
00097 
00098   inline void SetFunc(generic_func_type lset) { f_lset = lset; }
00099   generic_func_type GetFunc() const { return f_lset; }
00100 
00101 protected:
00102   generic_func_type f_lset;
00103   int inverse; 
00104 };
00105 
00106 
00107 #endif

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