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


Main Page   Class Hierarchy   Compound List   File List  

TSSrcIntegrator.h

Go to the documentation of this file.
00001 #ifndef AMROC_TSSRCINTEGRATOR_H
00002 #define AMROC_TSSRCINTEGRATOR_H
00003 
00011 #include "ODEIntegrators/ODEIntegrator.h"
00012 #include "TSSrcIntegratorInterface.h"
00013 
00014 #ifndef TSSrcIntegratorName
00015 #define TSSrcIntegrator(dim)      name2(TSSrcIntegrator,dim)
00016 #define TSSrcIntegratorName
00017 #endif
00018 
00026 template <class VectorType>
00027 class TSSrcIntegrator(DIM) : public TSSrcIntegratorInterface(DIM)<VectorType> {
00028   typedef ODEIntegrator(DIM)<VectorType> ode_integrator_type;
00029   typedef GridDataFunction(DIM)<VectorType> grid_data_fct_type;
00030   typedef GridData(DIM)<VectorType> vec_grid_data_type;
00031 
00032 public:
00033   TSSrcIntegrator(DIM)(const int gh) : 
00034     _Equations(VectorType::Length()), _Ghosts(gh) {
00035     _Hierarchy = (GridHierarchy*) 0;
00036     _TimeIntegrator = (ode_integrator_type *)0;
00037     _SrcTerm = (grid_data_fct_type *)0;
00038   }
00039 
00040   virtual void register_at(ControlDevice& Ctrl,const string& prefix) {
00041     ControlDevice LocCtrl = Ctrl.getSubDevice(prefix+"TSSrcIntegrator");
00042    if (_TimeIntegrator)
00043       TimeIntegrator().register_at(LocCtrl,prefix);
00044    if (_TimeIntegrator)
00045       SrcTerm().register_at(LocCtrl,prefix);
00046   }
00047   virtual void register_at(ControlDevice& Ctrl) {
00048     register_at(Ctrl, "");
00049   }
00050 
00051   virtual void init() {
00052     if (_TimeIntegrator)
00053       TimeIntegrator().init();
00054     if (_SrcTerm)
00055       SrcTerm().init();
00056   }
00057 
00058   virtual void update() {
00059     if (_TimeIntegrator)
00060       TimeIntegrator().update();
00061     if (_SrcTerm)
00062       SrcTerm().update();
00063   }
00064 
00065   virtual void finish() {
00066     if (_TimeIntegrator)
00067       TimeIntegrator().finish();
00068     if (_SrcTerm)
00069       SrcTerm().finish();  
00070   } 
00071 
00072   virtual void SetupData() {
00073     if (_TimeIntegrator)
00074       TimeIntegrator().SetupData();
00075     if (_SrcTerm)
00076       SrcTerm().SetupData();     
00077   }
00078 
00079   inline void SetSrcTerm(grid_data_fct_type* src) { 
00080     _SrcTerm = src;
00081     if (_TimeIntegrator)
00082       TimeIntegrator().SetGridDataFct(src); 
00083   }
00084   inline grid_data_fct_type& SrcTerm() { return *_SrcTerm;  }
00085   inline const grid_data_fct_type& SrcTerm() const { return *_SrcTerm; }
00086 
00087   inline void SetTimeIntegrator(ode_integrator_type* integ) { _TimeIntegrator = integ; }
00088   inline ode_integrator_type& TimeIntegrator() { return *_TimeIntegrator; }
00089   inline const ode_integrator_type& TimeIntegrator() const { return *_TimeIntegrator; }
00090 
00091   inline void SetGridHierarchy(GridHierarchy* gh) { 
00092     _Hierarchy = gh; 
00093     if (_SrcTerm)
00094       SrcTerm().SetGridHierarchy(gh);
00095   }
00096   inline GridHierarchy& GH() { return *_Hierarchy; }
00097   inline const GridHierarchy& GH() const { return *_Hierarchy; }
00098 
00099   /* Before the transport step, the source term has to be updated 
00100      even on the ghost cells! Use bnd==1 for this.
00101      See CLAWPACK-Manual Note #5 "Source Terms".
00102      Otherwise the boundary conditions are not consistent with the
00103      solution anymore. */
00104 
00105   virtual void CalculateSrcOnGrid(vec_grid_data_type& StateVec, double t, 
00106                                   double dt, DCoords& dx, const int& bnd) {
00107     if (_TimeIntegrator && _SrcTerm) {
00108       BBox OpBox = StateVec.bbox();
00109       if (bnd == 0) 
00110         for (int d=0; d<DIM; d++) 
00111           if (OpBox.extents(d) > 2*NGhosts()) {
00112             OpBox.growlower(d,-NGhosts()); 
00113             OpBox.growupper(d,-NGhosts()); 
00114           }
00115       TimeIntegrator().IntegrateGrid(StateVec, OpBox, t, dt, dx);
00116     }
00117   }
00118 
00119   inline const int& NEquations() const { return _Equations; }
00120   inline const int& NGhosts() const { return _Ghosts; }
00121 
00122 protected:
00123   int _Equations;
00124   int _Ghosts;
00125   GridHierarchy* _Hierarchy;
00126   ode_integrator_type* _TimeIntegrator;
00127   grid_data_fct_type* _SrcTerm;
00128 };
00129 
00130 
00131 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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