00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _EBVISCOUSTENSOROP_H_
00012 #define _EBVISCOUSTENSOROP_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
00027 #include "EBLevelDataOps.H"
00028 #include "BaseEBBC.H"
00029 #include "AMRTGA.H"
00030 #include "BaseDomainBC.H"
00031 #include "CFIVS.H"
00032 #include "EBFluxRegister.H"
00033 #include "EBMGAverage.H"
00034 #include "EBMGInterp.H"
00035 #include "EBTensorCFInterp.H"
00036 #include "EBCoarsen.H"
00037 #include "PolyGeom.H"
00038 #include "EBQuadCFInterp.H"
00039 #include "EBLevelGrid.H"
00040 #include "NamespaceHeader.H"
00041
00043
00047
00048 class EBViscousTensorOp: public LevelTGAHelmOp<LevelData<EBCellFAB>, EBFluxFAB >
00049 {
00050 public:
00051
00053 virtual void setAlphaAndBeta(const Real& a_alpha,
00054 const Real& a_beta)
00055 {
00056 m_alpha = a_alpha;
00057 m_beta = a_beta;
00058 defineStencils();
00059 }
00060
00062 virtual void diagonalScale(LevelData<EBCellFAB> & a_rhs)
00063 {
00064 EBLevelDataOps::kappaWeight(a_rhs);
00065 for(DataIterator dit = m_eblg.getDBL().dataIterator(); dit.ok(); ++dit)
00066 {
00067 for(int idir = 0; idir < SpaceDim; idir++)
00068 {
00069 int isrc = 0; int idst = idir; int inco = 1;
00070 a_rhs[dit()].mult((*m_acoef)[dit()], isrc, idst, inco);
00071 }
00072 }
00073 }
00074
00076 virtual void fillGrad(const LevelData<EBCellFAB>& a_phi);
00077
00079 virtual void getFlux(EBFluxFAB& a_flux,
00080 const LevelData<EBCellFAB>& a_data,
00081 const Box& a_grid,
00082 const DataIndex& a_dit,
00083 Real a_scale)
00084 {
00085 a_flux.define(m_eblg.getEBISL()[a_dit], a_grid, SpaceDim);
00086 a_flux.setVal(0.);
00087 for(int idir = 0; idir < SpaceDim; idir++)
00088 {
00089 FArrayBox& regFlux = (FArrayBox&) a_flux[idir ].getSingleValuedFAB();
00090 const FArrayBox& regData = (const FArrayBox&) a_data[a_dit].getSingleValuedFAB();
00091 const FArrayBox& regGrad = (const FArrayBox&) m_grad[a_dit].getSingleValuedFAB();
00092 Box faceBox = surroundingNodes(a_grid, idir);
00093 getFlux(regFlux, regData, regGrad, faceBox, idir, a_dit);
00094 }
00095 }
00096
00098 virtual void applyOpNoBoundary(LevelData<EBCellFAB>& a_opPhi,
00099 const LevelData<EBCellFAB>& a_phi)
00100 {
00101 s_turnOffBCs = true;
00102 applyOp(a_opPhi, a_phi, true);
00103 s_turnOffBCs = false;
00104 }
00105
00106
00107
00109
00111 EBViscousTensorOp(const EBLevelGrid & a_eblgFine,
00112 const EBLevelGrid & a_eblg,
00113 const EBLevelGrid & a_eblgCoar,
00114 const EBLevelGrid & a_eblgCoarMG,
00115 const Real& a_alpha,
00116 const Real& a_beta,
00117 const RefCountedPtr<LevelData<EBCellFAB> >& a_acoef,
00118 const RefCountedPtr<LevelData<EBFluxFAB> >& a_eta,
00119 const RefCountedPtr<LevelData<EBFluxFAB> >& a_lambda,
00120 const RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_etaIrreg,
00121 const RefCountedPtr<LevelData<BaseIVFAB<Real> > >& a_lambdaIrreg,
00122 const Real& a_dx,
00123 const Real& a_dxCoar,
00124 const int& a_refToFine,
00125 const int& a_refToCoar,
00126 const RefCountedPtr<ViscousBaseDomainBC>& a_domainBC,
00127 const RefCountedPtr<ViscousBaseEBBC>& a_ebBC,
00128 const bool& a_hasMGObjects,
00129 const IntVect& a_ghostCellsPhi,
00130 const IntVect& a_ghostCellsRHS);
00131
00133 virtual ~EBViscousTensorOp();
00134
00136
00137 void AMRResidualNC(LevelData<EBCellFAB>& a_residual,
00138 const LevelData<EBCellFAB>& a_phiFine,
00139 const LevelData<EBCellFAB>& a_phi,
00140 const LevelData<EBCellFAB>& a_rhs,
00141 bool a_homogeneousBC,
00142 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00143
00144
00146
00147 void AMROperatorNC(LevelData<EBCellFAB>& a_LofPhi,
00148 const LevelData<EBCellFAB>& a_phiFine,
00149 const LevelData<EBCellFAB>& a_phi,
00150 bool a_homogeneousBC,
00151 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00152
00154
00156 virtual void residual(LevelData<EBCellFAB>& a_residual,
00157 const LevelData<EBCellFAB>& a_phi,
00158 const LevelData<EBCellFAB>& a_rhs,
00159 bool a_homogeneousPhysBC=false);
00160
00162
00164 virtual void preCond(LevelData<EBCellFAB>& a_opPhi,
00165 const LevelData<EBCellFAB>& a_phi);
00166
00167
00169
00172 virtual void applyOp(LevelData<EBCellFAB>& a_opPhi,
00173 const LevelData<EBCellFAB>& a_phi,
00174 bool a_homogeneousPhysBC);
00175
00177
00179 virtual void create(LevelData<EBCellFAB>& a_lhs,
00180 const LevelData<EBCellFAB>& a_rhs);
00181
00183 virtual void createCoarsened(LevelData<EBCellFAB>& a_lhs,
00184 const LevelData<EBCellFAB>& a_rhs,
00185 const int& a_refRat);
00186
00188 Real
00189 AMRNorm(const LevelData<EBCellFAB>& a_coarResid,
00190 const LevelData<EBCellFAB>& a_fineResid,
00191 const int& a_refRat,
00192 const int& a_ord);
00193
00194
00196
00198 virtual void assign(LevelData<EBCellFAB>& a_lhs,
00199 const LevelData<EBCellFAB>& a_rhs);
00200
00202
00204 virtual Real dotProduct(const LevelData<EBCellFAB>& a_1,
00205 const LevelData<EBCellFAB>& a_2);
00206
00208
00210 virtual void incr(LevelData<EBCellFAB>& a_lhs,
00211 const LevelData<EBCellFAB>& a_x,
00212 Real a_scale);
00213
00215
00217 virtual void axby(LevelData<EBCellFAB>& a_lhs,
00218 const LevelData<EBCellFAB>& a_x,
00219 const LevelData<EBCellFAB>& a_y,
00220 Real a_a,
00221 Real a_b);
00222
00224
00226 virtual void scale(LevelData<EBCellFAB>& a_lhs,
00227 const Real& a_scale);
00228
00230
00232 virtual Real norm(const LevelData<EBCellFAB>& a_rhs,
00233 int a_ord);
00234
00236
00238 virtual void setToZero(LevelData<EBCellFAB>& a_lhs);
00239
00241
00243 virtual void setVal(LevelData<EBCellFAB>& a_lhs, const Real& a_value);
00244
00246
00248 virtual void createCoarser(LevelData<EBCellFAB>& a_coarse,
00249 const LevelData<EBCellFAB>& a_fine,
00250 bool a_ghosted);
00251
00253
00255 virtual void relax(LevelData<EBCellFAB>& a_e,
00256 const LevelData<EBCellFAB>& a_residual,
00257 int a_iterations);
00258
00260
00264 virtual void restrictResidual(LevelData<EBCellFAB>& a_resCoarse,
00265 LevelData<EBCellFAB>& a_phiFine,
00266 const LevelData<EBCellFAB>& a_rhsFine);
00267
00269
00273 virtual void prolongIncrement(LevelData<EBCellFAB>& a_phiThisLevel,
00274 const LevelData<EBCellFAB>& a_correctCoarse);
00275
00277
00279 virtual int refToCoarser();
00280
00282
00284 virtual int refToFiner();
00285
00287
00288 virtual void AMRResidual(LevelData<EBCellFAB>& a_residual,
00289 const LevelData<EBCellFAB>& a_phiFine,
00290 const LevelData<EBCellFAB>& a_phi,
00291 const LevelData<EBCellFAB>& a_phiCoarse,
00292 const LevelData<EBCellFAB>& a_rhs,
00293 bool a_homogeneousBC,
00294 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00295
00297
00298 virtual void AMRResidualNF(LevelData<EBCellFAB>& a_residual,
00299 const LevelData<EBCellFAB>& a_phi,
00300 const LevelData<EBCellFAB>& a_phiCoarse,
00301 const LevelData<EBCellFAB>& a_rhs,
00302 bool a_homogeneousBC);
00303
00304
00306
00307 virtual void AMROperator(LevelData<EBCellFAB>& a_LofPhi,
00308 const LevelData<EBCellFAB>& a_phiFine,
00309 const LevelData<EBCellFAB>& a_phi,
00310 const LevelData<EBCellFAB>& a_phiCoarse,
00311 bool a_homogeneousBC,
00312 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00313
00315
00316 virtual void AMROperatorNF(LevelData<EBCellFAB>& a_LofPhi,
00317 const LevelData<EBCellFAB>& a_phi,
00318 const LevelData<EBCellFAB>& a_phiCoarse,
00319 bool a_homogeneousBC);
00320
00322
00323 virtual void AMRRestrict(LevelData<EBCellFAB>& a_resCoarse,
00324 const LevelData<EBCellFAB>& a_residual,
00325 const LevelData<EBCellFAB>& a_correction,
00326 const LevelData<EBCellFAB>& a_coarseCorrection);
00327
00329
00330 virtual void AMRProlong(LevelData<EBCellFAB>& a_correction,
00331 const LevelData<EBCellFAB>& a_coarseCorrection);
00332
00334
00335 virtual void AMRUpdateResidual(LevelData<EBCellFAB>& a_residual,
00336 const LevelData<EBCellFAB>& a_correction,
00337 const LevelData<EBCellFAB>& a_coarseCorrection);
00338
00340
00341 static void
00342 getDivergenceStencil(VoFStencil& a_divStencil,
00343 const FaceIndex& a_face,
00344 const DataIndex& a_dit,
00345 const Real & a_dx,
00346 const EBLevelGrid& a_eblg);
00347
00349
00350 static void
00351 getGradientStencil(VoFStencil& a_gradStencil,
00352 int a_ivar,
00353 int a_diffDir,
00354 const FaceIndex& a_face,
00355 const DataIndex& a_dit,
00356 const Real & a_dx,
00357 const EBLevelGrid& a_eblg);
00358 protected:
00359
00360
00361
00362
00363 void incrOpRegularDir(EBCellFAB& a_lhs,
00364 const EBCellFAB& a_phi,
00365 const bool& a_homogeneous,
00366 const int& a_dir,
00367 const DataIndex& a_datInd);
00368
00369 void applyOpIrregular(EBCellFAB& a_lhs,
00370 const EBCellFAB& a_phi,
00371 const bool& a_homogeneous,
00372 const DataIndex& a_datInd);
00373
00374 void getFlux(FArrayBox& a_flux,
00375 const FArrayBox& a_phi,
00376 const FArrayBox& a_gradPhi,
00377 const Box& a_faceBox,
00378 const int& a_idir,
00379 const DataIndex& a_datInd);
00380 void
00381 homogeneousCFInterp(EBCellFAB& a_phi,
00382 const DataIndex& a_datInd,
00383 const int& a_idir,
00384 const Side::LoHiSide& a_hiorlo);
00385 void
00386 cfinterp(const LevelData<EBCellFAB>& a_phi,
00387 const LevelData<EBCellFAB>& a_phiCoarse);
00388
00389 void reflux(const LevelData<EBCellFAB>& a_phiFine,
00390 const LevelData<EBCellFAB>& a_phi,
00391 LevelData<EBCellFAB>& residual,
00392 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00393
00394 void homogeneousCFInterp(LevelData<EBCellFAB>& a_phi);
00395
00396 void defineStencils();
00397
00398 void getVoFStencil(VoFStencil& a_vofStencil,
00399 const VolIndex& a_vof,
00400 const DataIndex& a_dit,
00401 int a_ivar);
00402
00403 void getFluxStencil(VoFStencil& a_fluxStencil,
00404 const FaceIndex& a_face,
00405 const DataIndex& a_dit,
00406 int a_ivar);
00407
00408 void getDivergenceStencil(VoFStencil& a_gradStencil,
00409 const FaceIndex& a_face,
00410 const DataIndex& a_dit);
00411
00412 void getGradientStencil(VoFStencil& a_gradStencil,
00413 int a_ivar,
00414 int a_diffDir,
00415 const FaceIndex& a_face,
00416 const DataIndex& a_dit);
00417
00418
00419 void gsrbColor(LevelData<EBCellFAB>& a_phi,
00420 const LevelData<EBCellFAB>& a_lph,
00421 const LevelData<EBCellFAB>& a_rhs,
00422 const IntVect& a_color);
00423
00424 void getFaceCenteredFluxStencil(VoFStencil& a_fluxStencil,
00425 const FaceIndex& a_face,
00426 const DataIndex& a_dit,
00427 int a_ivar);
00428
00429 void cellGrad(EBCellFAB& a_gradPhi,
00430 const EBCellFAB& a_phi,
00431 const Box& a_grid,
00432 const DataIndex& a_datInd);
00433
00434 void
00435 incrementFRCoar(const LevelData<EBCellFAB>& a_phiFine,
00436 const LevelData<EBCellFAB>& a_phi);
00437
00438
00439 void
00440 incrementFRFine(const LevelData<EBCellFAB>& a_phiFine,
00441 const LevelData<EBCellFAB>& a_phi,
00442 AMRLevelOp<LevelData<EBCellFAB> >* a_finerOp);
00443
00444
00445 static bool s_turnOffBCs;
00446
00447 LayoutData<CFIVS> m_loCFIVS[CH_SPACEDIM];
00448 LayoutData<CFIVS> m_hiCFIVS[CH_SPACEDIM];
00449
00450
00451 EBLevelGrid m_eblgFine;
00452 EBLevelGrid m_eblg;
00453 EBLevelGrid m_eblgCoar;
00454 EBLevelGrid m_eblgCoarMG;
00455
00456
00457 Real m_alpha;
00458 Real m_beta;
00459 RefCountedPtr<LevelData<EBCellFAB> > m_acoef;
00460 RefCountedPtr<LevelData<EBFluxFAB> > m_eta;
00461 RefCountedPtr<LevelData<EBFluxFAB> > m_lambda;
00462 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_etaIrreg;
00463 RefCountedPtr<LevelData<BaseIVFAB<Real> > > m_lambdaIrreg;
00464
00465
00466
00467 EBFluxRegister m_fluxReg;
00468
00469
00470
00471
00472 Real m_dx;
00473 Real m_dxCoar;
00474
00475
00476 bool m_hasFine;
00477 bool m_hasCoar;
00478 int m_refToFine;
00479 int m_refToCoar;
00480 bool m_hasMGObjects;
00481
00482
00483 IntVect m_ghostCellsPhi;
00484 IntVect m_ghostCellsRHS;
00485
00486
00487 LayoutData<RefCountedPtr<EBStencil> > m_stencil[CH_SPACEDIM];
00488
00489
00490 LevelData<EBCellFAB> m_relCoef;
00491
00492
00493 LevelData<EBCellFAB> m_grad;
00494
00495
00496 LayoutData<VoFIterator > m_vofIter;
00497 LayoutData<VoFIterator > m_vofMult;
00498
00499 LayoutData<VoFIterator > m_vofIterDomLo[CH_SPACEDIM];
00500 LayoutData<VoFIterator > m_vofIterDomHi[CH_SPACEDIM];
00501
00502
00503 RefCountedPtr<EBTensorCFInterp> m_interpWithCoarser;
00504
00505
00506 EBMGAverage m_ebAverage;
00507 EBMGAverage m_ebAverageMG;
00508
00509
00510 EBMGInterp m_ebInterp;
00511 EBMGInterp m_ebInterpMG;
00512
00513
00514 RefCountedPtr<ViscousBaseDomainBC> m_domainBC;
00515 RefCountedPtr<ViscousBaseEBBC> m_ebBC;
00516 Vector<IntVect> m_colors;
00517 private:
00519 EBViscousTensorOp()
00520 {
00521 MayDay::Error("invalid operator");
00522 }
00523
00524
00525 EBViscousTensorOp(const EBViscousTensorOp& a_opin)
00526 {
00527 MayDay::Error("invalid operator");
00528 }
00529
00530 void operator=(const EBViscousTensorOp& a_opin)
00531 {
00532 MayDay::Error("invalid operator");
00533 }
00534 };
00535
00536
00537 #include "NamespaceFooter.H"
00538 #endif