00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _NWOEBCONDUCTIVITYOP_H_
00012 #define _NWOEBCONDUCTIVITYOP_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 #include "EBAMRPoissonOp.H"
00023
00024 #include "EBIndexSpace.H"
00025 #include "EBCellFAB.H"
00026 #include "EBCellFactory.H"
00027 #include "VCAggStencil.H"
00028
00029 #include "EBLevelDataOps.H"
00030 #include "BaseEBBC.H"
00031 #include "BaseDomainBC.H"
00032 #include "CFIVS.H"
00033 #include "EBFluxRegister.H"
00034 #include "EBFastFR.H"
00035 #include "EBMGAverage.H"
00036 #include "EBMGInterp.H"
00037 #include "PolyGeom.H"
00038 #include "NWOEBQuadCFInterp.H"
00039 #include "EBLevelGrid.H"
00040 #include "AMRTGA.H"
00041 #include "AMRPoissonOp.H"
00042 #include "CFRegion.H"
00043 #include "ConductivityBaseDomainBC.H"
00044 #include "NamespaceHeader.H"
00045
00046
00047
00048
00049
00050
00051
00052 class NWOEBConductivityOp: public LevelTGAHelmOp<LevelData<EBCellFAB>, EBFluxFAB >
00053 {
00054 public:
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 NWOEBConductivityOp(const EBLevelGrid & a_eblgFine,
00082 const EBLevelGrid & a_eblg,
00083 const EBLevelGrid & a_eblgCoar,
00084 const EBLevelGrid & a_eblgCoarMG,
00085 const RefCountedPtr<NWOEBQuadCFInterp>& a_quadCFI,
00086 const RefCountedPtr<ConductivityBaseDomainBC>& a_domainBC,
00087 const RefCountedPtr<ConductivityBaseEBBC>& a_ebBC,
00088 const Real & a_dx,
00089 const Real & a_dxCoar,
00090 const int& a_refToFine,
00091 const int& a_refToCoar,
00092 const bool& a_hasFine,
00093 const bool& a_hasCoar,
00094 const bool& a_hasMGObjects,
00095 const bool& a_layoutChanged,
00096 const Real& a_alpha,
00097 const Real& a_beta,
00098 const RefCountedPtr<LevelData<EBCellFAB> >& a_acoef,
00099 const RefCountedPtr<LevelData<EBFluxFAB> >& a_bcoef,
00100 const RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_bcoIrreg,
00101 const IntVect& a_ghostCellsPhi,
00102 const IntVect& a_ghostCellsRHS,
00103 const int& a_relaxType);
00104
00105
00106 ~NWOEBConductivityOp()
00107 {
00108 }
00109
00110
00111
00112
00113
00114
00115
00116 virtual void resetACoefficient(RefCountedPtr<LevelData<EBCellFAB> >& a_acoef)
00117 {
00118
00119 m_acoef = a_acoef;
00120 calculateAlphaWeight();
00121 calculateRelaxationCoefficient();
00122 }
00123
00124
00125 Real dx() const
00126 {
00127 return m_dx;
00128 }
00129
00130
00131 virtual void kappaScale(LevelData<EBCellFAB> & a_rhs);
00132
00133
00134
00135 void AMRResidualNC(LevelData<EBCellFAB>& a_residual,
00136 const LevelData<EBCellFAB>& a_phiFine,
00137 const LevelData<EBCellFAB>& a_phi,
00138 const LevelData<EBCellFAB>& a_rhs,
00139 bool a_homogeneousBC,
00140 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00141
00142
00143
00144
00145 void AMROperatorNC(LevelData<EBCellFAB>& a_LofPhi,
00146 const LevelData<EBCellFAB>& a_phiFine,
00147 const LevelData<EBCellFAB>& a_phi,
00148 bool a_homogeneousBC,
00149 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00150
00151
00152
00153
00154
00155 void setAlphaAndBeta(const Real& a_alpha,
00156 const Real& a_beta);
00157
00158 void diagonalScale(LevelData<EBCellFAB> & a_rhs,
00159 bool a_kappaWeighted);
00160
00161 void divideByIdentityCoef(LevelData<EBCellFAB> & a_rhs);
00162
00163
00164 void fillGrad(const LevelData<EBCellFAB>& a_phi)
00165 {
00166 }
00167
00168 void fillPhiGhost(const EBCellFAB& a_phi, const DataIndex& a_datInd, bool a_homog) const;
00169 void fillPhiGhost(const LevelData<EBCellFAB>& a_phi, bool a_homog) const;
00170
00171 void getFlux(EBFluxFAB& a_flux,
00172 const LevelData<EBCellFAB>& a_data,
00173 const Box& a_grid,
00174 const DataIndex& a_dit,
00175 Real a_scale);
00176
00177 void getFlux(EBFaceFAB& a_fluxCentroid,
00178 const EBCellFAB& a_phi,
00179 const Box& a_ghostedBox,
00180 const Box& a_fabBox,
00181 const ProblemDomain& a_domain,
00182 const EBISBox& a_ebisBox,
00183 const Real& a_dx,
00184 const DataIndex& a_datInd,
00185 const int& a_idir);
00186
00187
00188
00189
00190
00191 virtual void residual(LevelData<EBCellFAB>& a_residual,
00192 const LevelData<EBCellFAB>& a_phi,
00193 const LevelData<EBCellFAB>& a_rhs,
00194 bool a_homogeneousPhysBC=false);
00195
00196
00197
00198
00199 virtual void preCond(LevelData<EBCellFAB>& a_opPhi,
00200 const LevelData<EBCellFAB>& a_phi);
00201
00202
00203
00204
00205
00206
00207 virtual void applyOp(LevelData<EBCellFAB>& a_opPhi,
00208 const LevelData<EBCellFAB>& a_phi,
00209 const LevelData<EBCellFAB>* const a_phiCoarse,
00210 const bool& a_homogeneousPhysBC,
00211 const bool& a_homogeneousCFBC);
00212
00213
00214 virtual void applyOpNoBoundary(LevelData<EBCellFAB>& a_opPhi,
00215 const LevelData<EBCellFAB>& a_phi)
00216 {
00217 s_turnOffBCs = true;
00218 applyOp(a_opPhi, a_phi, true);
00219 s_turnOffBCs = false;
00220 }
00221
00222 void
00223 applyOpIrregular(EBCellFAB& a_lhs,
00224 const EBCellFAB& a_phi,
00225 const bool& a_homogeneous,
00226 const DataIndex& a_datInd);
00227
00228 void
00229 applyOpRegular(EBCellFAB& a_lhs,
00230 const EBCellFAB& a_phi,
00231 const bool& a_homogeneous,
00232 const DataIndex& a_datInd);
00233
00234
00235
00236
00237
00238
00239 virtual void applyOp(LevelData<EBCellFAB> & a_opPhi,
00240 const LevelData<EBCellFAB> & a_phi,
00241 bool a_homogeneousPhysBC = false);
00242
00243
00244
00245
00246 virtual void create(LevelData<EBCellFAB>& a_lhs,
00247 const LevelData<EBCellFAB>& a_rhs);
00248
00249
00250 virtual void createCoarsened(LevelData<EBCellFAB>& a_lhs,
00251 const LevelData<EBCellFAB>& a_rhs,
00252 const int& a_refRat);
00253
00254 Real
00255 AMRNorm(const LevelData<EBCellFAB>& a_coarResid,
00256 const LevelData<EBCellFAB>& a_fineResid,
00257 const int& a_refRat,
00258 const int& a_ord);
00259
00260
00261
00262
00263 virtual void assign(LevelData<EBCellFAB>& a_lhs,
00264 const LevelData<EBCellFAB>& a_rhs);
00265
00266
00267
00268
00269 virtual Real dotProduct(const LevelData<EBCellFAB>& a_1,
00270 const LevelData<EBCellFAB>& a_2);
00271
00272
00273
00274
00275 virtual void incr(LevelData<EBCellFAB>& a_lhs,
00276 const LevelData<EBCellFAB>& a_x,
00277 Real a_scale);
00278
00279
00280
00281
00282 virtual void axby(LevelData<EBCellFAB>& a_lhs,
00283 const LevelData<EBCellFAB>& a_x,
00284 const LevelData<EBCellFAB>& a_y,
00285 Real a_a,
00286 Real a_b);
00287
00288
00289
00290
00291 virtual void scale(LevelData<EBCellFAB>& a_lhs,
00292 const Real& a_scale);
00293
00294
00295
00296
00297 virtual Real norm(const LevelData<EBCellFAB>& a_rhs,
00298 int a_ord);
00299
00300 virtual Real localMaxNorm(const LevelData<EBCellFAB>& a_rhs);
00301
00302
00303
00304 virtual void setToZero(LevelData<EBCellFAB>& a_lhs);
00305
00306
00307
00308
00309 virtual void setVal(LevelData<EBCellFAB>& a_lhs, const Real& a_value);
00310
00311
00312
00313
00314 virtual void createCoarser(LevelData<EBCellFAB>& a_coarse,
00315 const LevelData<EBCellFAB>& a_fine,
00316 bool a_ghosted);
00317
00318
00319
00320
00321 virtual void relax(LevelData<EBCellFAB>& a_e,
00322 const LevelData<EBCellFAB>& a_residual,
00323 int a_iterations);
00324
00325
00326
00327
00328
00329
00330 virtual void restrictResidual(LevelData<EBCellFAB>& a_resCoarse,
00331 LevelData<EBCellFAB>& a_phiFine,
00332 const LevelData<EBCellFAB>& a_rhsFine);
00333
00334
00335
00336
00337
00338
00339 virtual void prolongIncrement(LevelData<EBCellFAB>& a_phiThisLevel,
00340 const LevelData<EBCellFAB>& a_correctCoarse);
00341
00342
00343
00344
00345 virtual int refToCoarser();
00346
00347
00348
00349
00350 virtual int refToFiner();
00351
00352
00353
00354 virtual void AMRResidual(LevelData<EBCellFAB>& a_residual,
00355 const LevelData<EBCellFAB>& a_phiFine,
00356 const LevelData<EBCellFAB>& a_phi,
00357 const LevelData<EBCellFAB>& a_phiCoarse,
00358 const LevelData<EBCellFAB>& a_rhs,
00359 bool a_homogeneousBC,
00360 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00361
00362
00363
00364 virtual void AMRResidualNF(LevelData<EBCellFAB>& a_residual,
00365 const LevelData<EBCellFAB>& a_phi,
00366 const LevelData<EBCellFAB>& a_phiCoarse,
00367 const LevelData<EBCellFAB>& a_rhs,
00368 bool a_homogeneousBC);
00369
00370
00371
00372
00373 virtual void AMROperator(LevelData<EBCellFAB>& a_LofPhi,
00374 const LevelData<EBCellFAB>& a_phiFine,
00375 const LevelData<EBCellFAB>& a_phi,
00376 const LevelData<EBCellFAB>& a_phiCoarse,
00377 bool a_homogeneousBC,
00378 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00379
00380
00381
00382 virtual void AMROperatorNF(LevelData<EBCellFAB>& a_LofPhi,
00383 const LevelData<EBCellFAB>& a_phi,
00384 const LevelData<EBCellFAB>& a_phiCoarse,
00385 bool a_homogeneousBC);
00386
00387
00388
00389 virtual void AMRRestrict(LevelData<EBCellFAB>& a_resCoarse,
00390 const LevelData<EBCellFAB>& a_residual,
00391 const LevelData<EBCellFAB>& a_correction,
00392 const LevelData<EBCellFAB>& a_coarseCorrection,
00393 bool a_skip_res = false );
00394
00395
00396
00397 virtual void AMRProlong(LevelData<EBCellFAB>& a_correction,
00398 const LevelData<EBCellFAB>& a_coarseCorrection);
00399
00400
00401
00402 virtual void AMRUpdateResidual(LevelData<EBCellFAB>& a_residual,
00403 const LevelData<EBCellFAB>& a_correction,
00404 const LevelData<EBCellFAB>& a_coarseCorrection);
00405
00406 void
00407 gsrbColor(LevelData<EBCellFAB>& a_phi,
00408 const LevelData<EBCellFAB>& a_rhs,
00409 const IntVect& a_color);
00410
00411 void reflux(LevelData<EBCellFAB>& a_residual,
00412 const LevelData<EBCellFAB>& a_phiFine,
00413 const LevelData<EBCellFAB>& a_phi,
00414 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00415
00416 void gsrbColor(LevelData<EBCellFAB>& a_phi,
00417 const LevelData<EBCellFAB>& a_lph,
00418 const LevelData<EBCellFAB>& a_rhs,
00419 const IntVect& a_color);
00420
00421 void getDivFStencil(VoFStencil& a_vofStencil,
00422 const VolIndex& a_vof,
00423 const DataIndex& a_dit);
00424
00425 void getFluxStencil(VoFStencil& a_fluxStencil,
00426 const FaceIndex& a_face,
00427 const DataIndex& a_dit);
00428
00429 void getFaceCenteredFluxStencil(VoFStencil& a_fluxStencil,
00430 const FaceIndex& a_face,
00431 const DataIndex& a_dit);
00432
00433 void homogeneousCFInterp(LevelData<EBCellFAB>& a_phif);
00434
00435
00436
00437
00438 const EBLevelGrid& getEBLG() const
00439 {
00440 return m_eblg;
00441 }
00442 static void setForceNoEBCF(bool a_forceNoEBCF)
00443 {
00444 s_forceNoEBCF = a_forceNoEBCF;
00445 }
00446
00447 static void doLazyRelax(bool a_doLazyRelax)
00448 {
00449 s_doLazyRelax = a_doLazyRelax;
00450 }
00451
00452 void defineStencils();
00453
00454
00455 void getAlphaDiagWeight(LayoutData<BaseIVFAB<Real> > const*& a_alphaDiagWeight)
00456 {
00457 a_alphaDiagWeight = &m_alphaDiagWeight;
00458 }
00459
00460 void getAlphaBeta(Real& a_alpha, Real& a_beta)
00461 {
00462 a_alpha = m_alpha;
00463 a_beta = m_beta;
00464 }
00465 const RefCountedPtr<BaseDomainBC> getDomainBC()
00466 {
00467 return m_domainBC;
00468 }
00469
00470 const RefCountedPtr<LevelData<EBCellFAB> > getAScalingCoefficients()
00471 {
00472 return m_acoef;
00473 }
00474
00475 const RefCountedPtr<LevelData<EBFluxFAB> > getBScalingCoefficients()
00476 {
00477 return m_bcoef;
00478 }
00479
00480 void getEBBCFluxStencil(LayoutData<BaseIVFAB<VoFStencil> > const*& a_ebbcFluxStencil)
00481 {
00482 a_ebbcFluxStencil = m_ebBC->getFluxStencil(0);
00483 }
00484 protected:
00485
00486
00487 Real getSafety();
00488
00489 void incrOpRegularAllDirs(Box * a_loBox,
00490 Box * a_hiBox,
00491 int * a_hasLo,
00492 int * a_hasHi,
00493 Box & a_curDblBox,
00494 Box & a_curPhiBox,
00495 int a_nComps,
00496 BaseFab<Real> & a_curOpPhiFAB,
00497 const BaseFab<Real> & a_curPhiFAB,
00498 bool a_homogeneousPhysBC,
00499 const DataIndex& a_dit);
00500
00501 void applyDomainFlux(Box * a_loBox,
00502 Box * a_hiBox,
00503 int * a_hasLo,
00504 int * a_hasHi,
00505 Box & a_dblBox,
00506 int a_nComps,
00507 BaseFab<Real> & a_phiFAB,
00508 bool a_homogeneousPhysBC,
00509 const DataIndex& a_dit);
00510
00511 void GSColorAllIrregular(EBCellFAB& a_phi,
00512 const EBCellFAB& a_rhs,
00513 const int& a_icolor,
00514 const DataIndex& a_dit);
00515
00516 static bool s_turnOffBCs;
00517 static bool s_forceNoEBCF;
00518 static bool s_doLazyRelax;
00519
00520
00521 virtual void calculateAlphaWeight();
00522 virtual void calculateRelaxationCoefficient();
00523
00524
00525 void defineEBCFStencils();
00526 void getFluxEBCF(EBFaceFAB& a_flux,
00527 const EBCellFAB& a_phi,
00528 const Box& a_ghostedBox,
00529 Vector<FaceIndex>& a_faceitEBCF,
00530 Vector<VoFStencil>& a_stenEBCF);
00531
00532 void getFluxRegOnly(EBFaceFAB& a_fluxCentroid,
00533 const EBCellFAB& a_phi,
00534 const Box& a_ghostedBox,
00535 const Real& a_dx,
00536 const DataIndex& a_datInd,
00537 const int& a_idir);
00538
00539
00540 LayoutData< Vector<FaceIndex> > m_faceitCoar[2*SpaceDim];
00541 LayoutData< Vector<VoFStencil> > m_stencilCoar[2*SpaceDim];
00542
00543
00544
00545 int m_relaxType;
00546 const IntVect m_ghostPhi;
00547 const IntVect m_ghostRHS;
00548
00549 RefCountedPtr<NWOEBQuadCFInterp> m_interpWithCoarser;
00550
00551 EBLevelGrid m_eblg;
00552 EBLevelGrid m_eblgFine;
00553 EBLevelGrid m_eblgCoar;
00554 EBLevelGrid m_eblgCoarMG;
00555 EBLevelGrid m_eblgCoarsenedFine;
00556
00557 RefCountedPtr<ConductivityBaseDomainBC> m_domainBC;
00558 RefCountedPtr<ConductivityBaseEBBC> m_ebBC;
00559
00560 Real m_dxFine;
00561 Real m_dx;
00562 Real m_dxCoar;
00563
00564 RefCountedPtr<LevelData<EBCellFAB> > m_acoef;
00565 RefCountedPtr<LevelData<EBFluxFAB> > m_bcoef;
00566 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_bcoIrreg;
00567
00568 Real m_alpha;
00569 Real m_beta;
00570
00571 LayoutData<BaseIVFAB<Real> > m_alphaDiagWeight;
00572
00573 LayoutData<BaseIVFAB<Real> > m_betaDiagWeight;
00574 int m_refToFine;
00575 int m_refToCoar;
00576 bool m_hasEBCF;
00577 bool m_hasFine;
00578 bool m_hasInterpAve;
00579 bool m_hasCoar;
00580
00581
00582 EBMGAverage m_ebAverage;
00583
00584 EBMGInterp m_ebInterp;
00585
00586
00587 LayoutData<RefCountedPtr<VCAggStencil> > m_opEBStencil;
00588
00589
00590
00591 LevelData<EBCellFAB> m_relCoef;
00592
00593
00594
00595 LayoutData<VoFIterator > m_vofIterIrreg;
00596 LayoutData<VoFIterator > m_vofIterMulti;
00597
00598 LayoutData<VoFIterator > m_vofIterDomLo[CH_SPACEDIM];
00599 LayoutData<VoFIterator > m_vofIterDomHi[CH_SPACEDIM];
00600
00601
00602
00603 LayoutData<CFIVS> m_loCFIVS[SpaceDim];
00604 LayoutData<CFIVS> m_hiCFIVS[SpaceDim];
00605
00606
00607 EBFastFR m_fastFR;
00608
00609
00610
00611
00612 bool m_hasMGObjects;
00613 bool m_layoutChanged;
00614
00615 EBMGAverage m_ebAverageMG;
00616 EBMGInterp m_ebInterpMG;
00617 DisjointBoxLayout m_dblCoarMG;
00618 EBISLayout m_ebislCoarMG;
00619 ProblemDomain m_domainCoarMG;
00620
00621 Vector<IntVect> m_colors;
00622 Copier m_exchangeCopier;
00623
00624 private:
00625
00626 void incrementFRCoar(EBFastFR& a_fluxReg,
00627 const LevelData<EBCellFAB>& a_phiFine,
00628 const LevelData<EBCellFAB>& a_phi);
00629
00630 void incrementFRFine(EBFastFR& a_fluxReg,
00631 const LevelData<EBCellFAB>& a_phiFine,
00632 const LevelData<EBCellFAB>& a_phi,
00633 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00634
00635 void getFlux(FArrayBox& a_flux,
00636 const FArrayBox& a_phi,
00637 const Box& a_faceBox,
00638 const int& a_idir,
00639 const Real& a_dx,
00640 const DataIndex& a_datInd);
00641
00642
00643
00644 void getOpVoFStencil(VoFStencil& a_stencil,
00645 const EBISBox& a_ebisbox,
00646 const VolIndex& a_vof);
00647
00648 void getOpVoFStencil(VoFStencil& a_stencil,
00649 const int& a_dir,
00650 const Vector<VolIndex>& a_allMonotoneVoFs,
00651 const EBISBox& a_ebisbox,
00652 const VolIndex& a_vof,
00653 const bool& a_lowOrder);
00654
00655
00656 void getOpFaceStencil(VoFStencil& a_stencil,
00657 const Vector<VolIndex>& a_allMonotoneVofs,
00658 const EBISBox& a_ebisbox,
00659 const VolIndex& a_vof,
00660 int a_dir,
00661 const Side::LoHiSide& a_side,
00662 const FaceIndex& a_face,
00663 const bool& a_lowOrder);
00664
00665 private:
00666
00667
00668 NWOEBConductivityOp();
00669
00670
00671 NWOEBConductivityOp(const NWOEBConductivityOp& a_opin)
00672 {
00673 MayDay::Error("invalid operator");
00674 }
00675
00676 void operator=(const NWOEBConductivityOp& a_opin)
00677 {
00678 MayDay::Error("invalid operator");
00679 }
00680 };
00681
00682
00683 #include "NamespaceFooter.H"
00684 #endif