AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

Flagging.h

Go to the documentation of this file.
00001 #ifndef AMROC_FLAGGING_H
00002 #define AMROC_FLAGGING_H
00003 
00011 #include "FlaggingInterface.h"
00012 #include "Integrator.h"
00013 
00014 #define GoodPoint (0)
00015 #define BadPoint  (1)
00016 #define VizServer 0                                               
00017 
00018 #ifndef FlaggingName
00019 #define Flagging(dim)      name2(Flagging,dim)
00020 #define FlaggingName
00021 #endif
00022 
00023 #ifndef SolverName
00024 #define Solver(dim)      name2(Solver,dim)
00025 #define SolverName
00026 #endif
00027 
00028 template <class VectorType, class FixupType, class FlagType>
00029 class Solver(DIM);
00030 
00038 template <class VectorType, class FixupType, class FlagType>
00039 class Flagging(DIM) : public FlaggingInterface(DIM)<VectorType,FlagType> {
00040   typedef Solver(DIM)<VectorType,FixupType,FlagType> solver_type;
00041 
00042   typedef GridFunction(DIM)<VectorType> vec_grid_fct_type;  
00043   typedef GridFunction(DIM)<typename VectorType::InternalDataType>   grid_fct_type;
00044   typedef GridFunction(DIM)<FlagType> flag_fct_type; 
00045 
00046 public:
00047   typedef Integrator(DIM)<VectorType> integrator_type;
00048 
00049   Flagging(DIM)(solver_type& solver) : _Solver(solver), _EstimateError(false) {    
00050     _Hierarchy = (GridHierarchy*) 0;
00051     _u = (vec_grid_fct_type *) 0;
00052     _u_sh = (vec_grid_fct_type *) 0;
00053     _work = (grid_fct_type *) 0;
00054     _work_sh = (grid_fct_type *) 0;
00055     _flag = (flag_fct_type *) 0; 
00056   }
00057 
00058   ~Flagging(DIM)() {
00059     if (_flag)
00060       delete _flag;
00061   }
00062 
00063   virtual void register_at(ControlDevice& Ctrl) {}
00064   virtual void register_at(ControlDevice& Ctrl,const string& prefix) {
00065     LocCtrl = Ctrl.getSubDevice(prefix+"Flagging");
00066   }
00067   virtual void init() {}
00068   virtual void update() {}
00069   virtual void finish() {
00070     if (_flag) {
00071       delete _flag;
00072       _flag = (flag_fct_type *) 0; 
00073     }
00074   } 
00075 
00076   void SetBufferwidth(const int buffw) { _Bufferwidth = buffw; }
00077   inline const int& Bufferwidth() const { return _Bufferwidth; }
00078   inline int Bufferwidth() { return _Bufferwidth; }
00079 
00080   void SetupData() {
00081     int t_sten = 0;            
00082     int s_sten = Bufferwidth(); 
00083     sprintf(flagName,"FlagPlaceholder");
00084     _flag = new flag_fct_type(flagName, t_sten, s_sten, GH(), DAGHCommSimple);
00085     SetCheckpointFlag(*_flag, DAGHFalse);   
00086     SetProlongFlag(*_flag, DAGHFalse);   
00087     _flag->GF_SetMaxRecomposeLevel(DAGHNull);
00088   }    
00089 
00090   void FlagLevel(const int Time, const int Level, double t, double dt) {
00091     forall (Flags(),Time,Level,c)  
00092       Flags()(Time,Level,c) = GoodPoint;
00093     end_forall    
00094     SetFlags(Time, Level, t, dt);
00095   }   
00096 
00097   inline void SetGridHierarchy(GridHierarchy* gh) { _Hierarchy = gh; }
00098   inline GridHierarchy& GH() { return *_Hierarchy; }
00099   inline const GridHierarchy& GH() const { return *_Hierarchy; }
00100 
00101   inline void SetGridFunctions(vec_grid_fct_type* u, vec_grid_fct_type* ush, 
00102                                grid_fct_type* work, grid_fct_type* worksh) {
00103     _u = u; _u_sh = ush;
00104     _work = work; _work_sh = worksh; 
00105   }
00106   inline vec_grid_fct_type& U() { return *_u; }
00107   inline const vec_grid_fct_type& U() const { return *_u; }
00108   inline vec_grid_fct_type& Ush() { return *_u_sh; }
00109   inline const vec_grid_fct_type& Ush() const { return *_u_sh; }
00110   inline grid_fct_type& Work() { return *_work; }
00111   inline const grid_fct_type& Work() const { return *_work; }
00112   inline flag_fct_type& Flags() { return *_flag; }
00113   inline grid_fct_type& Worksh() { return *_work_sh; }
00114   inline const grid_fct_type& Worksh() const { return *_work_sh; }
00115   inline const flag_fct_type& Flags() const { return *_flag; }
00116   inline const bool& ErrorEstimation() const { return _EstimateError;}
00117   void SetErrorEstimation(const bool est) { _EstimateError = est; }
00118 
00119   inline solver_type& Solver_() { return _Solver; }
00120   inline const solver_type& Solver_() const { return _Solver; }
00121   inline integrator_type& Integrator_() { return Solver_().Integrator_(); }
00122   inline const integrator_type& Integrator_() const { return Solver_().Integrator_(); }
00123 
00124   inline const int& NEquations() const { return Integrator_().NEquations(); }
00125   inline const int& NGhosts() const { return Integrator_().NGhosts(); }
00126 
00127 protected:
00128   solver_type& _Solver;
00129   GridHierarchy* _Hierarchy;
00130   vec_grid_fct_type *_u, *_u_sh;
00131   grid_fct_type *_work, *_work_sh;
00132   flag_fct_type* _flag;
00133   char flagName[DAGHBktGFNameWidth];
00134   int _Bufferwidth;
00135   bool _EstimateError;
00136   ControlDevice LocCtrl;
00137 };
00138 
00139 
00140 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04