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


Main Page   Class Hierarchy   Compound List   File List  

Solver.h

Go to the documentation of this file.
00001 #ifndef AMROC_SOLVER_H
00002 #define AMROC_SOLVER_H
00003 
00011 #include "Integrator.h"
00012 #include "InitialCondition.h"
00013 #include "BoundaryConditions.h"
00014 #include "SolverInterface.h"
00015 #include "Flagging.h"
00016 
00017 #if DIM == 1
00018 #   include "Fixup1.h"  
00019 #   include "VectorGridData1Ops.h"
00020 #elif DIM == 2
00021 #   include "Fixup2.h"  
00022 #   include "VectorGridData2Ops.h"
00023 #elif DIM == 3  
00024 #   include "Fixup3.h"
00025 #   include "VectorGridData3Ops.h"
00026 #endif
00027 
00028 
00029 #define FixedTimeSteps               (0)
00030 #define AutomaticTimeStepsNoRestart  (1)
00031 #define AutomaticTimeStepsRestart    (2)
00032 
00033 
00034 #ifndef SolverName
00035 #define Solver(dim)      name2(Solver,dim)
00036 #define SolverName
00037 #endif
00038 
00045 template <class VectorType, class FixupType, class FlagType>
00046 class Solver(DIM) : public SolverInterface(DIM)<VectorType> {
00047   typedef typename VectorType::InternalDataType DataType;
00048   typedef GridFunction(DIM)<VectorType> vec_grid_fct_type;  
00049   typedef GridFunction(DIM)<DataType>   grid_fct_type;
00050 
00051   typedef Integrator(DIM)<VectorType> integrator_type;
00052   typedef InitialCondition(DIM)<VectorType> initial_condition_type;
00053   typedef BoundaryConditions(DIM)<VectorType> boundary_conditions_type;
00054   typedef Flagging(DIM)<VectorType, FixupType, FlagType> flagging_type;
00055   typedef Fixup(DIM)<VectorType, FixupType> fixup_type;
00056 
00057 public:
00058   Solver(DIM)(integrator_type& integ, 
00059               initial_condition_type& init,
00060               boundary_conditions_type& bc) : 
00061     _Integrator(integ), _InitialCondition(init), _BoundaryConditions(bc) {
00062     _Hierarchy = (GridHierarchy*) 0;
00063     _u = (vec_grid_fct_type *) 0;
00064     _u_sh = (vec_grid_fct_type *) 0;
00065     _work = (grid_fct_type *) 0;
00066     _work_sh = (grid_fct_type *) 0;
00067     _Flagging = (flagging_type *) 0;
00068     _Fixup = (fixup_type *) 0;
00069     _LastOutputTime = -1;
00070   }
00071 
00072   virtual void register_at(ControlDevice& Ctrl,const string& prefix) {
00073     LocCtrl = Ctrl.getSubDevice(prefix+"Solver");    
00074     _Integrator.register_at(LocCtrl,prefix);
00075     _InitialCondition.register_at(LocCtrl,prefix);
00076     _BoundaryConditions.register_at(LocCtrl,prefix);
00077     if (_Flagging)
00078       _Flagging->register_at(LocCtrl,prefix);
00079     if (_Fixup)
00080       _Fixup->register_at(LocCtrl,prefix);
00081   }
00082   virtual void register_at(ControlDevice& Ctrl) {
00083     register_at(Ctrl, "");
00084   }
00085 
00086   virtual void init() {
00087     _Integrator.init();
00088     _InitialCondition.init();
00089     _BoundaryConditions.init();
00090     if (_Flagging)
00091       _Flagging->init();
00092     if (_Fixup)
00093       _Fixup->init();
00094   }
00095   virtual void update() {
00096     _Integrator.update();
00097     _InitialCondition.update();
00098     _BoundaryConditions.update();
00099     if (_Flagging)
00100       _Flagging->update();
00101     if (_Fixup)
00102       _Fixup->update();
00103   }
00104   virtual void finish() {
00105     _Integrator.finish();
00106     _InitialCondition.finish();
00107     _BoundaryConditions.finish();
00108     if (_Flagging)
00109       _Flagging->finish();
00110     if (_Fixup)
00111       _Fixup->finish();
00112   } 
00113 
00114   virtual void SetupData() {
00115     Integrator_().SetupData();
00116     if (_Flagging) 
00117       Flagging_().SetupData();
00118     if (_Fixup)
00119       Fixup_().SetupData();
00120   }
00121 
00122   inline void SetBoundaryConditions() { 
00123     BoundaryConditions_().Set(*_u); 
00124     if (_u_sh) 
00125       BoundaryConditions_().Set(*_u_sh);
00126   }
00127 
00128   void SetGridHierarchy(GridHierarchy* gh) { 
00129     _Integrator.SetGridHierarchy(gh);
00130     _InitialCondition.SetGridHierarchy(gh);
00131     _BoundaryConditions.SetGridHierarchy(gh);
00132     if (_Flagging)
00133       _Flagging->SetGridHierarchy(gh);
00134     if (_Fixup)
00135       _Fixup->SetGridHierarchy(gh);
00136     _Hierarchy = gh; 
00137   }
00138   inline GridHierarchy& GH() { return *_Hierarchy; }
00139   inline const GridHierarchy& GH() const { return *_Hierarchy; }
00140 
00141   void SetGridFunctions(vec_grid_fct_type* u, vec_grid_fct_type* ush,
00142                         grid_fct_type* work, grid_fct_type* worksh) {
00143     if (_Flagging) 
00144       _Flagging->SetGridFunctions(u, ush, work, worksh);
00145     if (_Fixup) 
00146       _Fixup->SetGridFunctions(u);
00147     _u = u; _u_sh = ush;
00148     _work = work; _work_sh = worksh; 
00149   }
00150   inline vec_grid_fct_type& U() { return *_u; }
00151   inline const vec_grid_fct_type& U() const { return *_u; }
00152   inline vec_grid_fct_type& Ush() { return *_u_sh; }
00153   inline const vec_grid_fct_type& Ush() const { return *_u_sh; }
00154   inline grid_fct_type& Work() { return *_work; }
00155   inline const grid_fct_type& Work() const { return *_work; }
00156   inline grid_fct_type& Worksh() { return *_work_sh; }
00157   inline const grid_fct_type& Worksh() const { return *_work_sh; }
00158 
00159   inline initial_condition_type& InitialCondition_() 
00160     { return _InitialCondition; }
00161   inline const initial_condition_type& InitialCondition_() const 
00162     { return _InitialCondition; }
00163 
00164   inline boundary_conditions_type& BoundaryConditions_() 
00165     { return _BoundaryConditions; }
00166   inline const boundary_conditions_type& BoundaryConditions_() const 
00167     { return _BoundaryConditions; }
00168 
00169   inline integrator_type& Integrator_() { return _Integrator; }
00170   inline const integrator_type& Integrator_() const { return _Integrator; }
00171 
00172   inline void SetFlagging(flagging_type* _flagging) { _Flagging = _flagging; }
00173   inline flagging_type& Flagging_() { return *_Flagging; }
00174   inline const flagging_type& Flagging_() const { return *_Flagging; }
00175   inline const bool& ErrorEstimation() const { return Flagging_().ErrorEstimation();}
00176 
00177   inline void SetFixup(fixup_type* _fixup) { _Fixup = _fixup; }
00178   inline fixup_type& Fixup_() { return *_Fixup; }
00179   inline const fixup_type& Fixup_() const { return *_Fixup; }
00180 
00181   inline const int& NEquations() const { return _Integrator.NEquations(); }
00182   inline const int& NGhosts() const { return _Integrator.NGhosts(); }
00183 
00184   inline void SetLastOutputTime(int Time) { _LastOutputTime = Time; }
00185   inline int LastOutputTime() const { return _LastOutputTime; }
00186 
00187 protected:
00188   integrator_type& _Integrator;
00189   initial_condition_type& _InitialCondition;
00190   boundary_conditions_type& _BoundaryConditions;
00191   GridHierarchy* _Hierarchy;
00192   vec_grid_fct_type *_u, *_u_sh;
00193   grid_fct_type *_work, *_work_sh;
00194   flagging_type* _Flagging;
00195   fixup_type* _Fixup;
00196   ControlDevice LocCtrl;
00197   int _LastOutputTime;
00198 };
00199 
00200 
00201 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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