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, generic_func_type trs) :
00069 base(), f_intbnd(bnd), f_inttrans(trs), f_intaux(0) {}
00070 F77GFMBoundary(generic_func_type bnd, generic_func_type trs, generic_func_type aux) :
00071 base(), f_intbnd(bnd), f_inttrans(trs), f_intaux(aux) {}
00072
00073 virtual ~F77GFMBoundary() {}
00074
00075 virtual void SetGrid(vec_grid_data_type& gdu, grid_data_type& gdphi, const BBox& bb,
00076 const int& Level, double t, const int& nc,
00077 const int* idx, const point_type* xc,
00078 DataType* distance, point_type* normal) {
00079
00080 Coords ex = gdu.extents();
00081 VectorType* u = (VectorType*) 0;
00082 DataType* aux = (DataType*) 0;
00083 DCoords dx = base::GH().worldStep(gdu.stepsize());
00084 if (base::NAux()>0)
00085 aux = new DataType[nc*base::NAux()];
00086
00087 if (base::NormalFactor()>0)
00088 if (f_inttrans) {
00089 START_WATCH
00090 vec_grid_data_type gdhelp(gdu.bbox());
00091 if (dim == 1)
00092 ((trans_1_func_type) f_inttrans)(AA(1,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00093 else if (dim == 2)
00094 ((trans_2_func_type) f_inttrans)(AA(2,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00095 else if (dim == 3)
00096 ((trans_3_func_type) f_inttrans)(AA(3,ex()),base::NEquations(),gdu.data(),gdhelp.data());
00097 END_WATCH(GFM_TRANSFORM)
00098
00099 base::Extrapolation(gdhelp,gdphi,u,Level,nc,idx,xc,
00100 distance,normal,base::NormalFactor());
00101 if (base::NAux()>0) {
00102 START_WATCH
00103 SetBndryAux(gdhelp,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00104 END_WATCH(GFM_AUXILIARY_VALUES)
00105 }
00106 }
00107 else {
00108 base::Extrapolation(gdu,gdphi,u,Level,nc,idx,xc,
00109 distance,normal,base::NormalFactor());
00110 if (base::NAux()>0) {
00111 START_WATCH
00112 SetBndryAux(gdu,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00113 END_WATCH(GFM_AUXILIARY_VALUES)
00114 }
00115 }
00116 else if (base::NAux()>0) {
00117 START_WATCH
00118 SetBndryAux(gdu,gdphi,bb,u,aux,Level,t,nc,idx,xc,distance,normal);
00119 END_WATCH(GFM_AUXILIARY_VALUES)
00120 }
00121
00122 if (f_intbnd) {
00123 START_WATCH
00124 if (dim == 1)
00125 ((bnd_1_func_type) f_intbnd)(FORTRAN_ARGS(1,gdu),base::NEquations(),nc,
00126 idx,u[0].data(),xc[0].data(),distance,
00127 normal[0].data(),base::NAux(),aux,dx(),t);
00128 else if (dim == 2)
00129 ((bnd_2_func_type) f_intbnd)(FORTRAN_ARGS(2,gdu),base::NEquations(),nc,
00130 idx,u[0].data(),xc[0].data(),distance,
00131 normal[0].data(),base::NAux(),aux,dx(),t);
00132 else if (dim == 3)
00133 ((bnd_3_func_type) f_intbnd)(FORTRAN_ARGS(3,gdu),base::NEquations(),nc,
00134 idx,u[0].data(),xc[0].data(),distance,
00135 normal[0].data(),base::NAux(),aux,dx(),t);
00136 END_WATCH(GFM_SETBNDRY)
00137 }
00138 if (u) delete [] u;
00139 if (aux) delete [] aux;
00140 }
00141
00142 virtual void SetBndryAux(vec_grid_data_type& gdu, grid_data_type& gdphi, const BBox& bb,
00143 const VectorType* u, DataType* aux, const int& Level,
00144 double t, const int& nc, const int* idx,
00145 const point_type* xc, const DataType* distance,
00146 const point_type* normal) {
00147 if (f_intaux) {
00148 DCoords dx = base::GH().worldStep(gdu.stepsize());
00149 ((bndaux_func_type) f_intaux)(base::NEquations(),nc,u[0].data(),
00150 xc[0].data(),distance,normal[0].data(),
00151 base::NAux(),aux,dx(),t);
00152 }
00153 else
00154 for (register int i=0; i<nc*base::NAux(); i++)
00155 aux[i] = static_cast<DataType>(0.);
00156 }
00157
00158 inline void SetBndFunc(generic_func_type bnd) { f_intbnd = bnd; }
00159 generic_func_type GetBndFunc() const { return f_intbnd; }
00160 inline void SetTransFunc(generic_func_type trans) { f_inttrans = trans; }
00161 generic_func_type GetTransFunc() const { return f_inttrans; }
00162 inline void SetAuxFunc(generic_func_type aux) { f_intaux = aux; }
00163 generic_func_type GetAuxFunc() const { return f_intaux; }
00164
00165 protected:
00166 generic_func_type f_intbnd, f_inttrans, f_intaux;
00167 };
00168
00169 #endif