Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef AMROC_FIXUP_BASE_H 00002 #define AMROC_FIXUP_BASE_H 00003 00011 #include "GridFunction.h" 00012 #include "FixupBaseInterface.h" 00013 #include "Integrator.h" 00014 00015 #ifndef FixupBaseName 00016 #define FixupBase(dim) name2(FixupBase,dim) 00017 #define FixupBaseName 00018 #endif 00019 00027 template <class VectorType, class FixupType> 00028 class FixupBase(DIM) : 00029 public FixupBaseInterface(DIM)<VectorType,FixupType> { 00030 00031 typedef Integrator(DIM)<VectorType> integrator_type; 00032 typedef GridData(DIM)<VectorType> vec_grid_data_type; 00033 00034 typedef GridData(DIM_1)<VectorType> ld_vec_grid_data_type; 00035 typedef GridData(DIM_1)<FixupType> ld_fixup_grid_data_type; 00036 00037 typedef GridFunction(DIM)<VectorType> vec_grid_fct_type; 00038 typedef GridFunction(DIM_1)<FixupType> ld_fixup_grid_fct_type; 00039 00040 public: 00041 FixupBase(DIM)(integrator_type& integ) : _Integrator(integ), 00042 _FixupEquations(FixupType::Length()) { 00043 _Hierarchy = (GridHierarchy*) 0; 00044 _u = (vec_grid_fct_type *) 0; 00045 for (int d=0; d<DIM; d++) { 00046 _f[2*d] = (ld_fixup_grid_fct_type *) 0; 00047 _f[2*d+1] = (ld_fixup_grid_fct_type *) 0; 00048 _f_name[2*d] = (char *) 0; 00049 _f_name[2*d+1] = (char *) 0; 00050 } 00051 } 00052 00053 ~FixupBase(DIM)() { 00054 for (int d=0; d<DIM; d++) { 00055 // if (_f[2*d]) delete _f[2*d]; 00056 if (_f_name[2*d]) delete [] _f_name[2*d]; 00057 // if (_f[2*d+1]) delete _f[2*d+1]; 00058 if (_f_name[2*d+1]) delete [] _f_name[2*d+1]; 00059 } 00060 } 00061 00062 virtual void register_at(ControlDevice& Ctrl,const string& prefix) { 00063 LocCtrl = Ctrl.getSubDevice(prefix+"FixupBase"); 00064 } 00065 virtual void register_at(ControlDevice& Ctrl) { register_at(Ctrl,""); } 00066 virtual void init() {} 00067 virtual void update() {} 00068 virtual void finish() { 00069 for (int d=0; d<DIM; d++) { 00070 if (_f[2*d]) { 00071 delete _f[2*d]; 00072 _f[2*d] = (ld_fixup_grid_fct_type *) 0; 00073 } 00074 if (_f_name[2*d]) { 00075 delete [] _f_name[2*d]; 00076 _f_name[2*d] = (char *) 0; 00077 } 00078 if (_f[2*d+1]) { 00079 delete _f[2*d+1]; 00080 _f[2*d+1] = (ld_fixup_grid_fct_type *) 0; 00081 } 00082 if (_f_name[2*d+1]) { 00083 delete [] _f_name[2*d+1]; 00084 _f_name[2*d+1] = (char *) 0; 00085 } 00086 } 00087 } 00088 00089 void SetupData() { 00090 if (!_u) return; 00091 int t_sten = 0; 00092 int s_sten = 0; 00093 AllocError::SetTexts("FixupBase(DIM)","allocation of GridFunctions"); 00094 int DAGH_Base = DAGH_X; 00095 if (DIM == 2) DAGH_Base = DAGH_Y; 00096 if (DIM == 3) DAGH_Base = DAGH_YZ; 00097 00098 for (int d=0; d<DIM; d++) { 00099 _f_name[2*d] = new char[DAGHBktGFNameWidth]; 00100 sprintf(_f_name[2*d],"f_lower"); 00101 _f[2*d] = new ld_fixup_grid_fct_type(_f_name[2*d], t_sten, s_sten, GH(), 00102 DAGHCellCentered, 1, 1, DAGH_Base-d, 00103 DAGHNoComm, DAGHNoBoundary, 00104 DAGHNoAdaptBoundary, DAGHNoExternalGhost); 00105 SetProlongFlag(F(2*d), DAGHFalse); 00106 SetCheckpointFlag(F(2*d), DAGHFalse); 00107 00108 _f_name[2*d+1] = new char[DAGHBktGFNameWidth]; 00109 sprintf(_f_name[2*d+1],"f_upper"); 00110 _f[2*d+1] = new ld_fixup_grid_fct_type(_f_name[2*d+1], t_sten, s_sten, GH(), 00111 DAGHCellCentered, 1, 1, (DAGH_Base-d) | DAGH_Dim1ToTop, 00112 DAGHNoComm, DAGHNoBoundary, 00113 DAGHNoAdaptBoundary, DAGHNoExternalGhost); 00114 SetProlongFlag(F(2*d+1), DAGHFalse); 00115 SetCheckpointFlag(F(2*d+1), DAGHFalse); 00116 } 00117 00118 SetMaxRecomposeLevel(DAGHNull); 00119 } 00120 00121 void SetMaxRecomposeLevel(const int l) { 00122 for (int d=0; d<DIM; d++) { 00123 F(2*d).GF_SetMaxRecomposeLevel(l); 00124 F(2*d+1).GF_SetMaxRecomposeLevel(l); 00125 } 00126 } 00127 00128 inline void SetGridHierarchy(GridHierarchy* gh) { _Hierarchy = gh; } 00129 inline GridHierarchy& GH() { return *_Hierarchy; } 00130 inline const GridHierarchy& GH() const { return *_Hierarchy; } 00131 00132 inline void SetGridFunctions(vec_grid_fct_type* u) { _u = u; } 00133 inline vec_grid_fct_type& U() { return *_u; } 00134 inline const vec_grid_fct_type& U() const { return *_u; } 00135 00136 inline ld_fixup_grid_fct_type& F(int d) { 00137 #ifdef DEBUG_PRINT 00138 assert(d>=0 && d<2*DIM); 00139 #endif 00140 return *_f[d]; 00141 } 00142 00143 inline const ld_fixup_grid_fct_type& F(int d) const { 00144 #ifdef DEBUG_PRINT 00145 assert(d>=0 && d<2*DIM); 00146 #endif 00147 return *_f[d]; 00148 } 00149 00150 inline integrator_type& Integrator_() { return _Integrator; } 00151 inline const integrator_type& Integrator_() const { return _Integrator; } 00152 00153 inline const int& NEquations() { return _Integrator.NEquations(); } 00154 inline const int& NFixupEquations() { return _FixupEquations; } 00155 inline const int& NGhosts() const { return _Integrator.NGhosts(); } 00156 00157 protected: 00158 integrator_type& _Integrator; 00159 int _FixupEquations; 00160 GridHierarchy* _Hierarchy; 00161 vec_grid_fct_type* _u; 00162 ld_fixup_grid_fct_type* _f[2*DIM]; 00163 char *_f_name[2*DIM]; 00164 ControlDevice LocCtrl; 00165 }; 00166 00167 00168 void AlignBBox(BBox &bb, const int s) { 00169 int DAGH_Base = DAGH_X; 00170 if (DIM == 2) DAGH_Base = DAGH_Y; 00171 if (DIM == 3) DAGH_Base = DAGH_YZ; 00172 #ifdef DEBUG_PRINT 00173 assert (s>=0 && s<2*DIM); 00174 #endif 00175 if (s % 2 != 0) 00176 DAGH_Base = DAGH_Base | DAGH_Dim1ToTop; 00177 gdbAlignBBox(DIM_1, bb, DAGH_Base - s/2); 00178 bb.rank = DIM_1; 00179 bb.lower().rank = DIM_1; 00180 bb.upper().rank = DIM_1; 00181 bb.stepsize().rank = DIM_1; 00182 } 00183 00184 00185 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04