00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_INTEGRATOR_H
00010 #define AMROC_INTEGRATOR_H
00011
00019 #include <iostream>
00020 #include <string>
00021 #include <cassert>
00022 #include <cstdio>
00023 #include "AMRBase.h"
00024
00031 template <class VectorType, int dim>
00032 class Integrator : public AMRBase<VectorType,dim> {
00033 typedef AMRBase<VectorType,dim> base;
00034 public:
00035 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00036 typedef typename base::vec_grid_data_type vec_grid_data_type;
00037
00038 Integrator() : base(), _MaxPass(0), _abort(DAGHFalse) {}
00039
00040 virtual ~Integrator() {}
00041
00042
00043
00044
00045 virtual double CalculateGrid(vec_grid_data_type& NewStateVec,
00046 vec_grid_data_type& OldStateVec,
00047 vec_grid_data_type* Flux[],
00048 const int& level,
00049 const double& t, const double& dt,
00050 const int& mpass) = 0;
00051 virtual void AllocGridFluxes(const BBox &bb, vec_grid_data_type**& Flux) = 0;
00052 virtual void DeAllocGridFluxes(vec_grid_data_type**& Flux) = 0;
00053 virtual void ResetGridFluxes(vec_grid_data_type**& Flux) = 0;
00054 virtual int ControlGrid(vec_grid_data_type& StateVec, const int& level,
00055 const BBox& where, const double& time, const int verbose) = 0;
00056 virtual int NMethodOrder() const = 0;
00057
00058
00059 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00060 base::LocCtrl = Ctrl.getSubDevice(prefix+"Integrator");
00061 }
00062 virtual void register_at(ControlDevice& Ctrl) {
00063 register_at(Ctrl, "");
00064 }
00065
00066 inline void SetMaxIntegratorPasses(int mp) { _MaxPass = mp; }
00067 inline const int& MaxIntegratorPasses() { return _MaxPass; }
00068
00069 inline const int& Abort() const { return _abort; }
00070 void CheckGrid(vec_grid_data_type& StateVec, const int& level,
00071 const BBox& where, const double& time, const char *text) {
00072 if (ControlGrid(StateVec, level, where, time, 1)==0 && _abort) {
00073 char Proc[32];
00074 #ifndef DAGH_NO_MPI
00075 std::sprintf(Proc,"On Processor %d: ",comm_service::proc_me());
00076 #else
00077 Proc[0] = '\0';
00078 #endif
00079 std::string ErrorText = "\n";
00080 ErrorText += Proc; ErrorText += " CheckGrid() at ";
00081 ErrorText += text; ErrorText += " not successful for ";
00082 std::cerr << ErrorText << StateVec.bbox()
00083 << "\nAborting program...\n" << std::flush;
00084 std::cout << ErrorText << StateVec.bbox()
00085 << "\nAborting program...\n" << std::flush;
00086 #ifdef DEBUG_PRINT
00087 ( comm_service::log() << ErrorText << StateVec.bbox()
00088 << "\nAborting programm...\n\n" ).flush();
00089 ( comm_service::log() << StateVec << "\n" ).flush();
00090 #endif
00091 assert(0);
00092 }
00093 }
00094
00095 inline void SetGridFunction(vec_grid_fct_type* u) { _u = u; }
00096 inline vec_grid_fct_type& U() { return *_u; }
00097 inline const vec_grid_fct_type& U() const { return *_u; }
00098
00099 protected:
00100 int _MaxPass;
00101 int _abort;
00102 vec_grid_fct_type *_u;
00103 };
00104
00105
00106 #endif