00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _LEVELRK4_H__
00012 #define _LEVELRK4_H__
00013
00015
00056
00077 template <class TSoln, class TFR, class TOp>
00078 void RK4LevelAdvance(TSoln& a_newSoln,
00079 TSoln& a_oldSoln,
00080 const TSoln& a_oldCrseSoln,
00081 Real a_oldCrseTime,
00082 const TSoln& a_newCrseSoln,
00083 Real a_newCrseTime,
00084 TFR& a_crseFRPtr,
00085 TFR& a_fineFRPtr,
00086 Real a_time,
00087 Real a_dt,
00088 TOp& a_op)
00089 {
00090
00091
00092
00093 TSoln RHSTmp;
00094 TSoln solnTmp;
00095 a_op.defineRHSData(RHSTmp,a_oldSoln);
00096 a_op.defineSolnData(solnTmp,a_oldSoln);
00097 a_op.copySolnData(solnTmp,a_oldSoln);
00098
00099
00100 a_op.copySolnData(a_newSoln, a_oldSoln);
00101
00102
00103
00104
00105 a_op.evalRHS(RHSTmp,a_oldSoln,
00106 a_fineFRPtr,a_crseFRPtr,
00107 a_oldCrseSoln, a_oldCrseTime,
00108 a_newCrseSoln, a_newCrseTime,
00109 a_time,a_dt/6);
00110
00111
00112
00113
00114 a_op.updateODE(a_newSoln,RHSTmp,a_dt/6);
00115
00116
00117
00118 a_op.updateODE(solnTmp, RHSTmp,a_dt/2);
00119
00120
00121
00122 a_op.evalRHS(RHSTmp,solnTmp,
00123 a_fineFRPtr,a_crseFRPtr,
00124 a_oldCrseSoln, a_oldCrseTime,
00125 a_newCrseSoln, a_newCrseTime,
00126 a_time+a_dt/2,a_dt/3);
00127
00128
00129
00130 a_op.updateODE(a_newSoln,RHSTmp,a_dt/3);
00131
00132
00133 a_op.copySolnData(solnTmp,a_oldSoln);
00134 a_op.updateODE(solnTmp,RHSTmp,a_dt/2);
00135
00136
00137
00138 a_op.evalRHS(RHSTmp,solnTmp,
00139 a_fineFRPtr,a_crseFRPtr,
00140 a_oldCrseSoln, a_oldCrseTime,
00141 a_newCrseSoln, a_newCrseTime,
00142 a_time+a_dt/2,a_dt/3);
00143
00144
00145
00146
00147 a_op.updateODE(a_newSoln,RHSTmp,a_dt/3);
00148
00149
00150 a_op.copySolnData(solnTmp,a_oldSoln);
00151 a_op.updateODE(solnTmp,RHSTmp,a_dt);
00152
00153
00154
00155 a_op.evalRHS(RHSTmp,solnTmp,
00156 a_fineFRPtr,a_crseFRPtr,
00157 a_oldCrseSoln, a_oldCrseTime,
00158 a_newCrseSoln, a_newCrseTime,
00159 a_time+a_dt,a_dt/6);
00160
00161
00162
00163 a_op.updateODE(a_newSoln,RHSTmp,a_dt/6);
00164 }
00165
00166
00168
00222
00244 template <class TSoln, class TInterp, class TFR, class TOp>
00245 void RK4LevelAdvance(TSoln& a_newSoln,
00246 TSoln& a_oldSoln,
00247 TInterp& a_interpPtr,
00248 const TSoln& a_oldCrseSoln,
00249 Real a_oldCrseTime,
00250 const TSoln& a_newCrseSoln,
00251 Real a_newCrseTime,
00252 TFR& a_crseFRPtr,
00253 TFR& a_fineFRPtr,
00254 Real a_time,
00255 Real a_dt,
00256 TOp& a_op)
00257 {
00258
00259
00260
00261
00262 TSoln RHSTmp;
00263 TSoln solnTmp;
00264 a_op.defineRHSData(RHSTmp,a_oldSoln);
00265 a_op.defineSolnData(solnTmp,a_oldSoln);
00266 a_op.copySolnData(solnTmp,a_oldSoln);
00267
00268
00269 a_op.copySolnData(a_newSoln, a_oldSoln);
00270 a_interpPtr.setDt(a_dt);
00271 a_interpPtr.saveInitialSoln(a_oldSoln);
00272
00273
00274
00275
00276 a_op.evalRHS(RHSTmp,a_oldSoln,
00277 a_fineFRPtr,a_crseFRPtr,
00278 a_oldCrseSoln, a_oldCrseTime,
00279 a_newCrseSoln, a_newCrseTime,
00280 a_time,a_dt/6);
00281 a_interpPtr.saveRHS(RHSTmp);
00282
00283
00284
00285
00286 a_op.updateODE(a_newSoln,RHSTmp,a_dt/6);
00287
00288
00289
00290 a_op.updateODE(solnTmp, RHSTmp,a_dt/2);
00291
00292
00293
00294 a_op.evalRHS(RHSTmp,solnTmp,
00295 a_fineFRPtr,a_crseFRPtr,
00296 a_oldCrseSoln, a_oldCrseTime,
00297 a_newCrseSoln, a_newCrseTime,
00298 a_time+a_dt/2,a_dt/3);
00299 a_interpPtr.saveRHS(RHSTmp);
00300
00301
00302
00303 a_op.updateODE(a_newSoln,RHSTmp,a_dt/3);
00304
00305
00306 a_op.copySolnData(solnTmp,a_oldSoln);
00307 a_op.updateODE(solnTmp,RHSTmp,a_dt/2);
00308
00309
00310
00311 a_op.evalRHS(RHSTmp,solnTmp,
00312 a_fineFRPtr,a_crseFRPtr,
00313 a_oldCrseSoln, a_oldCrseTime,
00314 a_newCrseSoln, a_newCrseTime,
00315 a_time+a_dt/2,a_dt/3);
00316 a_interpPtr.saveRHS(RHSTmp);
00317
00318
00319
00320
00321 a_op.updateODE(a_newSoln,RHSTmp,a_dt/3);
00322
00323
00324 a_op.copySolnData(solnTmp,a_oldSoln);
00325 a_op.updateODE(solnTmp,RHSTmp,a_dt);
00326
00327
00328
00329 a_op.evalRHS(RHSTmp,solnTmp,
00330 a_fineFRPtr,a_crseFRPtr,
00331 a_oldCrseSoln, a_oldCrseTime,
00332 a_newCrseSoln, a_newCrseTime,
00333 a_time+a_dt,a_dt/6);
00334 a_interpPtr.saveRHS(RHSTmp);
00335
00336
00337
00338 a_op.updateODE(a_newSoln,RHSTmp,a_dt/6);
00339 }
00340
00341 #endif // end multiple-include preventer