00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _EBAMRPOISSONOP_H_
00012 #define _EBAMRPOISSONOP_H_
00013
00014 #include "REAL.H"
00015 #include "Box.H"
00016 #include "FArrayBox.H"
00017 #include "Vector.H"
00018 #include <map>
00019 #include "RefCountedPtr.H"
00020
00021 #include "AMRMultiGrid.H"
00022
00023 #include "EBIndexSpace.H"
00024 #include "EBCellFAB.H"
00025 #include "EBCellFactory.H"
00026 #include "EBStencil.H"
00027
00028 #include "EBLevelDataOps.H"
00029 #include "BaseEBBC.H"
00030 #include "BaseDomainBC.H"
00031 #include "CFIVS.H"
00032 #include "EBFluxRegister.H"
00033 #include "EBFastFR.H"
00034 #include "EBMGAverage.H"
00035 #include "EBMGInterp.H"
00036 #include "PolyGeom.H"
00037 #include "EBQuadCFInterp.H"
00038 #include "EBLevelGrid.H"
00039 #include "AMRTGA.H"
00040 #include "AMRPoissonOp.H"
00041 #include "CFRegion.H"
00042 #include "NamespaceHeader.H"
00043
00044 #if CH_SPACEDIM==2
00045 #define EBAMRPO_NUMSTEN 4
00046 #elif CH_SPACEDIM==3
00047 #define EBAMRPO_NUMSTEN 8
00048 #else
00049 void THIS_IS_AN_ERROR_MESSAGE(void)
00050 {
00051 THIS_WILL_ONLY_COMPILE_WHEN_CH_SPACEDIM_IS_2_OR_3;
00052 }
00053 #endif
00054
00056
00059 class EBAMRPoissonOp: public LevelTGAHelmOp<LevelData<EBCellFAB>, EBFluxFAB >
00060 {
00061 public:
00062
00064
00067 static bool getCoarserLayouts(DisjointBoxLayout& a_dblCoar,
00068 ProblemDomain& a_domainCoar,
00069 const DisjointBoxLayout& a_dblFine,
00070 const EBISLayout& a_ebislFine,
00071 const ProblemDomain& a_domainFine,
00072 int a_refToCoar,
00073 const EBIndexSpace* a_ebisPtr,
00074 int a_maxBoxSize,
00075 bool& a_layoutChanged);
00076
00077
00078 virtual void setAlphaAndBeta(const Real& a_alpha,
00079 const Real& a_beta);
00080
00081
00082 virtual void diagonalScale(LevelData<EBCellFAB> & a_rhs);
00083
00085 virtual void fillGrad(const LevelData<EBCellFAB>& a_phi)
00086 {;}
00087
00088 virtual void getFlux(EBFluxFAB& a_flux,
00089 const LevelData<EBCellFAB>& a_data,
00090 const Box& a_grid,
00091 const DataIndex& a_dit,
00092 Real a_scale)
00093 {
00094 for(int idir = 0; idir < SpaceDim; idir++)
00095 {
00096 Box ghostedBox = a_grid;
00097 ghostedBox.grow(1);
00098 ghostedBox.grow(idir,-1);
00099 ghostedBox &= m_eblg.getDomain();
00100
00101 getFlux(a_flux[idir], a_data[a_dit], ghostedBox, a_grid,
00102 m_eblg.getDomain(),
00103 m_eblg.getEBISL()[a_dit], m_dx, idir);
00104 }
00105 }
00106 EBLevelGrid getEBLG()
00107 {
00108 return m_eblg;
00109 }
00110 EBLevelGrid getEBLGCoarMG()
00111 {
00112 return m_eblgCoarMG;
00113 }
00114 static void setOperatorTime(Real a_time)
00115 {
00116 s_time = a_time;
00117 }
00119 virtual ~EBAMRPoissonOp();
00120
00122 EBAMRPoissonOp();
00123
00125
00126 void AMRResidualNC(LevelData<EBCellFAB>& a_residual,
00127 const LevelData<EBCellFAB>& a_phiFine,
00128 const LevelData<EBCellFAB>& a_phi,
00129 const LevelData<EBCellFAB>& a_rhs,
00130 bool a_homogeneousBC,
00131 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00132
00133
00135
00136 void AMROperatorNC(LevelData<EBCellFAB>& a_LofPhi,
00137 const LevelData<EBCellFAB>& a_phiFine,
00138 const LevelData<EBCellFAB>& a_phi,
00139 bool a_homogeneousBC,
00140 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00141
00143
00168 EBAMRPoissonOp(const EBLevelGrid & a_eblgFine,
00169 const EBLevelGrid & a_eblg,
00170 const EBLevelGrid & a_eblgCoar,
00171 const EBLevelGrid & a_eblgCoarMG,
00172 const RefCountedPtr<EBQuadCFInterp>& a_quadCFI,
00173 const RefCountedPtr<BaseDomainBC>& a_domainBC,
00174 const RefCountedPtr<BaseEBBC>& a_ebBC,
00175 const RealVect& a_dx,
00176 const RealVect& a_dxCoar,
00177 const RealVect& a_origin,
00178 const int& a_refToFine,
00179 const int& a_refToCoar,
00180 const bool& a_hasFine,
00181 const bool& a_hasCoar,
00182 const bool& a_hasMGObjects,
00183 const bool& a_layoutChanged,
00184 const int& a_numPreCondIters,
00185 const int& a_relaxType,
00186 const Real& a_alpha,
00187 const Real& a_beta,
00188 const IntVect& a_ghostCellsPhi,
00189 const IntVect& a_ghostCellsRHS);
00190
00191
00192
00194
00196 virtual void residual(LevelData<EBCellFAB>& a_residual,
00197 const LevelData<EBCellFAB>& a_phi,
00198 const LevelData<EBCellFAB>& a_rhs,
00199 bool a_homogeneousPhysBC=false);
00200
00202
00204 virtual void preCond(LevelData<EBCellFAB>& a_opPhi,
00205 const LevelData<EBCellFAB>& a_phi);
00206
00208
00212 virtual void applyOp(LevelData<EBCellFAB>& a_opPhi,
00213 const LevelData<EBCellFAB>& a_phi,
00214 const LevelData<EBCellFAB>* const a_phiCoarse,
00215 const bool& a_homogeneousPhysBC,
00216 const bool& a_homogeneousCFBC);
00217
00219 virtual void applyOpNoBoundary(LevelData<EBCellFAB>& a_opPhi,
00220 const LevelData<EBCellFAB>& a_phi);
00221
00223
00227 virtual void
00228 applyOp(LevelData<EBCellFAB>& a_opPhi,
00229 const LevelData<EBCellFAB>& a_phi,
00230 const LevelData<EBCellFAB>* const a_phiCoar,
00231 const bool& a_homogeneousPhysBC,
00232 const bool& a_homogeneousCFBC,
00233 const LevelData<BaseIVFAB<Real> >* const a_ebFluxBCLD);
00234
00235 virtual void
00236 GSColorAllRegular(BaseFab<Real>& a_phi,
00237 const BaseFab<Real>& a_rhs,
00238 const int& a_icolor,
00239 const Real& a_weight,
00240 const bool& a_homogeneousPhysBC,
00241 const DataIndex& a_dit);
00242
00243 virtual void
00244 GSColorAllIrregular(EBCellFAB& a_phi,
00245 const EBCellFAB& a_rhs,
00246 const int& a_icolor,
00247 const bool& a_homogeneousPhysBC,
00248 const DataIndex& a_dit);
00249
00251
00254 virtual void applyOp(LevelData<EBCellFAB>& a_opPhi,
00255 const LevelData<EBCellFAB>& a_phi,
00256 bool a_homogeneousPhysBC);
00257
00259 void
00260 applyOpNoCFBCs(LevelData<EBCellFAB>& a_opPhi,
00261 const LevelData<EBCellFAB>& a_phi,
00262 const LevelData<EBCellFAB>* const a_phiCoar,
00263 const bool& a_homogeneousPhysBC,
00264 const bool& a_homogeneousCFBC,
00265 const LevelData<BaseIVFAB<Real> >* const a_ebFluxBCLD
00266 );
00267
00269
00271 virtual void create(LevelData<EBCellFAB>& a_lhs,
00272 const LevelData<EBCellFAB>& a_rhs);
00273
00275 virtual void createCoarsened(LevelData<EBCellFAB>& a_lhs,
00276 const LevelData<EBCellFAB>& a_rhs,
00277 const int& a_refRat);
00278
00279 Real
00280 AMRNorm(const LevelData<EBCellFAB>& a_coarResid,
00281 const LevelData<EBCellFAB>& a_fineResid,
00282 const int& a_refRat,
00283 const int& a_ord);
00284
00286
00288 virtual void assign(LevelData<EBCellFAB>& a_lhs,
00289 const LevelData<EBCellFAB>& a_rhs);
00290
00292
00294 virtual Real dotProduct(const LevelData<EBCellFAB>& a_1,
00295 const LevelData<EBCellFAB>& a_2);
00296
00298
00300 virtual void incr(LevelData<EBCellFAB>& a_lhs,
00301 const LevelData<EBCellFAB>& a_x,
00302 Real a_scale);
00303
00305
00307 virtual void axby(LevelData<EBCellFAB>& a_lhs,
00308 const LevelData<EBCellFAB>& a_x,
00309 const LevelData<EBCellFAB>& a_y,
00310 Real a_a,
00311 Real a_b);
00312
00314
00316 virtual void scale(LevelData<EBCellFAB>& a_lhs,
00317 const Real& a_scale);
00318
00320
00322 virtual Real norm(const LevelData<EBCellFAB>& a_rhs,
00323 int a_ord);
00324
00326
00328 virtual Real localMaxNorm(const LevelData<EBCellFAB>& a_rhs);
00329
00331
00333 virtual void setToZero(LevelData<EBCellFAB>& a_lhs);
00334
00336
00338 virtual void setVal(LevelData<EBCellFAB>& a_lhs, const Real& a_value);
00339
00341
00343 virtual void createCoarser(LevelData<EBCellFAB>& a_coarse,
00344 const LevelData<EBCellFAB>& a_fine,
00345 bool a_ghosted);
00346
00348
00350 virtual void relax(LevelData<EBCellFAB>& a_e,
00351 const LevelData<EBCellFAB>& a_residual,
00352 int a_iterations);
00353
00355
00359 virtual void restrictResidual(LevelData<EBCellFAB>& a_resCoarse,
00360 LevelData<EBCellFAB>& a_phiFine,
00361 const LevelData<EBCellFAB>& a_rhsFine);
00362
00364
00368 virtual void prolongIncrement(LevelData<EBCellFAB>& a_phiThisLevel,
00369 const LevelData<EBCellFAB>& a_correctCoarse);
00370
00372
00374 virtual int refToCoarser();
00375
00377
00379 virtual int refToFiner();
00380
00382
00383 virtual void AMRResidual(LevelData<EBCellFAB>& a_residual,
00384 const LevelData<EBCellFAB>& a_phiFine,
00385 const LevelData<EBCellFAB>& a_phi,
00386 const LevelData<EBCellFAB>& a_phiCoarse,
00387 const LevelData<EBCellFAB>& a_rhs,
00388 bool a_homogeneousBC,
00389 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00390
00392
00393 virtual void AMRResidualNF(LevelData<EBCellFAB>& a_residual,
00394 const LevelData<EBCellFAB>& a_phi,
00395 const LevelData<EBCellFAB>& a_phiCoarse,
00396 const LevelData<EBCellFAB>& a_rhs,
00397 bool a_homogeneousBC);
00398
00399
00401
00402 virtual void AMROperator(LevelData<EBCellFAB>& a_LofPhi,
00403 const LevelData<EBCellFAB>& a_phiFine,
00404 const LevelData<EBCellFAB>& a_phi,
00405 const LevelData<EBCellFAB>& a_phiCoarse,
00406 bool a_homogeneousBC,
00407 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00408
00410
00411 virtual void AMROperatorNF(LevelData<EBCellFAB>& a_LofPhi,
00412 const LevelData<EBCellFAB>& a_phi,
00413 const LevelData<EBCellFAB>& a_phiCoarse,
00414 bool a_homogeneousBC);
00415
00417
00418 virtual void AMRRestrict(LevelData<EBCellFAB>& a_resCoarse,
00419 const LevelData<EBCellFAB>& a_residual,
00420 const LevelData<EBCellFAB>& a_correction,
00421 const LevelData<EBCellFAB>& a_coarseCorrection);
00422
00424
00425 virtual void AMRProlong(LevelData<EBCellFAB>& a_correction,
00426 const LevelData<EBCellFAB>& a_coarseCorrection);
00427
00429
00430 virtual void AMRUpdateResidual(LevelData<EBCellFAB>& a_residual,
00431 const LevelData<EBCellFAB>& a_correction,
00432 const LevelData<EBCellFAB>& a_coarseCorrection);
00433
00435
00437 void AMRUpdateResidual(LevelData<EBCellFAB>& a_residual,
00438 const LevelData<EBCellFAB>& a_correction,
00439 const LevelData<EBCellFAB>& a_coarseCorrection,
00440 const LevelData<BaseIVFAB<Real> >* const a_ebFluxBCLD);
00441
00442 void reflux(LevelData<EBCellFAB>& a_residual,
00443 const LevelData<EBCellFAB>& a_phiFine,
00444 const LevelData<EBCellFAB>& a_phi,
00445 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00446
00447
00448 void old_reflux(LevelData<EBCellFAB>& a_residual,
00449 const LevelData<EBCellFAB>& a_phiFine,
00450 const LevelData<EBCellFAB>& a_phi,
00451 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00452
00453 void fast_reflux(LevelData<EBCellFAB>& a_residual,
00454 const LevelData<EBCellFAB>& a_phiFine,
00455 const LevelData<EBCellFAB>& a_phi,
00456 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00457
00458 void setEBBC(const RefCountedPtr<BaseEBBC>& a_ebBC);
00459
00460
00461 void slowGSRBColor(LevelData<EBCellFAB>& a_phi,
00462 const LevelData<EBCellFAB>& a_lph,
00463 const LevelData<EBCellFAB>& a_rhs,
00464 const IntVect& a_color);
00465
00466
00467 void levelSlowRelax(LevelData<EBCellFAB>& a_phi,
00468 const LevelData<EBCellFAB>& a_rhs);
00469
00470 void levelMultiColorGS(LevelData<EBCellFAB>& a_phi,
00471 const LevelData<EBCellFAB>& a_rhs);
00472
00473 void levelMultiColorGS(LevelData<EBCellFAB>& a_phi,
00474 const LevelData<EBCellFAB>& a_resid,
00475 const IntVect& color);
00476
00477 void colorGS(LevelData<EBCellFAB>& a_phi,
00478 const LevelData<EBCellFAB>& a_rhs,
00479 const int& a_icolor);
00480
00481 void levelGSRB(LevelData<EBCellFAB>& a_phi,
00482 const LevelData<EBCellFAB>& a_rhs);
00483
00484 void levelGSRB(LevelData<EBCellFAB>& a_phi,
00485 const LevelData<EBCellFAB>& a_rhs,
00486 const int a_color);
00487
00488 static void doLazyRelax(bool a_doLazyRelax);
00489 static void doEBEllipticLoadBalance(bool a_doEBEllipticLoadBalance);
00490
00491 void getDivFStencil(VoFStencil& a_vofStencil,
00492 const VolIndex& a_vof,
00493 const DataIndex& a_dit,
00494 bool a_doFaceInterp);
00495
00496 void getFluxStencil(VoFStencil& a_fluxStencil,
00497 const FaceIndex& a_face,
00498 const DataIndex& a_dit,
00499 bool a_doFaceInterp);
00500
00501 void getFaceCenteredFluxStencil(VoFStencil& a_fluxStencil,
00502 const FaceIndex& a_face,
00503 const DataIndex& a_dit);
00504
00505 void applyCFBCs(LevelData<EBCellFAB>& a_phi,
00506 const LevelData<EBCellFAB>* const a_phiCoarse,
00507 bool a_homogeneousCFBC,
00508 bool a_doOnlyRegularInterp = false);
00509
00510 protected:
00511
00512 static bool s_turnOffBCs;
00513 static bool s_doEBEllipticLoadBalance;
00514 void defineStencils();
00515
00516 const IntVect m_ghostCellsPhi;
00517 const IntVect m_ghostCellsRHS;
00518
00519 AMRPoissonOp m_amrpop;
00520 CFRegion m_cfregion;
00521 RefCountedPtr<EBQuadCFInterp> m_quadCFIWithCoar;
00522
00523 EBLevelGrid m_eblg;
00524 EBLevelGrid m_eblgFine;
00525 EBLevelGrid m_eblgCoar;
00526 EBLevelGrid m_eblgCoarMG;
00527 EBLevelGrid m_eblgCoarsenedFine;
00528
00529 RefCountedPtr<BaseDomainBC> m_domainBC;
00530 RefCountedPtr<BaseEBBC> m_ebBC;
00531
00532 RealVect m_dxFine;
00533 RealVect m_dx;
00534 RealVect m_dxCoar;
00535
00536 RealVect m_invDx;
00537 RealVect m_invDx2;
00538 Real m_dxScale;
00539 Real m_alpha;
00540 Real m_aCoef;
00541 Real m_beta;
00542 Real m_bCoef;
00543 static Real s_time;
00544 static bool s_doLazyRelax;
00545 static bool s_doInconsistentRelax;
00546 static bool s_doTrimEdges;
00547 RealVect m_origin;
00548 int m_refToFine;
00549 int m_refToCoar;
00550 bool m_hasFine;
00551 bool m_hasInterpAve;
00552 bool m_hasCoar;
00553 int m_numPreCondIters;
00554 int m_relaxType;
00555
00556 Copier m_exchangeCopier;
00557
00558 EBMGAverage m_ebAverage;
00559
00560 EBMGInterp m_ebInterp;
00561
00562
00563 LayoutData<RefCountedPtr<EBStencil> > m_opEBStencil;
00564
00565 LayoutData<RefCountedPtr<EBStencil> > m_colorEBStencil[EBAMRPO_NUMSTEN];
00566
00567 LayoutData<BaseIVFAB<Real> > m_alphaDiagWeight;
00568
00569 LayoutData<BaseIVFAB<Real> > m_betaDiagWeight;
00570
00571
00572 LayoutData<VoFIterator > m_vofItIrreg;
00573 LayoutData<VoFIterator > m_vofItIrregColor[EBAMRPO_NUMSTEN];
00574
00575 LayoutData<VoFIterator > m_vofItIrregDomLo[SpaceDim];
00576 LayoutData<VoFIterator > m_vofItIrregDomHi[SpaceDim];
00577
00578 LayoutData<VoFIterator > m_vofItIrregColorDomLo[EBAMRPO_NUMSTEN][SpaceDim];
00579 LayoutData<VoFIterator > m_vofItIrregColorDomHi[EBAMRPO_NUMSTEN][SpaceDim];
00580
00581
00582 LayoutData<CFIVS> m_loCFIVS[SpaceDim];
00583 LayoutData<CFIVS> m_hiCFIVS[SpaceDim];
00584
00585
00586 EBFluxRegister m_fluxReg;
00587 EBFastFR m_fastFR;
00588
00589
00590
00591
00592
00593 bool m_hasMGObjects;
00594 bool m_layoutChanged;
00595
00596 EBMGAverage m_ebAverageMG;
00597 EBMGInterp m_ebInterpMG;
00598 DisjointBoxLayout m_dblCoarMG;
00599 EBISLayout m_ebislCoarMG;
00600 ProblemDomain m_domainCoarMG;
00601
00602 Vector<IntVect> m_colors;
00603
00604 private:
00605
00606
00607
00608 void old_incrementFRCoar(EBFluxRegister& a_fluxReg,
00609 const LevelData<EBCellFAB>& a_phiFine,
00610 const LevelData<EBCellFAB>& a_phi);
00611
00612 void old_incrementFRFine(EBFluxRegister& a_fluxReg,
00613 const LevelData<EBCellFAB>& a_phiFine,
00614 const LevelData<EBCellFAB>& a_phi,
00615 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00616
00617 void fast_incrementFRCoar(EBFastFR& a_fluxReg,
00618 const LevelData<EBCellFAB>& a_phiFine,
00619 const LevelData<EBCellFAB>& a_phi);
00620
00621 void fast_incrementFRFine(EBFastFR& a_fluxReg,
00622 const LevelData<EBCellFAB>& a_phiFine,
00623 const LevelData<EBCellFAB>& a_phi,
00624 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00625
00626 void getFlux(EBFaceFAB& a_flux,
00627 const EBCellFAB& a_phi,
00628 const Box& a_ghostedBox,
00629 const Box& a_fabBox,
00630 const ProblemDomain& a_domainBox,
00631 const EBISBox& a_ebisBox,
00632 const RealVect& a_dx,
00633 const int& a_idir);
00634
00635 void getOpVoFStencil(VoFStencil& a_stencil,
00636 const EBISBox& a_ebisbox,
00637 const VolIndex& a_vof);
00638
00639 void getOpVoFStencil(VoFStencil& a_stencil,
00640 const int& a_dir,
00641 const Vector<VolIndex>& a_allMonotoneVoFs,
00642 const EBISBox& a_ebisbox,
00643 const VolIndex& a_vof,
00644 const bool& a_lowOrder);
00645
00646
00647 void getOpFaceStencil(VoFStencil& a_stencil,
00648 const Vector<VolIndex>& a_allMonotoneVofs,
00649 const EBISBox& a_ebisbox,
00650 const VolIndex& a_vof,
00651 int a_dir,
00652 const Side::LoHiSide& a_side,
00653 const FaceIndex& a_face,
00654 const bool& a_lowOrder);
00655
00656 void levelJacobi(LevelData<EBCellFAB>& a_phi,
00657 const LevelData<EBCellFAB>& a_rhs);
00658
00659 void applyHomogeneousCFBCs(LevelData<EBCellFAB>& a_phi);
00660
00661 void applyHomogeneousCFBCs(EBCellFAB& a_phi,
00662 const DataIndex& a_datInd,
00663 int a_idir,
00664 Side::LoHiSide a_hiorlo);
00665
00666 Real getRadius(const FaceIndex& a_face, const RealVect& a_centroid);
00667
00669
00671 void applyOpRegularAllDirs(Box * a_loBox,
00672 Box * a_hiBox,
00673 int * a_hasLo,
00674 int * a_hasHi,
00675 Box & a_curOpPhiBox,
00676 Box & a_curPhiBox,
00677 int a_nComps,
00678 BaseFab<Real> & a_curOpPhiFAB,
00679 const BaseFab<Real> & a_curPhiFAB,
00680 bool a_homogeneousPhysBC,
00681 const DataIndex& a_dit,
00682 const Real& a_beta);
00683
00684 void applyDomainFlux(Box * a_loBox,
00685 Box * a_hiBox,
00686 int * a_hasLo,
00687 int * a_hasHi,
00688 Box & a_curPhiBox,
00689 int a_nComps,
00690 BaseFab<Real> & a_phiFAB,
00691 bool a_homogeneousPhysBC,
00692 const DataIndex& a_dit,
00693 const Real& a_beta);
00694
00696
00700 void getInvDiagRHS(LevelData<EBCellFAB>& a_lhs,
00701 const LevelData<EBCellFAB>& a_rhs);
00702
00703 private:
00704
00705 EBAMRPoissonOp(const EBAMRPoissonOp& a_opin)
00706 {
00707 MayDay::Error("invalid operator");
00708 }
00709
00710 void operator=(const EBAMRPoissonOp& a_opin)
00711 {
00712 MayDay::Error("invalid operator");
00713 }
00714 };
00715
00716
00717 #include "NamespaceFooter.H"
00718 #endif