00001
00002
00003
00004
00005
00006 #ifndef AMROC_COUPLED_GFMSOLVER_H
00007 #define AMROC_COUPLED_GFMSOLVER_H
00008
00016 #include "AMRGFMSolver.h"
00017
00024 template <class VectorType, class FixupType, class FlagType, int dim>
00025 class AMRCoupledGFMSolver : public AMRGFMSolver<VectorType,FixupType,FlagType,dim> {
00026 typedef typename VectorType::InternalDataType DataType;
00027 typedef AMRGFMSolver<VectorType,FixupType,FlagType,dim> base;
00028
00029 public:
00030 typedef typename base::integrator_type integrator_type;
00031 typedef typename base::initial_condition_type initial_condition_type;
00032 typedef typename base::boundary_conditions_type boundary_conditions_type;
00033 typedef typename base::vec_grid_fct_type vec_grid_fct_type;
00034
00035 AMRCoupledGFMSolver(integrator_type& integ,
00036 initial_condition_type& init,
00037 boundary_conditions_type& bc) : base(integ, init, bc) {
00038 CouplingLevel = 0;
00039 _SubSteps = 1;
00040 }
00041
00042 virtual ~AMRCoupledGFMSolver() {}
00043
00044
00045
00046
00047 virtual void ReceiveBoundaryData(bool FullDomain=false) = 0;
00048 virtual void SendBoundaryData() = 0;
00049
00050
00051 virtual void register_at(ControlDevice& Ctrl, const std::string& prefix) {
00052 base::register_at(Ctrl,prefix);
00053 RegisterAt(base::LocCtrl,"CouplingLevel",CouplingLevel);
00054 }
00055 virtual void register_at(ControlDevice& Ctrl) {
00056 base::register_at(Ctrl);
00057 }
00058
00059 virtual bool setup() {
00060 bool ret = base::setup();
00061 if (CouplingLevel>base::MaxLev-1)
00062 CouplingLevel=base::MaxLev-1;
00063 _SubSteps = 1;
00064 for (register int n=0; n<CouplingLevel; n++)
00065 _SubSteps *= base::_RefineFactor[n];
00066 return ret;
00067 }
00068
00069 virtual void SetupData() {
00070 base::SetupData();
00071 #ifdef DEBUG_PRINT_AMRSOLVER
00072 ( comm_service::log() << "*** base::SetupData() finished.\n" ).flush();
00073 #endif
00074 }
00075
00076 virtual void Initialize(double& t, double &dt) {
00077 #ifdef DEBUG_PRINT_AMRSOLVER
00078 ( comm_service::log() << "*** AMRCoupledGFMSolver::Initialize().\n" ).flush();
00079 #endif
00080 if (CouplingLevel>=0)
00081 ReceiveBoundaryData(true);
00082 #ifdef DEBUG_PRINT_AMRSOLVER
00083 ( comm_service::log() << "*** ReceiveBoundaryData() done.\n" ).flush();
00084 #endif
00085 base::Initialize(t,dt);
00086 #ifdef DEBUG_PRINT_AMRSOLVER
00087 ( comm_service::log() << "*** base::Initialize() finished.\n" ).flush();
00088 #endif
00089 if (CouplingLevel>=0)
00090 SendBoundaryData();
00091 }
00092
00093 virtual void Restart(double& t, double& dt) {
00094 #ifdef DEBUG_PRINT_AMRSOLVER
00095 ( comm_service::log() << "*** AMRCoupledGFMSolver::Restart().\n" ).flush();
00096 #endif
00097 if (CouplingLevel>=0)
00098 ReceiveBoundaryData(true);
00099 #ifdef DEBUG_PRINT_AMRSOLVER
00100 ( comm_service::log() << "*** ReceiveBoundaryData() done.\n" ).flush();
00101 #endif
00102 base::Restart(t,dt);
00103 #ifdef DEBUG_PRINT_AMRSOLVER
00104 ( comm_service::log() << "*** base::Restart() finished.\n" ).flush();
00105 #endif
00106 if (CouplingLevel>=0)
00107 SendBoundaryData();
00108 }
00109
00110 virtual void Advance(double& t, double &dt) {
00111 #ifdef DEBUG_PRINT_AMRSOLVER
00112 ( comm_service::log() << "*** AMRCoupledGFMSolver::Advance().\n" ).flush();
00113 #endif
00114 if (CouplingLevel>=0)
00115 ReceiveBoundaryData(true);
00116 #ifdef DEBUG_PRINT_AMRSOLVER
00117 ( comm_service::log() << "*** ReceiveBoundaryData() done.\n" ).flush();
00118 #endif
00119 base::Advance(t,dt);
00120 #ifdef DEBUG_PRINT_AMRSOLVER
00121 ( comm_service::log() << "*** base::Advance() finished.\n" ).flush();
00122 #endif
00123 }
00124
00125 virtual void AfterLevelStep(const int Level) {
00126 if (Level!=CouplingLevel) return;
00127 SendBoundaryData();
00128 if (CouplingLevel>0 && CurrentTime(base::GH(),Level)<
00129 CurrentTime(base::GH(),0)+TimeStep(base::U(),0)) {
00130 if (base::RedistributeEvery>0)
00131 ReceiveBoundaryData(false);
00132 else
00133 ReceiveBoundaryData(true);
00134 #ifdef DEBUG_PRINT_AMRSOLVER
00135 ( comm_service::log() << "*** ReceiveBoundaryData() on level "
00136 << Level << " done.\n" ).flush();
00137 #endif
00138 }
00139 }
00140
00141 const int& SubSteps() const { return _SubSteps; }
00142
00143 protected:
00144 int CouplingLevel, _SubSteps;
00145 };
00146
00147
00148 #endif