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


Main Page   Class Hierarchy   Compound List   File List  

Integrator.h

Go to the documentation of this file.
00001 #ifndef AMROC_INTEGRATOR_H
00002 #define AMROC_INTEGRATOR_H
00003 
00011 #include "IntegratorInterface.h"
00012 #include "TSSrcIntegrator.h"
00013 
00014 #ifndef temporary_fluxes
00015 #define temporary_fluxes(f, u) { \
00016   vec_grid_data_type* (f)[2*DIM]; \
00017   register int name2(f,_CU) = 0; \
00018   for (; name2(f,_CU)<2*DIM; name2(f,_CU)++) { \
00019     (f)[name2(f,_CU)] = new vec_grid_data_type((u).bbox()); }
00020 #endif
00021 
00022 #ifndef end_temporary_fluxes
00023 #define end_temporary_fluxes(f) for (name2(f,_CU)=0; \
00024   name2(f,_CU)<2*DIM; name2(f,_CU)++) { \
00025     delete (f)[name2(f,_CU)]; } \
00026 } 
00027 #endif
00028 
00029 
00030 #ifndef IntegratorName
00031 #define Integrator(dim)      name2(Integrator,dim)
00032 #define IntegratorName
00033 #endif
00034 
00041 template <class VectorType>
00042 class Integrator(DIM) : public IntegratorInterface(DIM)<VectorType> {
00043   typedef GridData(DIM)<VectorType> vec_grid_data_type;
00044   typedef GridFunction(DIM)<VectorType> vec_grid_fct_type;  
00045   typedef TSSrcIntegrator(DIM)<VectorType> src_integrator_type;
00046 
00047 public:
00048   Integrator(DIM)(const int gh) : 
00049     _Equations(VectorType::Length()), _Ghosts(gh), _SrcTreatment(0) {    
00050     _Hierarchy = (GridHierarchy*) 0;
00051     _SrcIntegrator = (src_integrator_type *) 0;
00052     _abort = DAGHFalse;
00053   }
00054 
00055   virtual void register_at(ControlDevice& Ctrl,const string& prefix) {
00056     ControlDevice LocCtrl = Ctrl.getSubDevice(prefix+"Integrator");
00057     if (_SrcIntegrator)
00058       SrcIntegrator().register_at(LocCtrl,prefix);
00059   }
00060   virtual void register_at(ControlDevice& Ctrl) {
00061     register_at(Ctrl, "");
00062   }
00063 
00064   virtual void init() {
00065     if (_SrcIntegrator)
00066       SrcIntegrator().init();
00067   }
00068   virtual void update() {
00069     if (_SrcIntegrator)
00070       SrcIntegrator().update();
00071   }
00072   virtual void finish() {
00073     if (_SrcIntegrator)
00074       SrcIntegrator().finish();
00075   } 
00076 
00077   virtual void SetupData() {
00078     if (_SrcIntegrator)
00079       SrcIntegrator().SetupData();
00080   }
00081    
00082   inline void SetGridHierarchy(GridHierarchy* gh) { 
00083     _Hierarchy = gh; 
00084     if (_SrcIntegrator)
00085       SrcIntegrator().SetGridHierarchy(gh);
00086   }
00087   inline GridHierarchy& GH() { return *_Hierarchy; }
00088   inline const GridHierarchy& GH() const { return *_Hierarchy; }
00089 
00090   inline void SetSrcIntegrator(src_integrator_type* src_integ) 
00091     { _SrcIntegrator = src_integ; }
00092   inline src_integrator_type& SrcIntegrator() { return *_SrcIntegrator; }
00093   inline const src_integrator_type& SrcIntegrator() const { return *_SrcIntegrator; }
00094   inline void SetSrcTreatment(int st) { _SrcTreatment = st; }
00095   inline const int& SrcTreatment() { return _SrcTreatment; }
00096   inline void SetMaxIntegratorPasses(int mp) { _MaxPass = mp; }
00097   inline const int& MaxIntegratorPasses() { return _MaxPass; }
00098 
00099   inline const int& Abort() const { return _abort; }
00100   void CheckGrid(vec_grid_data_type& StateVec, const BBox& where, const char *text) {
00101     if (!ControlGrid(StateVec, where) && _abort) {
00102       char Proc[32];
00103 #ifndef DAGH_NO_MPI
00104       sprintf(Proc,"On Processor %d: ",comm_service::proc_me());
00105 #else
00106       Proc[0] = '\0';
00107 #endif 
00108       string ErrorText = "\n";
00109       ErrorText += Proc; ErrorText += " CheckGrid() at ";
00110       ErrorText += text; ErrorText += " not successful for ";
00111       cerr << ErrorText << StateVec.bbox() << "\nAborting programm...\n" << flush;
00112       cout << ErrorText << StateVec.bbox() << "\nAborting programm...\n" << flush;
00113 #ifdef DEBUG_PRINT
00114       ( comm_service::log() << ErrorText << StateVec.bbox() 
00115         << "\nAborting programm...\n\n" ).flush();
00116       ( comm_service::log() << StateVec << "\n" ).flush();     
00117 #endif
00118       assert(0);
00119     } 
00120   }
00121 
00122   inline const int& NEquations() const { return _Equations; }
00123   inline const int& NGhosts() const { return _Ghosts; }
00124 
00125 protected:
00126   int _Equations;
00127   int _Ghosts;
00128   int _SrcTreatment;
00129   int _MaxPass;
00130   int _abort;
00131   GridHierarchy* _Hierarchy;
00132   vec_grid_fct_type* _u;
00133   src_integrator_type* _SrcIntegrator;
00134 };
00135 
00136 
00137 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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