00001 #ifdef CH_LANG_CC 00002 /* 00003 * _______ __ 00004 * / ___/ / ___ __ _ / / ___ 00005 * / /__/ _ \/ _ \/ V \/ _ \/ _ \ 00006 * \___/_//_/\___/_/_/_/_.__/\___/ 00007 * Please refer to Copyright.txt, in Chombo's root directory. 00008 */ 00009 #endif 00010 00011 #ifndef _EBLEVELTGA_H_ 00012 #define _EBLEVELTGA_H_ 00013 00014 #include <iostream> 00015 #include <math.h> 00016 #include "SPACE.H" 00017 #include <stdlib.h> 00018 #include "REAL.H" 00019 #include "Box.H" 00020 #include "DisjointBoxLayout.H" 00021 #include "LevelData.H" 00022 #include "EBCellFAB.H" 00023 #include "EBLevelGrid.H" 00024 #include "EBFluxFAB.H" 00025 #include "EBFluxRegister.H" 00026 #include "ProblemDomain.H" 00027 #include "BaseLevelTGA.H" 00028 #include "BaseLevelBackwardEuler.H" 00029 #include "BaseLevelCrankNicolson.H" 00030 #include "NamespaceHeader.H" 00031 00032 00033 //! \class EBLevelTGA 00034 //! This class implements an imlplicit integrator for a diffusion 00035 //! equation using an approach devised by Twizzell, Gumel, and Arigu. 00036 class EBLevelTGA : public BaseLevelTGA<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister> 00037 { 00038 00039 public: 00040 00041 //! Create a new TGA level integrator. 00042 //! \param a_grids The disjoint box layout on which the level integrator is defined. 00043 //! \param a_refRat The refinement ratios for the boxes. 00044 //! \param a_level0Domain The coarsest grid level defining the problem domain. 00045 //! \param a_opFact A factory that generates level diffusion operators. 00046 //! \param a_solver A multigrid solver. 00047 EBLevelTGA(const Vector<DisjointBoxLayout>& a_grids, 00048 const Vector<int>& a_refRat, 00049 const ProblemDomain& a_level0Domain, 00050 RefCountedPtr<AMRLevelOpFactory<LevelData<EBCellFAB> > >& a_opFact, 00051 const RefCountedPtr<AMRMultiGrid<LevelData<EBCellFAB> > >& a_solver) 00052 :BaseLevelTGA<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister>(a_grids, a_refRat, a_level0Domain, a_opFact, a_solver) 00053 { 00054 m_isEBLGSet = false; 00055 } 00056 00057 //! Destructor 00058 virtual ~EBLevelTGA() 00059 { 00060 } 00061 00062 //! Computes the time-centered diffusive term for explicit updating. 00063 //! This integrates the diffusion equation for a new value of a quantity phi 00064 //! and then computes the diffusion term using a finite difference stencil 00065 //! in time. 00066 //! \param a_diffusionTerm The term computed by this method. 00067 //! \param a_phiOld The value of phi at the beginning of the time step, 00068 //! at the current grid level. 00069 //! \param a_src The source term in the diffusion equation at the current 00070 //! grid level. 00071 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00072 //! adjacent grid level (or NULL if there is none). 00073 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00074 //! adjacent grid level (or NULL if there is none). 00075 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00076 //! old value of phi on the coarser adjacent grid 00077 //! level (or NULL if there is none). 00078 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00079 //! updated value of phi on the coarser adjacent grid 00080 //! level (or NULL if there is none). 00081 //! \param a_oldTime The time at the beginning of the integration step on 00082 //! the current grid level. 00083 //! \param a_crseOldTime The time at the beginning of the integration step 00084 //! on the coarser adjacent grid level. 00085 //! \param a_crseNewTime The time at the end of the integration step 00086 //! on the coarser adjacent grid level. 00087 //! \param a_dt The time step on the current grid level. 00088 //! \param a_level The current grid level. 00089 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00090 //! be set to zero. Otherwise, \a a_phiOld will be used. 00091 void computeDiffusion(LevelData<EBCellFAB>& a_DiffusiveTerm, 00092 LevelData<EBCellFAB>& a_phiOld, 00093 LevelData<EBCellFAB>& a_src, 00094 EBFluxRegister* a_FineFluxRegPtr, 00095 EBFluxRegister* a_crseFluxRegPtr, 00096 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00097 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00098 Real a_oldTime, 00099 Real a_crseOldTime, 00100 Real a_crseNewTime, 00101 Real a_dt, 00102 int a_level, 00103 bool a_zeroPhi = true, 00104 bool a_rhsAlreadyKappaWeighted = false 00105 ); 00106 00107 //! Integrates the diffusion equation, storing the result in \a a_phiNew. 00108 //! \param a_phiNew The new value of phi at the current grid level. 00109 //! \param a_phiOld The value of phi at the beginning of the time step, 00110 //! at the current grid level. 00111 //! \param a_src The source term in the diffusion equation at the current 00112 //! grid level. 00113 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00114 //! adjacent grid level (or NULL if there is none). 00115 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00116 //! adjacent grid level (or NULL if there is none). 00117 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00118 //! old value of phi on the coarser adjacent grid 00119 //! level (or NULL if there is none). 00120 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00121 //! updated value of phi on the coarser adjacent grid 00122 //! level (or NULL if there is none). 00123 //! \param a_oldTime The time at the beginning of the integration step on 00124 //! the current grid level. 00125 //! \param a_crseOldTime The time at the beginning of the integration step 00126 //! on the coarser adjacent grid level. 00127 //! \param a_crseNewTime The time at the end of the integration step 00128 //! on the coarser adjacent grid level. 00129 //! \param a_dt The time step on the current grid level. 00130 //! \param a_level The current grid level. 00131 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00132 //! be set to zero. Otherwise, \a a_phiOld will be used. 00133 void updateSoln(LevelData<EBCellFAB>& a_phiNew, 00134 LevelData<EBCellFAB>& a_phiOld, 00135 LevelData<EBCellFAB>& a_src, 00136 EBFluxRegister* a_fineFluxRegPtr, 00137 EBFluxRegister* a_crseFluxRegPtr, 00138 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00139 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00140 Real a_oldTime, 00141 Real a_crseOldTime, 00142 Real a_crseNewTime, 00143 Real a_dt, 00144 int a_level, 00145 bool a_zeroPhi = true, 00146 bool a_rhsAlreadyKappaWeighted = false, 00147 int a_fluxStartComponent = 0); 00148 00149 void setSourceGhostCells(LevelData<EBCellFAB>& a_src, 00150 const DisjointBoxLayout& a_grids, 00151 int a_lev); 00152 00153 void setEBLG(Vector<EBLevelGrid>& a_eblg) 00154 { 00155 m_isEBLGSet = true; 00156 m_eblg = a_eblg; 00157 } 00158 00159 protected: 00160 bool m_isEBLGSet; 00161 Vector<EBLevelGrid> m_eblg; 00162 00163 00164 }; 00165 00166 00167 //! \class EBLevelBackwardEuler 00168 //! This class implements an imlplicit integrator for a diffusion 00169 //! equation using an approach devised by Twizzell, Gumel, and Arigu. 00170 class EBLevelBackwardEuler : public BaseLevelBackwardEuler<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister> 00171 { 00172 00173 public: 00174 00175 //! Create a new BackwardEuler level integrator. 00176 //! \param a_grids The disjoint box layout on which the level integrator is defined. 00177 //! \param a_refRat The refinement ratios for the boxes. 00178 //! \param a_level0Domain The coarsest grid level defining the problem domain. 00179 //! \param a_opFact A factory that generates level diffusion operators. 00180 //! \param a_solver A multigrid solver. 00181 EBLevelBackwardEuler(const Vector<DisjointBoxLayout>& a_grids, 00182 const Vector<int>& a_refRat, 00183 const ProblemDomain& a_level0Domain, 00184 RefCountedPtr<AMRLevelOpFactory<LevelData<EBCellFAB> > >& a_opFact, 00185 const RefCountedPtr<AMRMultiGrid<LevelData<EBCellFAB> > >& a_solver) 00186 :BaseLevelBackwardEuler<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister>(a_grids, a_refRat, a_level0Domain, a_opFact, a_solver) 00187 { 00188 m_isEBLGSet = false; 00189 } 00190 00191 //! Destructor 00192 virtual ~EBLevelBackwardEuler() 00193 { 00194 } 00195 00196 //! Computes the time-centered diffusive term for explicit updating. 00197 //! This integrates the diffusion equation for a new value of a quantity phi 00198 //! and then computes the diffusion term using a finite difference stencil 00199 //! in time. 00200 //! \param a_diffusionTerm The term computed by this method. 00201 //! \param a_phiOld The value of phi at the beginning of the time step, 00202 //! at the current grid level. 00203 //! \param a_src The source term in the diffusion equation at the current 00204 //! grid level. 00205 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00206 //! adjacent grid level (or NULL if there is none). 00207 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00208 //! adjacent grid level (or NULL if there is none). 00209 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00210 //! old value of phi on the coarser adjacent grid 00211 //! level (or NULL if there is none). 00212 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00213 //! updated value of phi on the coarser adjacent grid 00214 //! level (or NULL if there is none). 00215 //! \param a_oldTime The time at the beginning of the integration step on 00216 //! the current grid level. 00217 //! \param a_crseOldTime The time at the beginning of the integration step 00218 //! on the coarser adjacent grid level. 00219 //! \param a_crseNewTime The time at the end of the integration step 00220 //! on the coarser adjacent grid level. 00221 //! \param a_dt The time step on the current grid level. 00222 //! \param a_level The current grid level. 00223 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00224 //! be set to zero. Otherwise, \a a_phiOld will be used. 00225 void computeDiffusion(LevelData<EBCellFAB>& a_DiffusiveTerm, 00226 LevelData<EBCellFAB>& a_phiOld, 00227 LevelData<EBCellFAB>& a_src, 00228 EBFluxRegister* a_FineFluxRegPtr, 00229 EBFluxRegister* a_crseFluxRegPtr, 00230 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00231 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00232 Real a_oldTime, 00233 Real a_crseOldTime, 00234 Real a_crseNewTime, 00235 Real a_dt, 00236 int a_level, 00237 bool a_zeroPhi = true, 00238 bool a_rhsAlreadyKappaWeighted = false 00239 ); 00240 00241 //! Integrates the diffusion equation, storing the result in \a a_phiNew. 00242 //! \param a_phiNew The new value of phi at the current grid level. 00243 //! \param a_phiOld The value of phi at the beginning of the time step, 00244 //! at the current grid level. 00245 //! \param a_src The source term in the diffusion equation at the current 00246 //! grid level. 00247 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00248 //! adjacent grid level (or NULL if there is none). 00249 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00250 //! adjacent grid level (or NULL if there is none). 00251 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00252 //! old value of phi on the coarser adjacent grid 00253 //! level (or NULL if there is none). 00254 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00255 //! updated value of phi on the coarser adjacent grid 00256 //! level (or NULL if there is none). 00257 //! \param a_oldTime The time at the beginning of the integration step on 00258 //! the current grid level. 00259 //! \param a_crseOldTime The time at the beginning of the integration step 00260 //! on the coarser adjacent grid level. 00261 //! \param a_crseNewTime The time at the end of the integration step 00262 //! on the coarser adjacent grid level. 00263 //! \param a_dt The time step on the current grid level. 00264 //! \param a_level The current grid level. 00265 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00266 //! be set to zero. Otherwise, \a a_phiOld will be used. 00267 void updateSoln(LevelData<EBCellFAB>& a_phiNew, 00268 LevelData<EBCellFAB>& a_phiOld, 00269 LevelData<EBCellFAB>& a_src, 00270 EBFluxRegister* a_fineFluxRegPtr, 00271 EBFluxRegister* a_crseFluxRegPtr, 00272 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00273 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00274 Real a_oldTime, 00275 Real a_crseOldTime, 00276 Real a_crseNewTime, 00277 Real a_dt, 00278 int a_level, 00279 bool a_zeroPhi = true, 00280 bool a_rhsAlreadyKappaWeighted = false, 00281 int a_fluxStartComponent = 0); 00282 00283 00284 void setEBLG(Vector<EBLevelGrid>& a_eblg) 00285 { 00286 m_isEBLGSet = true; 00287 m_eblg = a_eblg; 00288 } 00289 00290 protected: 00291 bool m_isEBLGSet; 00292 Vector<EBLevelGrid> m_eblg; 00293 00294 00295 }; 00296 00297 //! \class EBLevelCrankNicolson 00298 //! This class implements an imlplicit integrator for a diffusion 00299 //! equation using an approach devised by Twizzell, Gumel, and Arigu. 00300 class EBLevelCrankNicolson : public BaseLevelCrankNicolson<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister> 00301 { 00302 00303 public: 00304 00305 //! Create a new CrankNicolson level integrator. 00306 //! \param a_grids The disjoint box layout on which the level integrator is defined. 00307 //! \param a_refRat The refinement ratios for the boxes. 00308 //! \param a_level0Domain The coarsest grid level defining the problem domain. 00309 //! \param a_opFact A factory that generates level diffusion operators. 00310 //! \param a_solver A multigrid solver. 00311 EBLevelCrankNicolson(const Vector<DisjointBoxLayout>& a_grids, 00312 const Vector<int>& a_refRat, 00313 const ProblemDomain& a_level0Domain, 00314 RefCountedPtr<AMRLevelOpFactory<LevelData<EBCellFAB> > >& a_opFact, 00315 const RefCountedPtr<AMRMultiGrid<LevelData<EBCellFAB> > >& a_solver) 00316 :BaseLevelCrankNicolson<LevelData<EBCellFAB>, EBFluxFAB, EBFluxRegister>(a_grids, a_refRat, a_level0Domain, a_opFact, a_solver) 00317 { 00318 m_isEBLGSet = false; 00319 } 00320 00321 //! Destructor 00322 virtual ~EBLevelCrankNicolson() 00323 { 00324 } 00325 00326 //! Computes the time-centered diffusive term for explicit updating. 00327 //! This integrates the diffusion equation for a new value of a quantity phi 00328 //! and then computes the diffusion term using a finite difference stencil 00329 //! in time. 00330 //! \param a_diffusionTerm The term computed by this method. 00331 //! \param a_phiOld The value of phi at the beginning of the time step, 00332 //! at the current grid level. 00333 //! \param a_src The source term in the diffusion equation at the current 00334 //! grid level. 00335 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00336 //! adjacent grid level (or NULL if there is none). 00337 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00338 //! adjacent grid level (or NULL if there is none). 00339 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00340 //! old value of phi on the coarser adjacent grid 00341 //! level (or NULL if there is none). 00342 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00343 //! updated value of phi on the coarser adjacent grid 00344 //! level (or NULL if there is none). 00345 //! \param a_oldTime The time at the beginning of the integration step on 00346 //! the current grid level. 00347 //! \param a_crseOldTime The time at the beginning of the integration step 00348 //! on the coarser adjacent grid level. 00349 //! \param a_crseNewTime The time at the end of the integration step 00350 //! on the coarser adjacent grid level. 00351 //! \param a_dt The time step on the current grid level. 00352 //! \param a_level The current grid level. 00353 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00354 //! be set to zero. Otherwise, \a a_phiOld will be used. 00355 void computeDiffusion(LevelData<EBCellFAB>& a_DiffusiveTerm, 00356 LevelData<EBCellFAB>& a_phiOld, 00357 LevelData<EBCellFAB>& a_src, 00358 EBFluxRegister* a_FineFluxRegPtr, 00359 EBFluxRegister* a_crseFluxRegPtr, 00360 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00361 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00362 Real a_oldTime, 00363 Real a_crseOldTime, 00364 Real a_crseNewTime, 00365 Real a_dt, 00366 int a_level, 00367 bool a_zeroPhi = true, 00368 bool a_rhsAlreadyKappaWeighted = false 00369 ); 00370 00371 //! Integrates the diffusion equation, storing the result in \a a_phiNew. 00372 //! \param a_phiNew The new value of phi at the current grid level. 00373 //! \param a_phiOld The value of phi at the beginning of the time step, 00374 //! at the current grid level. 00375 //! \param a_src The source term in the diffusion equation at the current 00376 //! grid level. 00377 //! \param a_fineFluxRegPtr A pointer to the flux register at the finer 00378 //! adjacent grid level (or NULL if there is none). 00379 //! \param a_crseFluxRegPtr A pointer to the flux register at the coarser 00380 //! adjacent grid level (or NULL if there is none). 00381 //! \param a_crsePhiOldPtr A pointer to the LevelData object holding the 00382 //! old value of phi on the coarser adjacent grid 00383 //! level (or NULL if there is none). 00384 //! \param a_crsePhiNewPtr A pointer to the LevelData object holding the 00385 //! updated value of phi on the coarser adjacent grid 00386 //! level (or NULL if there is none). 00387 //! \param a_oldTime The time at the beginning of the integration step on 00388 //! the current grid level. 00389 //! \param a_crseOldTime The time at the beginning of the integration step 00390 //! on the coarser adjacent grid level. 00391 //! \param a_crseNewTime The time at the end of the integration step 00392 //! on the coarser adjacent grid level. 00393 //! \param a_dt The time step on the current grid level. 00394 //! \param a_level The current grid level. 00395 //! \param a_zeroPhi If this flag is true, the initial estimate of phi will 00396 //! be set to zero. Otherwise, \a a_phiOld will be used. 00397 void updateSoln(LevelData<EBCellFAB>& a_phiNew, 00398 LevelData<EBCellFAB>& a_phiOld, 00399 LevelData<EBCellFAB>& a_src, 00400 EBFluxRegister* a_fineFluxRegPtr, 00401 EBFluxRegister* a_crseFluxRegPtr, 00402 const LevelData<EBCellFAB>* a_crsePhiOldPtr, 00403 const LevelData<EBCellFAB>* a_crsePhiNewPtr, 00404 Real a_oldTime, 00405 Real a_crseOldTime, 00406 Real a_crseNewTime, 00407 Real a_dt, 00408 int a_level, 00409 bool a_zeroPhi = true, 00410 bool a_rhsAlreadyKappaWeighted = false, 00411 int a_fluxStartComponent = 0); 00412 00413 00414 void setEBLG(Vector<EBLevelGrid>& a_eblg) 00415 { 00416 m_isEBLGSet = true; 00417 m_eblg = a_eblg; 00418 } 00419 00420 protected: 00421 bool m_isEBLGSet; 00422 Vector<EBLevelGrid> m_eblg; 00423 00424 00425 }; 00426 00427 #include "NamespaceFooter.H" 00428 #endif 00429 00430