00001
00002
00003
00004
00005
00006 #ifndef SCHEME_GFMBOUNDARY_H
00007 #define SCHEME_GFMBOUNDARY_H
00008
00015 #include "GFMBoundary.h"
00016
00023 template <class SchemeType, int dim>
00024 class SchemeGFMBoundary : public GFMBoundary<typename SchemeType::VectorType,dim> {
00025 typedef GFMBoundary<typename SchemeType::VectorType,dim> base;
00026
00027 public:
00028 typedef typename SchemeType::VectorType VectorType;
00029 typedef typename VectorType::InternalDataType DataType;
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 public:
00037 SchemeGFMBoundary(SchemeType &scheme) : base(), _scheme(scheme), Type(0), Scaling(0) {}
00038
00039 virtual ~SchemeGFMBoundary() {}
00040
00041 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00042 base::register_at(Ctrl,prefix);
00043 RegisterAt(base::LocCtrl,"Type",Type);
00044 RegisterAt(base::LocCtrl,"Scaling",Scaling);
00045 }
00046
00047 virtual void SetupData(GridHierarchy* gh, const int& ghosts) {
00048 if (Type==0)
00049 base::_bndtype = EXTRAPOLATION;
00050 base::SetupData(gh, ghosts);
00051 }
00052
00053 virtual void SetGrid(vec_grid_data_type& gdu, grid_data_type& gdphi, const BBox& bb,
00054 const int& Level, double t, const int& nc,
00055 const int* idx, const point_type* xc,
00056 DataType* distance, point_type* normal) {
00057
00058 Coords ex = gdu.extents();
00059 VectorType* u = (VectorType*) 0;
00060 DataType* aux = (DataType*) 0;
00061 DCoords dx = base::GH().worldStep(gdu.stepsize());
00062 if (base::NAux()>0)
00063 aux = new DataType[nc*base::NAux()];
00064
00065 if (base::NormalFactor()>0) {
00066 if (UseTransform()) {
00067 vec_grid_data_type gdhelp(gdu.bbox());
00068 Transform(gdu,gdhelp);
00069 base::Extrapolation(gdhelp,gdphi,u,Level,nc,idx,xc,
00070 distance,normal,base::NormalFactor());
00071 if (base::NAux()>0) {
00072 START_WATCH
00073 SetBndryAux(gdhelp,gdphi,u,aux,Level,t,nc,idx,xc,distance,normal);
00074 END_WATCH(GFM_AUXILIARY_VALUES)
00075 }
00076 }
00077 else {
00078 base::Extrapolation(gdu,gdphi,u,Level,nc,idx,xc,
00079 distance,normal,base::NormalFactor());
00080 if (base::NAux()>0) {
00081 START_WATCH
00082 SetBndryAux(gdu,gdphi,u,aux,Level,t,nc,idx,xc,distance,normal);
00083 END_WATCH(GFM_AUXILIARY_VALUES)
00084 }
00085 }
00086 }
00087 else if (base::NAux()>0) {
00088 START_WATCH
00089 SetBndryAux(gdu,gdphi,u,aux,Level,t,nc,idx,xc,distance,normal);
00090 END_WATCH(GFM_AUXILIARY_VALUES)
00091 }
00092
00093 START_WATCH
00094 SetBndry(gdu,nc,idx,u,xc,distance,normal,aux,base::NAux(),t);
00095 END_WATCH(GFM_SETBNDRY)
00096
00097 if (u) delete [] u;
00098 if (aux) delete [] aux;
00099 }
00100
00101 virtual bool UseTransform()
00102 { return Scheme().GFMUseTransform(); }
00103
00104 virtual void Transform(vec_grid_data_type& gdu, vec_grid_data_type& gdhelp)
00105 { Scheme().GFMTransform(gdu,gdhelp); }
00106
00107 virtual void SetBndry(vec_grid_data_type& gdu, const int& nc, const int* idx,
00108 const VectorType* u, const point_type* xc, const DataType* distance,
00109 const point_type* normal, DataType* aux, const int naux, const double t)
00110 { Scheme().GFMBCStandard(gdu,Type,nc,idx,u,xc,distance,normal,aux,naux,Scaling); }
00111
00112 virtual void SetBndryAux(vec_grid_data_type& gdu, grid_data_type& gdphi,
00113 const VectorType* u, DataType* aux, const int& Level,
00114 double t, const int& nc, const int* idx,
00115 const point_type* xc, const DataType* distance,
00116 const point_type* normal) {}
00117
00118 inline SchemeType& Scheme() { return _scheme; }
00119 inline const SchemeType& Scheme() const { return _scheme; }
00120
00121 protected:
00122 SchemeType &_scheme;
00123 int Type, Scaling;
00124 };
00125
00126 #endif