00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013 #ifndef _EBDATA_H_
00014 #define _EBDATA_H_
00015
00016 #include "REAL.H"
00017 #include "RealVect.H"
00018
00019 #include "EBGraph.H"
00020 #include "IrregNode.H"
00021 #include "BaseIVFAB.H"
00022 #include "BaseIFFAB.H"
00023
00024 #include "NamespaceHeader.H"
00025
00026 class EBIndexSpace;
00027
00028 template <class T>
00029 int linearSize(const T& inputT);
00030
00031 template <class T>
00032 void linearIn(T& a_outputT, const void* const inBuf);
00033
00034 template <class T>
00035 void linearOut(void* const a_outBuf, const T& inputT);
00036
00037 class BoundaryData
00038 {
00039 public:
00040 BoundaryData();
00041
00042 BoundaryData(const Real& bndryArea, const RealVect& normal,
00043 const RealVect& bndryCentroid, int phase,const VolIndex& index)
00044 :
00045 m_bndryArea(bndryArea),
00046 m_normal(normal),
00047 m_bndryCentroid(bndryCentroid),
00048 m_bndryPhase(phase),
00049 m_volIndex(index)
00050 {
00051 }
00052
00053 Real m_bndryArea;
00054 RealVect m_normal;
00055 RealVect m_bndryCentroid;
00056 int m_bndryPhase;
00057 VolIndex m_volIndex;
00058
00059
00060
00061
00062
00063
00064
00065 IndMomSpaceDim m_EBMoments;
00066
00067
00068
00069
00070
00071
00072 IndMomSpaceDim m_normalPartialDeriv[SpaceDim];
00073
00074
00075
00076
00077
00078
00079 IndMomSpaceDim m_EBNormalMoments[SpaceDim];
00080
00081 void
00082 setToZero()
00083 {
00084 m_bndryArea = 0.;
00085 m_bndryCentroid = RealVect::Zero;
00086 m_normal = BASISV(0);
00087 m_EBMoments.setToZero();
00088 for(int idir = 0; idir < SpaceDim; idir++)
00089 {
00090 m_normalPartialDeriv[idir].setToZero();
00091 m_EBNormalMoments [idir].setToZero();
00092
00093 }
00094 }
00095
00096 BoundaryData& operator=(const BoundaryData& a_in)
00097 {
00098 if(&a_in != this)
00099 {
00100 m_bndryArea = a_in.m_bndryArea;
00101 m_bndryCentroid = a_in.m_bndryCentroid;
00102 m_bndryPhase = a_in.m_bndryPhase;
00103 m_normal = a_in.m_normal;
00104 m_volIndex = a_in.m_volIndex;
00105 m_EBMoments = a_in.m_EBMoments;
00106 for(int idir = 0; idir < SpaceDim; idir++)
00107 {
00108 m_normalPartialDeriv[idir] = a_in.m_normalPartialDeriv[idir];
00109 m_EBNormalMoments [idir] = a_in.m_EBNormalMoments [idir];
00110 }
00111 }
00112 return *this;
00113 }
00114 };
00115
00116 template < >
00117 int linearSize(const BoundaryData& vdata);
00118 template < >
00119 void linearIn(BoundaryData& a_outputT, const void* const inBuf);
00120 template < >
00121 void linearOut(void* const a_outBuf, const BoundaryData& a_inputT);
00122
00123
00124
00125 class VolData
00126 {
00127 public:
00128 VolData();
00129 Real m_volFrac;
00130 RealVect m_volCentroid;
00131 BoundaryData m_averageFace;
00132 IndMomSpaceDim m_volumeMoments;
00133 Vector<BoundaryData> m_phaseFaces;
00134 void setToRegular(Real a_dx)
00135 {
00136 m_volFrac = 1.0;
00137 m_volCentroid = RealVect::Zero;
00138 m_volumeMoments.setRegular(a_dx);
00139 m_averageFace.setToZero();
00140 m_phaseFaces.resize(0);
00141 }
00142
00143 void setToCovered()
00144 {
00145 m_volFrac = 0.0;
00146 m_volCentroid = RealVect::Zero;
00147 m_averageFace.setToZero();
00148 m_volumeMoments.setToZero();
00149 m_phaseFaces.resize(0);
00150 }
00151 };
00152
00153
00154
00155 template < >
00156 int linearSize(const VolData& vdata);
00157 template < >
00158 void linearIn(VolData& a_outputT, const void* const inBuf);
00159 template < >
00160 void linearOut(void* const a_outBuf, const VolData& a_inputT);
00161
00162
00163
00164
00165 class FaceData
00166 {
00167 public:
00168 Real m_areaFrac;
00169 RealVect m_faceCentroid;
00170 IndMomSDMinOne m_faceMoments;
00171 void setToRegular(Real a_dx)
00172 {
00173 m_areaFrac = 0.;
00174 m_faceCentroid = RealVect::Zero;
00175 m_faceMoments.setRegular(a_dx);
00176 }
00177 void setToCovered()
00178 {
00179 m_areaFrac = 0.;
00180 m_faceCentroid = RealVect::Zero;
00181 m_faceMoments.setToZero();
00182 }
00183 };
00184
00185
00186 template < >
00187 int linearSize(const FaceData& vdata);
00188 template < >
00189 void linearIn(FaceData& a_outputT, const void* const inBuf);
00190 template < >
00191 void linearOut(void* const a_outBuf, const FaceData& a_inputT);
00192
00193
00194
00195
00196
00197
00198 class EBDataImplem
00199 {
00200
00201 public:
00202
00203
00204 EBDataImplem();
00205
00206
00207 ~EBDataImplem();
00208
00209
00210
00211
00212
00213 void define(const Box& box, int comps)
00214 {
00215 }
00216
00217
00218
00219
00220
00221
00222 EBDataImplem(const Box& a_box, int a_comps)
00223 {
00224 define(a_box, a_comps);
00225 }
00226
00227
00228
00229
00230
00231
00232
00233
00234 void copy(const Box& a_regionFrom,
00235 const Interval& a_Cd,
00236 const Box& a_regionto,
00237 const EBDataImplem& a_source,
00238 const Interval& a_Cs);
00239
00240
00241 void
00242 define(const EBGraph& a_graph,
00243 const Vector<IrregNode>& a_irregData,
00244 const Box& a_validBox,
00245 const Real & a_dx,
00246 bool a_hasMoments );
00247
00248
00249 void define(const EBGraph& a_graph,
00250 const Box& a_region,
00251 const Real& a_dx,
00252 bool a_hasMoments) ;
00253
00254
00255 void
00256 coarsenVoFs(const EBDataImplem& a_fineEBDataImplem,
00257 const EBGraph& a_fineGraph,
00258 const EBGraph& a_coarGraph,
00259 const Box& a_validRegion);
00260
00261
00262 void
00263 coarsenFaces(const EBDataImplem& a_fineEBDataImplem,
00264 const EBGraph& a_fineGraph,
00265 const EBGraph& a_coarGraph,
00266 const Box& a_validRegion);
00267
00268 const Real& volFrac(const VolIndex& a_vof) const;
00269
00270
00271 const Real& areaFrac(const FaceIndex& a_face1) const;
00272
00273
00274 const RealVect& centroid(const FaceIndex& facein) const;
00275
00276
00277 const RealVect& centroid(const VolIndex& a_vof) const;
00278
00279
00280 const RealVect& bndryCentroid(const VolIndex& a_vof) const;
00281 const RealVect& bndryCentroid(const VolIndex& a_vof, int face) const;
00282
00283
00284 const Real& bndryArea(const VolIndex& a_vof) const;
00285 const Real& bndryArea(const VolIndex& a_vof, int face) const;
00286
00287
00288 const RealVect& normal(const VolIndex& a_vof) const;
00289 const RealVect& normal(const VolIndex& a_vof, int face) const;
00290
00291
00292
00293
00294
00295 int facePhase(const VolIndex& a_vof, int aface) const ;
00296
00297
00298 const VolIndex& faceIndex(const VolIndex& a_vof, int face) const ;
00299
00300
00301 void setFacePhase(const VolIndex& a_vof, int face, int phase);
00302
00303
00304 void setFaceIndex(const VolIndex& a_vof, int face, const VolIndex& index);
00305
00306
00307 int numFacePhase(const VolIndex& a_vof) const ;
00308
00309 void clearMultiBoundaries();
00310
00311 void setBoundaryPhase(int phase);
00312
00313
00314
00315 int size(const Box& R, const Interval& comps) const;
00316
00317
00318 void linearOut(void* buf, const Box& R, const Interval& comps) const;
00319
00320
00321 void linearIn(void* buf, const Box& R, const Interval& comps);
00322
00323
00324 static int preAllocatable()
00325 {
00326 return 2;
00327 }
00328
00329 BaseIVFAB<VolData>& getVolData()
00330 {
00331 return m_volData;
00332 }
00333 const BaseIVFAB<VolData>& getVolData() const
00334 {
00335 return m_volData;
00336 }
00337
00338
00339
00340 bool hasMoments() const
00341 {
00342 return m_hasMoments;
00343 }
00344
00345 void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00346 const EBGraph& a_newGhostGraph,
00347 const BaseIVFAB<VolData>& a_newGhostData,
00348 const EBGraph& a_oldGhostGraph);
00349
00350
00351 void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange,
00352 const EBGraph& a_newGraph);
00353
00354 static void setVerbose(bool a_verbose);
00355
00356 static void setVerboseDebug(bool a_verboseDebug);
00357
00358
00359
00360
00361
00362
00363
00364 IndMomSpaceDim getVolumeMoments(const VolIndex& a_vof) const;
00365
00366
00367
00368
00369
00370
00371 IndMomSpaceDim getEBMoments(const VolIndex& a_vof) const;
00372
00373
00374
00375
00376
00377
00378 IndMomSDMinOne getFaceMoments(const FaceIndex& a_face) const;
00379
00380
00381 IndMomSDMinOne getAreaMoments(const FaceIndex& a_face) const
00382 {
00383 return getFaceMoments(a_face);
00384 }
00385
00386
00387
00388
00389
00390 IndMomSpaceDim getEBNormalPartialDerivs(const VolIndex& a_vof, int normalComponent) const;
00391
00392
00393
00394
00395
00396
00397
00398 IndMomSpaceDim getEBNormalMoments(const VolIndex& a_vof, int normalComponent) const;
00399
00400 private:
00401
00402
00403 bool
00404 irregFace(const FaceIndex& a_face) const;
00405
00406 bool
00407 irregVoF(const VolIndex& a_vof) const;
00408
00409
00410 void
00411 defineVoFData(const EBGraph& a_graph, const Box& a_region);
00412
00413
00414 void
00415 defineFaceData(const EBGraph& a_graph, const Box& a_region);
00416
00417 void setVolumeMomentsToZero(const VolIndex& a_vof);
00418
00419 void setAreaMomentsToZero(const FaceIndex& a_face);
00420
00421 void setCoveredAndRegular();
00422
00423 void shiftAndIncrement(IndMomSpaceDim& a_output, const IndMomSpaceDim& a_input,const RealVect& a_shiftRV);
00424 void shiftAndIncrement(IndMomSDMinOne& a_output, const IndMomSDMinOne& a_input,const RealVect& a_shiftRV, int faceDir);
00425
00426 static bool s_verbose;
00427 static bool s_verboseDebug;
00428
00429 BaseIVFAB<VolData> m_volData;
00430
00431
00432 IndMomSDMinOne m_regularAreaMoments;
00433
00434
00435 IndMomSpaceDim m_regularVolumeMoments;
00436
00437
00438 BaseIFFAB<FaceData> m_faceData[SpaceDim];
00439
00440
00441 bool m_isFaceDataDefined;
00442
00443
00444 bool m_isVoFDataDefined;
00445
00446
00447 bool m_hasMoments;
00448
00449
00450 Real m_dx;
00451 void operator=(const EBDataImplem& ebiin)
00452 {;}
00453
00454 EBDataImplem(const EBDataImplem& ebiin)
00455 {;}
00456
00457 void
00458 coarsenFaceCentroid(RealVect& a_centroidCoar,
00459 const Vector<RealVect>& a_centroidsFine,
00460 const Vector<Real>& a_areaFracFine,
00461 const Vector<FaceIndex>& a_facesFine,
00462 const FaceIndex& a_faceCoar);
00463 void
00464 coarsenAreaFrac(Real& a_areaFracCoar,
00465 const Vector<Real>& a_areaFracFine);
00466
00467 void
00468 coarsenVolFracAndCentroid(Real& a_volFracCoar,
00469 RealVect& a_volCentroidCoar,
00470 const Vector<Real>& a_volFracFine,
00471 const Vector<RealVect>& a_volCentroidFine,
00472 const Vector<VolIndex>& a_fineVoFs,
00473 const VolIndex& a_coarVoF);
00474
00475 void
00476 coarsenBoundaryAreaAndNormal(Real& a_bndryAreaCoar,
00477 RealVect& a_normalCoar,
00478 const Vector<Real>& a_bndryAreaFine,
00479 const Vector<RealVect>& a_normalFine);
00480
00481 RealVect
00482 fineToCoarseTransform(const RealVect& a_finePoint,
00483 const IntVect& a_coarCell,
00484 const IntVect& a_fineCell);
00485
00486 void
00487 coarsenBndryCentroid(RealVect& a_bndryCentroidCoar,
00488 const Vector<RealVect>& a_bndryCentroidFine,
00489 const Vector<Real>& a_bndryAreaFine,
00490 const Vector<VolIndex>& a_fineVoFs,
00491 const VolIndex& a_coarVoF);
00492
00493 void fetch(std::list<const VolData*>& fineVols, const Vector<VolIndex>& vofsFine) const;
00494
00495 friend class EBIndexSpace;
00496 friend class EBISLevel;
00497 };
00498
00499
00500
00501
00502
00503 class EBData
00504 {
00505 public:
00506
00507
00508 EBData(): m_implem( RefCountedPtr<EBDataImplem>( new EBDataImplem() ) )
00509 {
00510 }
00511
00512
00513 ~EBData()
00514 {
00515 }
00516
00517
00518
00519
00520 void define(const Box& a_box, int a_comps)
00521 {
00522 m_implem->define(a_box, a_comps);
00523 }
00524
00525
00526
00527
00528
00529 EBData(const Box& a_box, int a_comps)
00530 :m_implem(new EBDataImplem(a_box, a_comps))
00531 {
00532 }
00533
00534
00535
00536
00537
00538
00539
00540
00541 void copy(const Box& a_regionFrom,
00542 const Interval& a_Cd,
00543 const Box& a_regionto,
00544 const EBData& a_source,
00545 const Interval& a_Cs)
00546 {
00547 m_implem->copy(a_regionFrom, a_Cd, a_regionto, *a_source.m_implem, a_Cs);
00548 }
00549
00550
00551
00552 void
00553 define(const EBGraph& a_graph,
00554 const Vector<IrregNode>& a_irregData,
00555 const Box& a_validBox,
00556 const Real & a_dx,
00557 bool a_hasMoments)
00558 {
00559 m_implem->define(a_graph, a_irregData, a_validBox, a_dx, a_hasMoments);
00560 computeNormalsAndBoundaryAreas(a_graph, a_validBox);
00561 }
00562
00563
00564 void define(const EBGraph& a_graph,
00565 const Box& a_region,
00566 const Real& a_dx,
00567 bool a_hasMoments)
00568 {
00569 m_implem->define(a_graph, a_region, a_dx, a_hasMoments);
00570 }
00571
00572 void
00573 coarsenVoFs(const EBData& a_fineEBData,
00574 const EBGraph& a_fineGraph,
00575 const EBGraph& a_coarGraph,
00576 const Box& a_validRegion)
00577 {
00578 m_implem->coarsenVoFs(*a_fineEBData.m_implem, a_fineGraph, a_coarGraph, a_validRegion);
00579 }
00580
00581 void
00582 coarsenFaces(const EBData& a_fineEBData,
00583 const EBGraph& a_fineGraph,
00584 const EBGraph& a_coarGraph,
00585 const Box& a_validRegion)
00586 {
00587 m_implem->coarsenFaces(*a_fineEBData.m_implem, a_fineGraph, a_coarGraph, a_validRegion);
00588 }
00589
00590
00591
00592
00593
00594
00595 IndMomSpaceDim getVolumeMoments(const VolIndex& a_vof) const
00596 {
00597 return m_implem->getVolumeMoments(a_vof);
00598 }
00599
00600
00601
00602
00603
00604
00605 IndMomSpaceDim getEBMoments(const VolIndex& a_vof) const
00606 {
00607 return m_implem->getEBMoments(a_vof);
00608 }
00609
00610
00611
00612
00613
00614
00615 IndMomSDMinOne getFaceMoments(const FaceIndex& a_face) const
00616 {
00617 return m_implem->getFaceMoments(a_face);
00618 }
00619
00620
00621 IndMomSDMinOne getAreaMoments(const FaceIndex& a_face) const
00622 {
00623 return getFaceMoments(a_face);
00624 }
00625
00626
00627
00628
00629
00630 IndMomSpaceDim getEBNormalPartialDerivs(const VolIndex& a_vof, int a_normalComponent) const
00631 {
00632 return m_implem->getEBNormalPartialDerivs(a_vof, a_normalComponent);
00633 }
00634
00635
00636
00637
00638
00639
00640
00641 IndMomSpaceDim getEBNormalMoments(const VolIndex& a_vof, int a_normalComponent) const
00642 {
00643 return m_implem->getEBNormalMoments(a_vof, a_normalComponent);
00644 }
00645
00646
00647 const Real& volFrac(const VolIndex& a_vof) const;
00648
00649
00650 const Real& areaFrac(const FaceIndex& a_face1) const;
00651
00652
00653 const RealVect& centroid(const FaceIndex& facein) const;
00654
00655
00656 const RealVect& centroid(const VolIndex& a_vof) const;
00657
00658
00659 bool hasMoments() const
00660 {
00661 return m_implem->hasMoments();
00662 }
00663
00664 const RealVect& bndryCentroid(const VolIndex& a_vof) const;
00665 const RealVect& bndryCentroid(const VolIndex& a_vof, int face) const;
00666
00667
00668 const Real& bndryArea(const VolIndex& a_vof) const;
00669 const Real& bndryArea(const VolIndex& a_vof, int face) const;
00670
00671
00672 const RealVect& normal(const VolIndex& a_vof) const;
00673 const RealVect& normal(const VolIndex& a_vof, int face) const;
00674
00675
00676 int facePhase(const VolIndex& a_vof, int a_face) const
00677 {
00678 return m_implem->facePhase(a_vof, a_face);
00679 }
00680
00681
00682 const VolIndex& faceIndex(const VolIndex& a_vof, int face) const
00683 {
00684 return m_implem->faceIndex(a_vof, face);
00685 }
00686
00687
00688 void setFacePhase(const VolIndex& a_vof, int face, int phase)
00689 {
00690 m_implem->setFacePhase(a_vof, face, phase);
00691 }
00692
00693
00694 void setFaceIndex(const VolIndex& a_vof, int face, const VolIndex& index)
00695 {
00696 m_implem->setFaceIndex(a_vof, face, index);
00697 }
00698
00699 int numFacePhase(const VolIndex& a_vof) const
00700 {
00701 return m_implem->numFacePhase(a_vof);
00702 }
00703
00704 void clearMultiBoundaries()
00705 {
00706 m_implem->clearMultiBoundaries();
00707 }
00708 void setBoundaryPhase(int phase)
00709 {
00710 m_implem->setBoundaryPhase(phase);
00711 }
00712
00713 EBData(const EBData& a_ebiin)
00714 {
00715 m_implem = a_ebiin.m_implem;
00716 }
00717
00718
00719
00720
00721
00722 bool operator==(const EBData& a_ebiin)
00723 {
00724 return ((&(*m_implem)) == (&(*a_ebiin.m_implem)));
00725 }
00726
00727
00728 EBData& operator=(const EBData& a_ebiin)
00729 {
00730 m_implem = a_ebiin.m_implem;
00731 return *this;
00732 }
00733
00734
00735
00736
00737
00738 int size(const Box& R, const Interval& comps) const
00739 {
00740 return (m_implem->size(R, comps));
00741 }
00742
00743
00744 void linearOut(void* buf, const Box& R, const Interval& comps) const
00745 {
00746 m_implem->linearOut(buf, R, comps);
00747 }
00748
00749
00750 void linearIn(void* buf, const Box& R, const Interval& comps)
00751 {
00752 m_implem->linearIn(buf, R, comps);
00753 }
00754
00755
00756 void
00757 addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00758 const EBGraph& a_newGraph,
00759 const BaseIVFAB<VolData>& a_grownData,
00760 const EBGraph& a_oldGraph)
00761 {
00762 m_implem->addFullIrregularVoFs(a_vofsToChange, a_newGraph, a_grownData, a_oldGraph);
00763 }
00764
00765
00766
00767 void
00768 addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange,
00769 const EBGraph& a_newGraph)
00770 {
00771 m_implem->addEmptyIrregularVoFs(a_vofsToChange, a_newGraph);
00772 }
00773
00774
00775
00776 void
00777 computeNormalsAndBoundaryAreas(const EBGraph& a_graph,
00778 const Box& a_validRegion);
00779
00780 BaseIVFAB<VolData>& getVolData()
00781 {
00782 return m_implem->getVolData();
00783 }
00784
00785 const BaseIVFAB<VolData>& getVolData() const
00786 {
00787 return m_implem->getVolData();
00788 }
00789
00790
00791 static int preAllocatable()
00792 {
00793 return 2;
00794 }
00795
00796
00797 private:
00798
00799
00800 RefCountedPtr<EBDataImplem> m_implem;
00801
00802 friend class EBIndexSpace;
00803 friend class EBISLevel;
00804 };
00805
00806
00807 inline const Real& EBData::volFrac(const VolIndex& a_vof) const
00808 {
00809 return m_implem->volFrac(a_vof);
00810 }
00811
00812 inline const Real& EBData::bndryArea(const VolIndex& a_vof, int face) const
00813 {
00814 return m_implem->bndryArea(a_vof, face);
00815 }
00816 inline const Real& EBData::bndryArea(const VolIndex& a_vof) const
00817 {
00818 return m_implem->bndryArea(a_vof);
00819 }
00820
00821 inline const RealVect& EBData::normal(const VolIndex& a_vof, int face) const
00822 {
00823 return m_implem->normal(a_vof, face);
00824 }
00825 inline const RealVect& EBData::normal(const VolIndex& a_vof) const
00826 {
00827 return m_implem->normal(a_vof);
00828 }
00829
00830 inline const RealVect& EBData::centroid(const VolIndex& a_vof) const
00831 {
00832 return m_implem->centroid(a_vof);
00833 }
00834
00835 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof, int face) const
00836 {
00837 return m_implem->bndryCentroid(a_vof, face);
00838 }
00839 inline const RealVect& EBData::bndryCentroid(const VolIndex& a_vof) const
00840 {
00841 return m_implem->bndryCentroid(a_vof);
00842 }
00843
00844 inline const RealVect& EBData::centroid(const FaceIndex& a_face) const
00845 {
00846 return m_implem->centroid(a_face);
00847 }
00848
00849 inline const Real& EBData::areaFrac(const FaceIndex& a_face) const
00850 {
00851 return m_implem->areaFrac(a_face);
00852 }
00853
00854
00855 #include "NamespaceFooter.H"
00856 #endif