00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _EBARITH_H_
00012 #define _EBARITH_H_
00013
00014 #include "EBCellFAB.H"
00015 #include "EBISBox.H"
00016 #include "EBISLayout.H"
00017 #include "EBFaceFAB.H"
00018 #include "BoxLayout.H"
00019 #include "BoxLayoutData.H"
00020 #include "Stencils.H"
00021 #include "LayoutData.H"
00022 #include "Tuple.H"
00023 #include "EBFluxFAB.H"
00024 #include "EBCellFAB.H"
00025 #include "NamespaceHeader.H"
00027
00035 class EBNormType
00036 {
00037 public:
00038
00040
00048 enum NormMode{OverOnlyRegular=0, OverOnlyIrregular, OverBoth};
00049 };
00050
00052
00056 class EBArith
00057 {
00058 public:
00060
00062 static int orderScript(int icomp, int inorm, int ncomp);
00063
00065
00067 static void
00068 compareError(Vector<Real>& a_orders,
00069 const Vector< LevelData<EBCellFAB>* >& a_errorFine,
00070 const Vector< LevelData<EBCellFAB>* >& a_errorCoar,
00071 const Vector< DisjointBoxLayout >& a_gridsFine,
00072 const Vector< DisjointBoxLayout >& a_gridsCoar,
00073 const Vector< EBISLayout >& a_ebislFine,
00074 const Vector< EBISLayout >& a_ebislCoar,
00075 const Vector<int>& a_refRat,
00076 const Box& a_coarseDom,
00077 int a_testverbosity);
00078
00080 static void shrinkIVS(IntVectSet& a_ivs, const int& a_numShrink);
00081
00082 static void
00083 timeInterpolate(LevelData<EBCellFAB>& a_U,
00084 const LevelData<EBCellFAB>& a_UOld,
00085 const LevelData<EBCellFAB>& a_UNew,
00086 const DisjointBoxLayout& a_grids,
00087 const Real& a_time,
00088 const Real& a_told,
00089 const Real& a_tnew);
00091 static Real
00092 getDiagWeight( VoFStencil& a_vofStencil,
00093 const VolIndex& a_vof);
00094
00096 static void getMultiColors(Vector<IntVect>& a_colors);
00097
00099 static void
00100 interpolateCFH(EBCellFAB& a_phi,
00101 const int & a_idir,
00102 const Side::LoHiSide& a_hiorlo,
00103 const EBISBox& a_ebisBox,
00104 const Real& a_dxfine,
00105 const Real& a_dxcoar,
00106 const IntVectSet& a_interpIVS);
00107
00109
00115 static int
00116 getExtrapolationStencil(VoFStencil& a_stencil,
00117 const RealVect& a_dist,
00118 const RealVect& a_dx,
00119 const VolIndex& a_startVoF,
00120 const EBISBox& a_ebisBox,
00121 int a_noExtrapThisDirection = -1,
00122 IntVectSet* a_cfivsPtr = NULL,
00123 int ivar = 0);
00124
00126
00128 static void
00129 getDir1Dir2(int& a_dir1, int& a_dir2, const int& a_dir);
00130
00132
00135 static void
00136 loHiCenter(Box& a_loBox,
00137 int& a_hasLo,
00138 Box& a_hiBox,
00139 int& a_hasHi,
00140 Box& a_centerBox,
00141 const ProblemDomain & a_eblg,
00142 const Box& a_inBox,
00143 const int& a_dir,
00144 IntVectSet* a_cfivsPtr = NULL);
00145
00147
00149 static void
00150 loHi(Box& a_loBox,
00151 int& a_hasLo,
00152 Box& a_hiBox,
00153 int& a_hasHi,
00154 const ProblemDomain& a_eblg,
00155 const Box& a_inBox,
00156 const int& a_dir);
00157
00159
00163 static bool getCoarserLayouts(DisjointBoxLayout& a_dblCoar,
00164 ProblemDomain& a_domainCoar,
00165 const DisjointBoxLayout& a_dblFine,
00166 const ProblemDomain& a_domainFine,
00167 int a_refToCoar,
00168 int a_maxBoxSize,
00169 bool& a_layoutChanged,
00170 int a_testRef = 2);
00171
00173
00181 static int
00182 getFirstDerivStencil(VoFStencil& a_sten,
00183 const VolIndex& a_vof,
00184 const EBISBox& a_ebisBox,
00185 const int& a_idir,
00186 const Real& a_dx,
00187 IntVectSet* a_cfivsPtr = NULL,
00188 int ivar = 0);
00189
00190
00192
00199 static int
00200 getMixedDerivStencil(VoFStencil& a_sten,
00201 const VolIndex& a_vof,
00202 const EBISBox& a_ebisBox,
00203 const int& a_dir1,
00204 const int& a_dir2,
00205 const Real& a_dx1,
00206 const Real& a_dx2,
00207 IntVectSet* a_cfivsPtr = NULL,
00208 int ivar = 0);
00209
00211
00218 static int
00219 getSecondDerivStencil(VoFStencil& a_sten,
00220 const VolIndex& a_vof,
00221 const EBISBox& a_ebisBox,
00222 const int& a_idir,
00223 const Real& a_dx,
00224 IntVectSet* a_cfivsPtr = NULL,
00225 int ivar = 0);
00226
00228
00231 static void
00232 getVoFsDir(bool& a_hasClose, VolIndex& a_closeVoF,
00233 bool& a_hasFar, VolIndex& a_farVoF,
00234 const EBISBox& a_ebisBox,
00235 const VolIndex& a_vof,
00236 int a_idir, Side::LoHiSide a_sd,
00237 IntVectSet* a_cfivsPtr);
00238
00240
00244 static void
00245 defineCFIVS(LayoutData<IntVectSet>& a_cfivs,
00246 const DisjointBoxLayout& a_grids,
00247 const ProblemDomain& a_probDom);
00248
00250 static Real
00251 extrapToDomainFace(const FaceIndex& a_bndryFace,
00252 const Side::LoHiSide& a_side,
00253 const int& a_idir,
00254 const EBGraph& a_ebGraph,
00255 const EBFaceFAB& a_faceData,
00256 const int& a_comp);
00257
00259 static Real
00260 interpolateVel(const EBFaceFAB& a_vel,
00261 const EBISBox& a_ebisBox,
00262 const FaceIndex& a_face);
00263
00265 static Real
00266 deInterpolateVel(const Real& a_centroidVel,
00267 const EBFaceFAB& a_vel,
00268 const EBISBox& a_ebisBox,
00269 const FaceIndex& a_face);
00270
00272 static Real
00273 getFaceVelForDivFreeCell(const FaceIndex& a_face,
00274 const VolIndex& a_vof,
00275 const int& a_idir,
00276 const Side::LoHiSide& a_side,
00277 const EBFluxFAB& a_vel,
00278 const RealVect& a_dx,
00279 const EBISBox& a_ebisBox);
00281
00286 static void
00287 meanOverHierarchy(Real& a_mean,
00288 const Vector<LevelData<EBCellFAB> *>& a_divu,
00289 const Vector<DisjointBoxLayout>& a_grids,
00290 const Vector<EBISLayout>& a_ebisl,
00291 const Vector<int>& a_refRat,
00292 const ProblemDomain& a_domainCoarsest,
00293 const RealVect& a_dxCoarsest,
00294 const int& a_comp,
00295 int pval= -1);
00296
00298
00302 static Real
00303 getJohanVoFWeight(const VolIndex& a_whichVoF,
00304 const RealVect& a_intersectLoc,
00305 const IntVect& a_intersectIV,
00306 const int& a_nMaxDir,
00307 const RealVect& a_dx);
00308
00310
00314 static void
00315 johanStencil(bool& a_dropOrder,
00316 Vector<VoFStencil>& a_pointStencils,
00317 Vector<Real>& a_distanceAlongLine,
00318 const RealVect& a_normal,
00319 const RealVect& a_bndryCentroid,
00320 const VolIndex& a_vof,
00321 const EBISBox& a_ebisBox,
00322 const RealVect& a_dx,
00323 const IntVectSet& a_cfivs,
00324 int a_ivar = 0);
00325
00327
00332 static void
00333 johanStencil(bool& a_dropOrder,
00334 Vector<VoFStencil>& a_pointStencils,
00335 Vector<Real>& a_distanceAlongLine,
00336 const VolIndex& a_vof,
00337 const EBISBox& a_ebisBox,
00338 const RealVect& a_dx,
00339 const IntVectSet& a_cfivs,
00340 int a_ivar = 0);
00341
00343
00346 static void
00347 getLeastSquaresGradSten(VoFStencil& a_stencil,
00348 Real& a_weight,
00349 const VolIndex& a_vof,
00350 const EBISBox& a_ebisBox,
00351 const RealVect& a_dx,
00352 const ProblemDomain& a_domain,
00353 int a_ivar = 0);
00354
00356
00360 static void
00361 getLeastSquaresGradSten(VoFStencil& a_stencil,
00362 Real& a_weight,
00363 const RealVect& a_normal ,
00364 const RealVect& a_centroid,
00365 const VolIndex& a_vof,
00366 const EBISBox& a_ebisBox,
00367 const RealVect& a_dx,
00368 const ProblemDomain& a_domain,
00369 int a_ivar = 0);
00370
00371
00373
00377 static void
00378 getLeastSquaresGradSten(VoFStencil& a_stencil,
00379 Real& a_weight,
00380 const RealVect& a_normal ,
00381 const RealVect& a_centroid,
00382 const IntVect& a_quadrant,
00383 const VolIndex& a_vof,
00384 const EBISBox& a_ebisBox,
00385 const RealVect& a_dx,
00386 const ProblemDomain& a_domain,
00387 int a_ivar = 0);
00388
00391
00395 static void
00396 getLeastSquaresGradStenAll(VoFStencil& a_stencil,
00397 Real& a_weight,
00398 const RealVect& a_normal,
00399 const RealVect& a_centroid,
00400 const VolIndex& a_vof,
00401 const EBISBox& a_ebisBox,
00402 const RealVect& a_dx,
00403 const ProblemDomain& a_domain,
00404 int a_ivar);
00405
00407 static RealVect getDomainNormal(int a_idir, Side::LoHiSide a_side);
00408
00410 static RealVect getFaceLocation(const FaceIndex& a_face,
00411 const RealVect& a_dx,
00412 const RealVect& a_probLo);
00413
00415 static RealVect getVofLocation(const VolIndex& a_vof,
00416 const RealVect& a_dx,
00417 const RealVect& a_probLo);
00418
00420 static RealVect getIVLocation(const IntVect& a_iv,
00421 const RealVect& a_dx,
00422 const RealVect& a_probLo);
00423
00425
00428 static void
00429 defineFluxInterpolant(LevelData<BaseIFFAB<Real> >& a_fluxInterpolant,
00430 LayoutData<IntVectSet> & a_irregSetsGrown,
00431 const DisjointBoxLayout & a_dbl,
00432 const EBISLayout & a_ebisl,
00433 const ProblemDomain & a_domain,
00434 const int & a_ncomp,
00435 const int & a_faceDir);
00436
00438 static void
00439 interpolateFluxToCentroids(LevelData<EBFluxFAB>& a_centroidFlux,
00440 const LevelData<EBFluxFAB>& a_faceCentFlux,
00441 const DisjointBoxLayout& a_grids,
00442 const EBISLayout& a_ebisl,
00443 const ProblemDomain& a_domain);
00444
00446 static void
00447 interpolateFluxToCentroids(EBFaceFAB& a_centroidFlux,
00448 const EBFaceFAB& a_faceCentFlux,
00449 const Box& a_box,
00450 const EBISBox& a_ebisBox,
00451 const ProblemDomain& a_domain,
00452 const int& a_idir);
00453
00455 static void
00456 irregNorm(Real& a_ebIrregNorm,
00457 const BaseIVFAB<Real>& a_ebiError,
00458 const IntVectSet& a_ivsIrreg,
00459 const EBISBox& a_ebisBox,
00460 const int& a_comp,
00461 const int& a_normtype);
00462
00464 static FaceStencil getInterpStencil(const FaceIndex& a_face,
00465 const IntVectSet& a_coarseFineIVS,
00466 const EBISBox& a_ebisBox,
00467 const ProblemDomain& a_domainBox);
00468
00470 static void getInterpStencil2D(FaceStencil& a_sten,
00471 const FaceIndex& a_face,
00472 const IntVectSet& a_coarseFineIVS,
00473 const EBISBox& a_ebisBox,
00474 const ProblemDomain& a_domainBox) ;
00475
00477 static void getInterpStencil3D(FaceStencil& a_sten,
00478 const FaceIndex& a_face,
00479 const IntVectSet& a_coarseFineIVS,
00480 const EBISBox& a_ebisBox,
00481 const ProblemDomain& a_domainBox);
00482
00484
00488 static bool
00489 isVoFHere(VolIndex& a_vof,
00490 const Vector<VolIndex>& a_vofsStencil,
00491 const IntVect& a_cell );
00492
00494
00497 static void
00498 getAllVoFsInMonotonePath(Vector<VolIndex>& a_vofList,
00499 const VolIndex& a_vof,
00500 const EBISBox& a_ebisBox,
00501 const int& a_redistRad);
00502
00504 static void
00505 getKVolRZ(Real& a_kvol,
00506 Real& a_cellVol,
00507 const EBISBox& a_ebisBox,
00508 const Real& a_dx,
00509 const VolIndex& a_vof);
00510
00512 static void
00513 getKVolRZNoDx(Real& a_kvol,
00514 Real& a_cellVolDx3,
00515 const EBISBox& a_ebisBox,
00516 const VolIndex& a_vof);
00517
00519
00523 static
00524 bool
00525 getAdjacentFace(FaceIndex& a_adjacentFace,
00526 const FaceIndex& a_face,
00527 const EBISBox& a_ebisBox,
00528 const ProblemDomain& a_domain,
00529 const int& a_idir,
00530 const Side::LoHiSide& a_side);
00531
00533
00537 static
00538 void computeGradFluxStencil(VoFStencil& a_thisStencil,
00539 const FaceIndex& a_thisFace,
00540 const EBISBox& a_ebisBox,
00541 const ProblemDomain& a_domain,
00542 const int& a_dir);
00543
00545
00549 static
00550 void computeInterpStencil(FaceStencil& a_thisStencil,
00551 const FaceIndex& a_thisFace,
00552 const EBISBox& a_ebisBox,
00553 const ProblemDomain& a_domain,
00554 const int& a_dir);
00555
00557
00569 static
00570 void
00571 volWeightedSum(Real& a_norm,
00572 Real& a_volume,
00573 const EBCellFAB& a_src,
00574 const Box& a_region,
00575 const EBISBox& a_ebisBox,
00576 const RealVect& a_dx,
00577 const IntVectSet& a_ivsExclude,
00578 const int& a_comp,
00579 const int& a_p,
00580 EBNormType::NormMode = EBNormType::OverBoth);
00581
00582
00583 static void
00584 getCompVolRZ(Real& a_compVol,
00585 const EBISBox& a_ebisBox,
00586 const Real& a_dx,
00587 const VolIndex& a_vof,
00588 bool a_verbose = false);
00590
00600 static
00601 void
00602 computeSum(Real& a_norm,
00603 Real& a_volume,
00604 const EBCellFAB& a_src,
00605 const Box& a_region,
00606 const EBISBox& a_ebisBox,
00607 const RealVect& a_dx,
00608 const IntVectSet& a_ivsExclude,
00609 const int& a_comp,
00610 EBNormType::NormMode = EBNormType::OverBoth);
00611
00612
00614
00624 static
00625 void
00626 computeUnweightedSum(Real& a_norm,
00627 Real& a_volume,
00628 const EBCellFAB& a_src,
00629 const Box& a_region,
00630 const EBISBox& a_ebisBox,
00631 const RealVect& a_dx,
00632 const IntVectSet& a_ivsExclude,
00633 const int& a_comp,
00634 EBNormType::NormMode = EBNormType::OverBoth);
00635
00637
00653 static
00654 Real
00655 norm(const BoxLayoutData<EBCellFAB >& a_dataOne,
00656 const BoxLayout& a_layout,
00657 const EBISLayout& a_ebisl,
00658 const int& comp,
00659 const int& p,
00660 EBNormType::NormMode = EBNormType::OverBoth);
00661
00662 static
00663 Real
00664 norm(const Vector<LevelData<EBCellFAB>* >& a_data,
00665 const Vector< DisjointBoxLayout > & a_layout,
00666 const Vector< EBISLayout >& a_ebisl,
00667 const Vector< int >& a_refRatio,
00668 const int& comp,
00669 const int& p,
00670 EBNormType::NormMode = EBNormType::OverBoth);
00671
00673 static
00674 void
00675 computeCoveredFaces(Vector<VolIndex>& a_coveredFace,
00676 IntVectSet& a_coveredSets,
00677 IntVectSet& a_irregIVS,
00678 const int& a_idir,
00679 const Side::LoHiSide& a_sd,
00680 const EBISBox& a_ebisBox,
00681 const Box& a_region);
00682
00683
00684 static
00685 Real
00686 norm(Real& volume, const BoxLayoutData<EBCellFAB >& a_dataOne,
00687 const BoxLayout& a_layout,
00688 const EBISLayout& a_ebisl,
00689 const int& comp,
00690 const int& p,
00691 EBNormType::NormMode = EBNormType::OverBoth);
00692
00694
00706 static
00707 Real
00708 norm(const EBCellFAB& a_dataOne,
00709 const Box& a_grid,
00710 const EBISBox& a_ebisl,
00711 const int& a_comp,
00712 const int& a_p,
00713 EBNormType::NormMode = EBNormType::OverBoth);
00714
00715 static
00716 Real
00717 norm(Real& volume, const EBCellFAB& a_dataOne,
00718 const Box& a_grid,
00719 const EBISBox& a_ebisl,
00720 const int& a_comp,
00721 const int& a_p,
00722 EBNormType::NormMode = EBNormType::OverBoth);
00723
00725
00736 static
00737 void
00738 volWeightedSum(Real& a_sum,
00739 Real& a_volume,
00740 const BoxLayoutData<EBCellFAB >& a_dataOne,
00741 const BoxLayout& a_layout,
00742 const EBISLayout& a_ebisl,
00743 const RealVect& a_dx,
00744 const IntVectSet& a_ivsExclude,
00745 const int& a_comp,
00746 const int& a_p,
00747 EBNormType::NormMode = EBNormType::OverBoth);
00748
00750
00752 static
00753 void
00754 sumBndryArea(Real& a_area,
00755 const BoxLayout& a_region,
00756 const EBISLayout& a_ebisl);
00757
00759
00762 static
00763 Real
00764 dotProduct(const BoxLayoutData<EBCellFAB >& a_dataOne,
00765 const BoxLayoutData<EBCellFAB >& a_dataTwo,
00766 const BoxLayout& a_layout,
00767 const EBISLayout& a_ebisl,
00768 const int& a_comp);
00769
00771
00774 static
00775 Real
00776 dotProduct(const EBCellFAB& a_dataOne,
00777 const EBCellFAB& a_dataTwo,
00778 const Box& a_layout,
00779 const EBISBox& a_ebisBox,
00780 const int& a_comp);
00781
00783
00789 static
00790 bool
00791 monotonePathVoFToCellVoF(VolIndex& a_vof2,
00792 const VolIndex& a_vof1,
00793 const IntVect& a_cell2,
00794 const EBISBox& a_ebisBox);
00796
00799 static
00800 void
00801 getAllVoFsInMonotonePath(Vector<VolIndex>& a_vofs,
00802 const IntVect& a_timesMoved,
00803 const IntVect& a_pathSign,
00804 const VolIndex& a_vof,
00805 const EBISBox& a_ebisBox,
00806 const int& a_radius);
00807
00808 static VolIndex& getVoFMax()
00809 {
00810 return s_vofMax;
00811 }
00812 static Real& getValMax()
00813 {
00814 return s_valMax;
00815 }
00816
00817 static void setMinVolumeFraction(Real a_minVolFrac)
00818 {
00819 s_minVolFrac = a_minVolFrac;
00820 }
00821
00822 private:
00823 static VolIndex s_vofMax;
00824 static Real s_valMax;
00825 static Real s_minVolFrac;
00826
00827 };
00828
00829 extern IntVect ebcoarsen (const IntVect& b,
00830 int refinement_ratio);
00831
00832 extern
00833 Box ebrefine (const Box& b,
00834 int refinement_ratio);
00835 extern
00836 ProblemDomain ebrefine (const ProblemDomain& b,
00837 int refinement_ratio);
00838
00839 extern Box ebcoarsen (const Box& b,
00840 int refinement_ratio);
00841 extern ProblemDomain ebcoarsen (const ProblemDomain& b,
00842 int refinement_ratio);
00843
00844 extern void ebrefine(DisjointBoxLayout& output,
00845 const DisjointBoxLayout& input,
00846 int refinement);
00847
00848 extern void ebcoarsen(DisjointBoxLayout& output,
00849 const DisjointBoxLayout& input,
00850 int refinement);
00851
00852 #include "NamespaceFooter.H"
00853 #endif