Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef AMROC_CLP_INTEGRATOR1_H 00002 #define AMROC_CLP_INTEGRATOR1_H 00003 00011 #include "ClpIntegratorBase.h" 00012 00013 #ifndef ClpIntegratorName 00014 #define ClpIntegrator(dim) name2(ClpIntegrator,dim) 00015 #define ClpIntegratorName 00016 #endif 00017 00028 template <class VectorType, class AuxVectorType> 00029 class ClpIntegrator(1) : public ClpIntegratorBase(1)<VectorType,AuxVectorType> { 00030 typedef typename VectorType::InternalDataType DataType; 00031 typedef ClpIntegratorBase(1)<VectorType,AuxVectorType> base_type; 00032 typedef GridData(1)<VectorType> vec_grid_data_type; 00033 typedef GridFunction(1)<VectorType> vec_grid_fct_type; 00034 typedef GridData(DIM_1)<VectorType> ld_vec_grid_data_type; 00035 typedef GridData(DIM_1)<AuxVectorType> ld_aux_grid_data_type; 00036 00037 public: 00038 ClpIntegrator(1)(const int equ, const int wv, const int gh) : 00039 base_type(equ, wv, gh) {} 00040 00041 //------------------------------------------------------------------ 00042 // Solve Riemann problems. Copy left and right data into appropriate 00043 // format for normal_flux_func(). Note that left state has to shifted 00044 // one element. This is done in copySlice(). 00045 //------------------------------------------------------------------ 00046 virtual void ComputeRP(ld_vec_grid_data_type& LeftState, ld_aux_grid_data_type& auxl, 00047 ld_vec_grid_data_type& RightState, ld_aux_grid_data_type& auxr, 00048 ld_vec_grid_data_type& NewState, const int& direction) { 00049 00050 AllocError::SetTexts("ClpIntegrator(1)","calculate_Riemann_Problem(): work"); 00051 Coords ex = LeftState.extents(); 00052 int maxm = LeftState.extents(0) + 1; 00053 int nghosts = 0; 00054 DataType* wave = new DataType[maxm*NEqUsed()*NWaves()]; 00055 DataType* s = new DataType[maxm*NWaves()]; 00056 DataType* LeftStateSl = new DataType[maxm*NEqUsed()]; 00057 DataType* RightStateSl = new DataType[maxm*NEqUsed()]; 00058 DataType* auxlSl = new DataType[maxm*NAux()]; 00059 DataType* auxrSl = new DataType[maxm*NAux()]; 00060 00061 AllocError::SetTexts("ClpIntegrator(1)","calculate_Riemann_Problem(): fluctuations"); 00062 DataType* apdqSl = new DataType[(NewState.bbox().size()+1)*NEqUsed()]; 00063 DataType* amdqSl = new DataType[(NewState.bbox().size()+1)*NEqUsed()]; 00064 00065 copySlice(LeftStateSl, LeftState, NEqUsed(), 1); 00066 copySlice(RightStateSl, RightState, NEqUsed(), 0); 00067 00068 copyAuxSlice(auxlSl, auxl, NAux(), 1); 00069 copyAuxSlice(auxrSl, auxr, NAux(), 0); 00070 00071 (*normal_flux_func)(maxm, NEqUsed(), NWaves(), nghosts, maxm, 00072 LeftStateSl, RightStateSl, 00073 NAux(), auxlSl, auxrSl, wave, s, amdqSl, apdqSl); 00074 00075 addSlices(NewState, apdqSl, amdqSl, NEqUsed(), 1); 00076 00077 delete [] LeftStateSl; delete [] RightStateSl; 00078 delete [] auxlSl; delete [] auxrSl; 00079 delete [] apdqSl; delete [] amdqSl; 00080 delete [] wave; 00081 delete [] s; 00082 } 00083 00084 virtual double ComputeGrid(vec_grid_data_type& StateVec, 00085 vec_grid_data_type* Flux[], DataType* aux, 00086 double dt, DCoords& dx) { 00087 00088 AllocError::SetTexts("ClpIntegrator(1)","calculate_time_step(): work"); 00089 Coords ex = StateVec.extents(); 00090 int mx = ex(0)-2*NGhosts(); 00091 int msl = 0; 00092 #ifdef EXTENDED_INTEGRATOR 00093 msl = 4; 00094 #endif 00095 int mwork = (mx + 2*NGhosts()) * ((NEqUsed()+1)*NWaves() + (3+msl)*NEqUsed()+ NAux() + 1); 00096 DataType* work = new DataType[mwork]; 00097 00098 int wave = 0; 00099 int s = wave + (mx+2*NGhosts())*NEqUsed()*NWaves(); 00100 int amdq = s + (mx+2*NGhosts())*NWaves(); 00101 int apdq = amdq + (mx+2*NGhosts())*NEqUsed(); 00102 int dtdx = apdq + (mx+2*NGhosts())*NEqUsed(); 00103 int aux1 = dtdx + (mx+2*NGhosts()); 00104 int q1 = aux1 + (mx+2*NGhosts())*NAux(); 00105 int next = q1 + (mx+2*NGhosts())*NEqUsed(); 00106 int mwork1 = mwork - next; 00107 double cfl = 0.0; 00108 00109 // The ghostcells must remain untouched during integration! 00110 f_step(mx,NEquations(),NEqUsed(), 00111 NAux(),NWaves(),NGhosts(),mx, 00112 StateVec.data(), 00113 aux,dx(0),dt,method,mthlim,cfl, 00114 Flux[0]->data(),Flux[1]->data(), 00115 &(work[wave]),&(work[s]), 00116 &(work[amdq]),&(work[apdq]), 00117 &(work[dtdx]),&(work[aux1]),&(work[q1]), 00118 &(work[next]),mwork1, 00119 normal_flux_func); 00120 00121 delete [] work; 00122 return cfl; 00123 } 00124 00125 private: 00126 void copySlice(DataType* target, const ld_vec_grid_data_type &source, 00127 const int meqn, const int move) { 00128 const BBox& bbox = source.bbox(); 00129 for (int m=0; m<meqn; m++) { 00130 if (move) target++; 00131 BeginFastIndex1(tgt, bbox, target, DataType); 00132 for_1 (k, bbox, bbox.stepsize()) 00133 FastIndex1(tgt, k) = source(k)(m); 00134 end_for 00135 EndFastIndex1(tgt); 00136 if (!move) target++; 00137 target = &(target[bbox.size()]); 00138 } 00139 } 00140 00141 void copyAuxSlice(DataType* target, const ld_aux_grid_data_type &source, 00142 const int meqn, const int move) { 00143 const BBox& bbox = source.bbox(); 00144 for (int m=0; m<meqn; m++) { 00145 if (move) target++; 00146 BeginFastIndex1(tgt, bbox, target, DataType); 00147 for_1 (k, bbox, bbox.stepsize()) 00148 FastIndex1(tgt, k) = source(k)(m); 00149 end_for 00150 EndFastIndex1(tgt); 00151 if (!move) target++; 00152 target = &(target[bbox.size()]); 00153 } 00154 } 00155 00156 void addSlices(ld_vec_grid_data_type &target, 00157 DataType* source1, DataType* source2, 00158 const int meqn, const int move) { 00159 const BBox& bbox = target.bbox(); 00160 for (int m=0; m<meqn; m++) { 00161 if (move) { source1++; source2++; } 00162 BeginFastIndex1(src1, bbox, source1, const DataType); 00163 BeginFastIndex1(src2, bbox, source2, const DataType); 00164 for_1 (k, bbox, bbox.stepsize()) 00165 target(k)(m) = FastIndex1(src1, k) + FastIndex1(src2, k); 00166 end_for 00167 EndFastIndex1(src1); 00168 EndFastIndex1(src2); 00169 if (!move) { source1++; source2++; } 00170 source1 = &(source1[bbox.size()]); 00171 source2 = &(source2[bbox.size()]); 00172 } 00173 } 00174 }; 00175 00176 00177 00178 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04