00001
00002
00003
00004
00005
00006 #ifndef AMROC_F77_GFMBOUNDARY_H
00007 #define AMROC_F77_GFMBOUNDARY_H
00008
00016 #include "GFMBoundary.h"
00017
00024 template <class VectorType, int dim>
00025 class F77GFMBoundary : public GFMBoundary<VectorType,dim> {
00026 typedef typename VectorType::InternalDataType DataType;
00027 typedef GFMBoundary<VectorType,dim> base;
00028
00029 public:
00030 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00031 typedef typename base::vec_grid_data_type vec_grid_data_type;
00032 typedef typename base::grid_fct_type grid_fct_type;
00033 typedef typename base::grid_data_type grid_data_type;
00034 typedef typename base::point_type point_type;
00035
00036 typedef generic_fortran_func generic_func_type;
00037
00038 typedef void (*bnd_1_func_type) ( FI(1,VectorType), const INTEGER &, const INTEGER &,
00039 const INTEGER *, const DOUBLE *, const DOUBLE *,
00040 const DOUBLE *, const DOUBLE *, const INTEGER &,
00041 const DOUBLE *, const DOUBLE *, const DOUBLE &);
00042
00043 typedef void (*bnd_2_func_type) ( FI(2,VectorType), const INTEGER &, const INTEGER &,
00044 const INTEGER *, const DOUBLE *, const DOUBLE *,
00045 const DOUBLE *, const DOUBLE *, const INTEGER &,
00046 const DOUBLE *, const DOUBLE *, const DOUBLE &);
00047
00048 typedef void (*bnd_3_func_type) ( FI(3,VectorType), const INTEGER &, const INTEGER &,
00049 const INTEGER *, const DOUBLE *, const DOUBLE *,
00050 const DOUBLE *, const DOUBLE *, const INTEGER &,
00051 const DOUBLE *, const DOUBLE *, const DOUBLE &);
00052
00053 typedef void (*trans_1_func_type) ( const INTEGER& mx,
00054 const INTEGER& meqn, VectorType* q, VectorType* qt);
00055
00056 typedef void (*trans_2_func_type) ( const INTEGER& mx, const INTEGER& my,
00057 const INTEGER& meqn, VectorType* q, VectorType* qt);
00058
00059 typedef void (*trans_3_func_type) ( const INTEGER& mx, const INTEGER& my, const INTEGER& mz,
00060 const INTEGER& meqn, VectorType* q, VectorType* qt);
00061
00062 typedef void (*bndaux_func_type) ( const INTEGER &, const INTEGER &, const DOUBLE *,
00063 const DOUBLE *, const DOUBLE *, const DOUBLE *,
00064 const INTEGER &, const DOUBLE *, const DOUBLE *,
00065 const DOUBLE &);
00066
00067 public:
00068 F77GFMBoundary(generic_func_type bnd) :
00069 base(), f_intbnd(bnd), f_inttrans(0), f_intaux(0) {}
00070 F77GFMBoundary(generic_func_type bnd, generic_func_type trs) :
00071 base(), f_intbnd(bnd), f_inttrans(trs), f_intaux(0) {}
00072 F77GFMBoundary(generic_func_type bnd, generic_func_type trs, generic_func_type aux) :
00073 base(), f_intbnd(bnd), f_inttrans(trs), f_intaux(aux) {}
00074
00075 virtual ~F77GFMBoundary() {}
00076
00077 virtual void SetGrid(vec_grid_data_type& gdu, grid_data_type& gdphi, const BBox& bb,
00078 const int& Level, double t, const int& nc,
00079 const int* idx, const point_type* xc,
00080 DataType* distance, point_type* normal) {
00081
00082 Coords ex = gdu.extents();
00083 VectorType* u = (VectorType*) 0;
00084 DataType* aux = (DataType*) 0;
00085 DCoords dx = base::GH().worldStep(gdu.stepsize());
00086 if (base::NAux()>0)
00087 aux = new DataType[nc*base::NAux()];
00088
00089 if (base::NormalFactor()>0)
00090 if (f_inttrans) {
00091 START_WATCH
00092 vec_grid_data_type gdhelp(gdu.bbox());
00093 if (dim == 1)
00094 ((trans_1_func_type) f_inttrans)(AA(1,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00095 else if (dim == 2)
00096 ((trans_2_func_type) f_inttrans)(AA(2,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00097 else if (dim == 3)
00098 ((trans_3_func_type) f_inttrans)(AA(3,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00099 END_WATCH(GFM_TRANSFORM)
00100
00101 base::Extrapolation(gdhelp,gdphi,u,Level,nc,idx,xc,
00102 distance,normal,base::NormalFactor());
00103 if (base::NAux()>0) {
00104 START_WATCH
00105 SetBndryAux(gdhelp,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00106 END_WATCH(GFM_AUXILIARY_VALUES)
00107 }
00108 }
00109 else {
00110 base::Extrapolation(gdu,gdphi,u,Level,nc,idx,xc,
00111 distance,normal,base::NormalFactor());
00112 if (base::NAux()>0) {
00113 START_WATCH
00114 SetBndryAux(gdu,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00115 END_WATCH(GFM_AUXILIARY_VALUES)
00116 }
00117 }
00118 else if (base::NAux()>0) {
00119 START_WATCH
00120 SetBndryAux(gdu,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00121 END_WATCH(GFM_AUXILIARY_VALUES)
00122 }
00123
00124 if (f_intbnd) {
00125 START_WATCH
00126 if (dim == 1)
00127 ((bnd_1_func_type) f_intbnd)(FORTRAN_ARGS(1,gdu),base::NEquations(),nc,
00128 idx,u[0].data(),xc[0].data(),distance,
00129 normal[0].data(),base::NAux(),aux,dx(),t);
00130 else if (dim == 2)
00131 ((bnd_2_func_type) f_intbnd)(FORTRAN_ARGS(2,gdu),base::NEquations(),nc,
00132 idx,u[0].data(),xc[0].data(),distance,
00133 normal[0].data(),base::NAux(),aux,dx(),t);
00134 else if (dim == 3)
00135 ((bnd_3_func_type) f_intbnd)(FORTRAN_ARGS(3,gdu),base::NEquations(),nc,
00136 idx,u[0].data(),xc[0].data(),distance,
00137 normal[0].data(),base::NAux(),aux,dx(),t);
00138 END_WATCH(GFM_SETBNDRY)
00139 }
00140 if (u) delete [] u;
00141 if (aux) delete [] aux;
00142 }
00143
00144 virtual void SetBndryAux(vec_grid_data_type& gdu, grid_data_type& gdphi, const BBox& bb,
00145 const VectorType* u, DataType* aux, const int& Level,
00146 double t, const int& nc, const int* idx,
00147 const point_type* xc, const DataType* distance,
00148 const point_type* normal) {
00149 if (f_intaux) {
00150 DCoords dx = base::GH().worldStep(gdu.stepsize());
00151 ((bndaux_func_type) f_intaux)(base::NEquations(),nc,u[0].data(),
00152 xc[0].data(),distance,normal[0].data(),
00153 base::NAux(),aux,dx(),t);
00154 }
00155 else
00156 for (register int i=0; i<nc*base::NAux(); i++)
00157 aux[i] = static_cast<DataType>(0.);
00158 }
00159
00160 inline void SetBndFunc(generic_func_type bnd) { f_intbnd = bnd; }
00161 generic_func_type GetBndFunc() const { return f_intbnd; }
00162 inline void SetTransFunc(generic_func_type trans) { f_inttrans = trans; }
00163 generic_func_type GetTransFunc() const { return f_inttrans; }
00164 inline void SetAuxFunc(generic_func_type aux) { f_intaux = aux; }
00165 generic_func_type GetAuxFunc() const { return f_intaux; }
00166
00167 protected:
00168 generic_func_type f_intbnd, f_inttrans, f_intaux;
00169 };
00170
00171 #endif