vtf-logo

F77ExactSolution.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2002 Ralf Deiterding
00004 // Brandenburgische Universitaet Cottbus
00005 //
00006 // Copyright (C) 2003-2007 California Institute of Technology
00007 // Ralf Deiterding, ralf@amroc.net
00008 
00009 #ifndef AMROC_F77_EXACT_SOLUTION_H
00010 #define AMROC_F77_EXACT_SOLUTION_H
00011 
00019 #include "ExactSolution.h"
00020 
00021 template <class VectorType, int dim>
00022 class F77ExactBase {
00023   typedef typename VectorType::InternalDataType DataType;
00024   typedef GridData<VectorType,dim> vec_grid_data_type;
00025 
00026 public:
00027   typedef generic_fortran_func generic_func_type; 
00028 
00029   typedef void (*exact_1_func_type) ( const INTEGER& maxmx, 
00030                                       const INTEGER& meqn, const INTEGER& mbc,
00031                                       const INTEGER& mx, 
00032                                       const DOUBLE x[], 
00033                                       const DOUBLE& dx, 
00034                                       const DOUBLE& t, VectorType q[]); 
00035   typedef void (*exact_2_func_type) ( const INTEGER& maxmx, const INTEGER& maxmy, 
00036                                       const INTEGER& meqn, const INTEGER& mbc,
00037                                       const INTEGER& mx, const INTEGER& my, 
00038                                       const DOUBLE x[], const DOUBLE y[], 
00039                                       const DOUBLE& dx, const DOUBLE& dy, 
00040                                       const DOUBLE& t, VectorType q[]);
00041   typedef void (*exact_3_func_type) ( const INTEGER& maxmx, const INTEGER& maxmy, const INTEGER& maxmz,
00042                                       const INTEGER& meqn, const INTEGER& mbc,
00043                                       const INTEGER& mx, const INTEGER& my, const INTEGER& mz,
00044                                       const DOUBLE x[], const DOUBLE y[], const DOUBLE z[],
00045                                       const DOUBLE& dx, const DOUBLE& dy, const DOUBLE& dz, 
00046                                       const DOUBLE& t, VectorType q[]);
00047 
00048   F77ExactBase() : f_exact(0), _Equations(VectorType::Length()) {}
00049   F77ExactBase(generic_func_type exact) : f_exact(exact), _Equations(VectorType::Length()) {}
00050 
00051   void SetGrid(GridHierarchy& GH, const int& NGhosts, vec_grid_data_type& gd, 
00052                const int& level, double t) {
00053     assert(f_exact != (generic_func_type) 0);
00054     Coords ex = gd.extents();
00055     DCoords lbcorner = GH.worldCoords(gd.lower(), gd.stepsize());
00056     DCoords dx = GH.worldStep(gd.stepsize());
00057     int maxm[3], mx[3], d;
00058     DataType* x[3];
00059     for (d=0; d<dim; d++) {
00060       maxm[d] = ex(d);
00061       mx[d] = ex(d)-2*NGhosts;
00062       x[d] = new DataType[maxm[d]];
00063       for (int i=0; i<maxm[d]; i++) x[d][i] = (i+0.5)*dx(d)+lbcorner(d);
00064     }
00065 
00066     if (dim == 1) 
00067       ((exact_1_func_type) f_exact)(AA(1,mx),_Equations, NGhosts, 
00068                                     AA(1,mx), AA(1,x), AA(1,dx), t, gd.data()); 
00069     else if (dim == 2)
00070       ((exact_2_func_type) f_exact)(AA(2,mx),_Equations, NGhosts, 
00071                                     AA(2,mx), AA(2,x), AA(2,dx), t, gd.data());
00072     else if (dim == 3)
00073       ((exact_3_func_type) f_exact)(AA(3,mx),_Equations, NGhosts, 
00074                                     AA(3,mx), AA(3,x), AA(3,dx), t, gd.data());
00075 
00076     for (d=0; d<dim; d++) 
00077       delete [] x[d];
00078    }
00079 
00080   inline void SetFunc(generic_func_type exact) { f_exact = exact; }
00081   generic_func_type GetFunc() const { return f_exact; }
00082 
00083 protected:
00084   generic_func_type f_exact;
00085   int _Equations;
00086 };
00087 
00094 template <class VectorType, int dim>
00095 class F77ExactSolution : public F77ExactBase<VectorType,dim>,
00096   public ExactSolution<VectorType,dim> {
00097   typedef typename VectorType::InternalDataType DataType;
00098   typedef ExactSolution<VectorType,dim> base;
00099   typedef F77ExactBase<VectorType,dim> exact_base;
00100 
00101 public:
00102   typedef typename base::vec_grid_data_type vec_grid_data_type;
00103   typedef typename exact_base::generic_func_type generic_func_type;
00104 
00105   F77ExactSolution() : exact_base(), base() {}
00106   F77ExactSolution(generic_func_type exact) : exact_base(exact), base() {}
00107 
00108   virtual ~F77ExactSolution() {}
00109   
00110   virtual void SetGrid(vec_grid_data_type& gd, const int& level, double t) {
00111     exact_base::SetGrid(base::GH(),base::NGhosts(),gd,level,t);
00112   }
00113 };
00114 
00115 
00116 #endif

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