00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011
00012
00013 #ifndef _EBGRAPH_H_
00014 #define _EBGRAPH_H_
00015
00016 #include "REAL.H"
00017 #include "IntVect.H"
00018 #include "IntVectSet.H"
00019 #include "VolIndex.H"
00020 #include "Interval.H"
00021 #include "FaceIndex.H"
00022 #include "IntVectSet.H"
00023 #include "RealVect.H"
00024 #include "BaseFab.H"
00025 #include "SPMD.H"
00026 #include "IrregNode.H"
00027 #include "GraphNode.H"
00028 #include "RefCountedPtr.H"
00029 #include "FaceIterator.H"
00030 #include "VoFIterator.H"
00031 #include <map>
00032 #include "HDF5Portable.H"
00033 #include "NamespaceHeader.H"
00034
00035 class EBGraph;
00037
00042 class EBGraphImplem
00043 {
00044 public:
00046
00050 enum TAG {AllRegular = 0, AllCovered, HasIrregular};
00051
00053
00056 EBGraphImplem();
00057
00059 ~EBGraphImplem();
00060
00062
00071 const BaseFab<int>& getMask(int& a_regIrregCovered) const;
00072
00074
00077 Vector<VolIndex> getVoFs(const IntVect& a_iv) const;
00078
00080 int numVoFs(const IntVect& a_iv) const;
00081
00083 int numVoFs(const Box& a_box) const ;
00084
00086 int numFaces(const Box& a_box, int a_dir) const ;
00087
00089
00092 bool isAllRegular() const;
00093
00095
00098 bool hasIrregular() const;
00099
00101
00104 bool isAllCovered() const;
00105
00107
00110 bool isIrregular(const IntVect& a_iv) const;
00111
00113
00117 bool isCovered(const Box& a_box) const;
00118
00120
00124 bool isRegular(const Box& a_box) const;
00125
00127 bool isRegular(const IntVect& a_iv) const;
00128
00130 bool isCovered(const IntVect& a_iv) const;
00131
00133 bool isConnected(const VolIndex& a_vof1,
00134 const VolIndex& a_vof2) const;
00136
00140 Vector<FaceIndex> getFaces(const VolIndex& a_vof,
00141 const int& a_idir,
00142 const Side::LoHiSide& a_sd) const;
00143
00145 Vector<Vector<VolIndex> > getVoFSets(const Box& a_region) const;
00146
00148
00153 Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
00154
00156
00161 Vector<FaceIndex> refine(const FaceIndex& a_coarFace, const EBGraphImplem& a_fineGraph) const;
00162
00164
00169 FaceIndex coarsen(const FaceIndex& a_coarFace) const;
00170
00172
00177 VolIndex coarsen(const VolIndex& a_fineVoF) const;
00178
00180
00194 void
00195 buildGraph(const BaseFab<int>& a_regIrregCovered,
00196 const Vector<IrregNode>& a_irregGraph,
00197 const Box& a_validRegion,
00198 const ProblemDomain& a_domain);
00199
00201 static void
00202 checkGraph(const BaseFab<int>& a_regIrregCovered,
00203 const Vector<IrregNode>& a_irregGraph,
00204 const Box& a_validRegion,
00205 const ProblemDomain& a_domain) ;
00206
00208
00211 void setToAllRegular();
00212
00214
00217 void setToAllCovered();
00218
00220
00224 void define(const Box& box);
00225
00226 EBGraphImplem(const Box& box);
00227
00229
00235 void copy(const Box& a_regionFrom,
00236 const Interval& Cd,
00237 const Box& a_regionto,
00238 const EBGraphImplem& a_source,
00239 const Interval& Cs);
00240
00242 const Box& getRegion() const;
00243
00245 const ProblemDomain& getDomain() const;
00246
00248
00251 int size(const Box& R, const Interval& comps) const;
00252
00254 void linearOut(void* buf, const Box& R, const Interval& comps) const;
00255
00257 void linearIn(void* buf, const Box& R, const Interval& comps);
00258
00260 static int preAllocatable()
00261 {
00262 return 2;
00263 }
00264
00266 bool isDefined() const;
00267
00269 bool isDomainSet() const;
00270
00271
00272
00273
00274
00275 void coarsenVoFs(const EBGraphImplem& a_fineGraph,
00276 const Box& a_coarRegion);
00277
00278
00279 void coarsenFaces(const EBGraphImplem& a_coarGhostGraph,
00280 const EBGraphImplem& a_fineEBIS);
00281
00282
00283 void fixFineToCoarse(EBGraphImplem& a_fineEBIS) const;
00284
00285
00286 Vector<int>
00287 coarsenFaces(const VolIndex& a_coarVoF,
00288 const EBGraphImplem& a_coarGhostGraph,
00289 const EBGraphImplem& a_fineGraph,
00290 const int& a_idir,
00291 const Side::LoHiSide& a_sd);
00292
00294 void setDomain(const ProblemDomain& a_domain);
00295
00297 IntVectSet getIrregCells(const Box& a_subbox) const;
00298
00300 IntVectSet getMultiCells(const Box& a_subbox) const;
00301
00303 Vector<FaceIndex>
00304 getAllFaces(const IntVect& a_iv,
00305 const int& a_idir,
00306 const Side::LoHiSide& a_sd) const;
00307
00308 Vector<FaceIndex>
00309 getIrregFaces(const Box& a_box, int a_dir) const;
00310
00311
00312 void fillMask(BaseFab<char>& a_mask) const;
00313
00315
00320 void fillIntMask(BaseFab<int>& a_mask) const;
00321
00322
00324 void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00325 const EBGraph& a_ghostGraph);
00326
00328 void
00329 getRegNextToMultiValued(IntVectSet& a_vofsToChange,
00330 const EBGraph& a_ghostGraph) const;
00331
00332
00333
00334 const FaceIterator& FaceIteratorCache(const Box& a_region, int a_direction,
00335 FaceStop::WhichFaces a_loc, const EBGraph& parent) const;
00336
00337 const FaceIterator& FaceIteratorCache(const IntVectSet& ivs, int a_direction,
00338 FaceStop::WhichFaces a_loc, const EBGraph& parent) const;
00339
00340 const VoFIterator& VoFIteratorCache(const IntVectSet& ivs,
00341 const EBGraph& parent) const;
00342
00343 private:
00344
00346 Box m_region;
00347
00349 ProblemDomain m_domain;
00350
00352
00356 TAG m_tag;
00357
00359
00365 BaseFab<GraphNode> m_graph;
00366
00368 bool m_isDefined;
00369
00371 bool m_isDomainSet;
00372
00374 IntVectSet* m_irregIVS;
00375
00377 IntVectSet* m_multiIVS;
00378
00379 static bool s_verbose;
00380
00381 mutable std::map<Box, FaceIterator> m_boxFaceCache[2*CH_SPACEDIM];
00382 mutable std::map<IntVectSet, FaceIterator> m_faceCache[FaceStop::NUMTYPES*CH_SPACEDIM];
00383 mutable std::map<IntVectSet, VoFIterator> m_vofIteratorCache;
00384
00385
00386 mutable BaseFab<int> m_mask;
00387 mutable bool m_isMaskBuilt;
00388 private:
00389
00390 void operator=(const EBGraphImplem& ebiin)
00391 {
00392 MayDay::Error("invalid operator");
00393 }
00394 EBGraphImplem(const EBGraphImplem& ebiin)
00395 {
00396 MayDay::Error("invalid operator");
00397 }
00398 };
00399
00401
00408 class EBGraph
00409 {
00410 public:
00412
00416 enum TAG {AllRegular = 0, AllCovered, HasIrregular};
00417
00419
00422 EBGraph();
00423
00425 ~EBGraph();
00426
00428
00437 const BaseFab<int>& getMask(int& a_regIrregCovered) const;
00438
00440
00443 Vector<VolIndex> getVoFs(const IntVect& a_iv) const;
00444
00446 int numVoFs(const IntVect& a_iv) const;
00447
00449
00452 bool isAllRegular() const;
00453
00455
00458 bool hasIrregular() const;
00459
00461
00464 bool isAllCovered() const;
00465
00467
00470 bool isIrregular(const IntVect& a_iv) const;
00471
00473
00477 bool isCovered(const Box& a_box) const;
00478
00480
00484 bool isRegular(const Box& a_box) const;
00485
00487 bool isRegular(const IntVect& a_iv) const;
00488
00490 bool isCovered(const IntVect& a_iv) const;
00491
00493 bool isConnected(const VolIndex& a_vof1,
00494 const VolIndex& a_vof2) const;
00496
00500 Vector<FaceIndex> getFaces(const VolIndex& a_vof,
00501 const int& a_idir,
00502 const Side::LoHiSide& a_sd) const;
00503
00505 Vector<Vector<VolIndex> > getVoFSets(const Box& a_region) const;
00507
00512 Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
00513
00515
00520 Vector<FaceIndex> refine(const FaceIndex& a_coarFace, const EBGraph& a_fineGraph) const;
00521
00523
00528 FaceIndex coarsen(const FaceIndex& a_coarFace) const;
00529
00531
00536 VolIndex coarsen(const VolIndex& a_fineVoF) const;
00537
00539
00544 EBGraph(const Box& a_box, int a_comps);
00545
00547
00561 void
00562 buildGraph(const BaseFab<int>& a_regIrregCovered,
00563 const Vector<IrregNode>& a_irregGraph,
00564 const Box& a_validRegion,
00565 const ProblemDomain& a_domain);
00566
00568
00571 void setToAllRegular();
00572
00574
00577 void setToAllCovered();
00578
00580
00584 void define(const Box& box);
00585
00587
00593 void copy(const Box& a_regionFrom,
00594 const Interval& Cd,
00595 const Box& a_regionto,
00596 const EBGraph& a_source,
00597 const Interval& Cs);
00598
00600 const Box& getRegion() const;
00601
00603 const ProblemDomain& getDomain() const;
00604
00606 bool isDefined() const;
00607
00609 bool isDomainSet() const;
00610
00611
00612
00613
00614
00615 void coarsenVoFs(const EBGraph& a_fineGraph,
00616 const Box& a_coarRegion);
00617
00618
00619 void coarsenFaces(const EBGraph& a_coarGhostGraph,
00620 const EBGraph& a_fineEBIS);
00621
00622
00623 void fixFineToCoarse(EBGraph& a_fineEBIS) const;
00624
00625
00626 Vector<int>
00627 coarsenFaces(const VolIndex& a_coarVoF,
00628 const EBGraph& a_coarGhostGraph,
00629 const EBGraph& a_fineGraph,
00630 const int& a_idir,
00631 const Side::LoHiSide& a_sd);
00632
00634 void setDomain(const ProblemDomain& a_domain);
00635
00637 IntVectSet getIrregCells(const Box& a_subbox) const;
00638
00640 IntVectSet getMultiCells(const Box& a_subbox) const;
00641
00643 EBGraph& operator=(const EBGraph& ebiin);
00644
00646 EBGraph(const EBGraph& a_ebiin);
00647
00649 Vector<FaceIndex>
00650 getAllFaces(const IntVect& a_iv,
00651 const int& a_idir,
00652 const Side::LoHiSide& a_sd) const;
00653
00655 Vector<FaceIndex>
00656 getIrregFaces(const Box& a_box, int a_dir) const;
00657
00658 void fillMask(BaseFab<char>& a_mask) const;
00659
00661
00666 void fillIntMask(BaseFab<int>& a_mask) const;
00667
00668
00670 EBGraph(const Box& box);
00672 bool operator==(const EBGraph& a_ebiin);
00673
00675 bool operator<(const EBGraph& a_ebiin) const;
00676
00678
00681 int size(const Box& R, const Interval& comps) const;
00682
00684 void linearOut(void* buf, const Box& R, const Interval& comps) const;
00685
00687 void linearIn(void* buf, const Box& R, const Interval& comps);
00688
00690 static int preAllocatable()
00691 {
00692 return 2;
00693 }
00694
00696 void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00697 const EBGraph& a_ghostGraph);
00698
00700 void
00701 getRegNextToMultiValued(IntVectSet& a_vofsToChange,
00702 const EBGraph& a_ghostGraph) const;
00703
00704 int numVoFs(const Box& a_box) const ;
00705
00706 int numFaces(const Box& a_box, int a_dir) const ;
00707
00708 const FaceIterator& FaceIteratorCache(const IntVectSet& ivs, int a_direction,
00709 FaceStop::WhichFaces a_loc) const;
00710
00711 const FaceIterator& FaceIteratorCache(const Box& a_region, int a_direction,
00712 FaceStop::WhichFaces a_loc) const;
00713
00714 const VoFIterator& VoFIteratorCache(const IntVectSet& ivs) const;
00715
00716 private:
00717
00719 RefCountedPtr<EBGraphImplem> m_implem;
00720 };
00721
00722
00723
00724 template <>
00725 void dataTypes(Vector<hid_t>& a_types, const EBGraph& a_dummySpecializationArg);
00726
00727 template <>
00728 void dataSize(const EBGraph& item, Vector<int>& a_sizes,
00729 const Box& box, const Interval& comps);
00730
00731 template <>
00732 void write(const EBGraph& item, Vector<void*>& a_allocatedBuffers,
00733 const Box& box, const Interval& comps);
00734
00735 template <>
00736 void read(EBGraph& item, Vector<void*>& a_allocatedBuffers, const Box& box,
00737 const Interval& comps);
00738
00739 template <>
00740 const char* name(const EBGraph& a_dummySpecializationArg);
00741
00742
00743
00744
00745
00746
00747 inline
00748 const BaseFab<int>&
00749 EBGraph::getMask(int& a_regIrregCovered) const
00750 {
00751 return m_implem->getMask(a_regIrregCovered);
00752 }
00753
00754 inline void
00755 EBGraph::buildGraph(const BaseFab<int>& a_regIrregCovered,
00756 const Vector<IrregNode>& a_irregGraph,
00757 const Box& a_validRegion,
00758 const ProblemDomain& a_domain)
00759 {
00760 m_implem->buildGraph(a_regIrregCovered, a_irregGraph, a_validRegion, a_domain);
00761 }
00762
00763 inline void EBGraph::copy(const Box& a_regionFrom,
00764 const Interval& Cd,
00765 const Box& a_regionTo,
00766 const EBGraph& a_source,
00767 const Interval& Cs)
00768 {
00769 m_implem->copy(a_regionFrom, Cd, a_regionTo,
00770 *(a_source.m_implem), Cs);
00771 }
00772
00773 inline bool EBGraph::isDefined() const
00774 {
00775 return m_implem->isDefined();
00776 }
00777
00778 inline bool EBGraph::isConnected(const VolIndex& a_vof1,
00779 const VolIndex& a_vof2) const
00780 {
00781 return m_implem->isConnected(a_vof1, a_vof2);
00782 }
00783
00784 inline const Box& EBGraph::getRegion() const
00785 {
00786 return m_implem->getRegion();
00787 }
00788
00789 inline EBGraph& EBGraph::operator=(const EBGraph& a_ebiin)
00790 {
00791 if(&a_ebiin != this)
00792 {
00793 m_implem = a_ebiin.m_implem;
00794 }
00795 return *this;
00796 }
00797
00798
00799 inline IntVectSet EBGraph::getMultiCells(const Box& a_subbox) const
00800 {
00801 return m_implem->getMultiCells(a_subbox);
00802 }
00803
00804 inline IntVectSet EBGraph::getIrregCells(const Box& a_subbox) const
00805 {
00806 return m_implem->getIrregCells(a_subbox);
00807 }
00808
00809 inline Vector<VolIndex> EBGraph::getVoFs(const IntVect& a_iv) const
00810 {
00811 return m_implem->getVoFs(a_iv);
00812 }
00813
00814 inline bool EBGraph::isRegular(const IntVect& a_iv) const
00815 {
00816 return m_implem->isRegular(a_iv);
00817 }
00818
00819 inline bool EBGraph::isAllRegular() const
00820 {
00821 return m_implem->isAllRegular();
00822 }
00823
00824 inline bool EBGraph::isAllCovered() const
00825 {
00826 return m_implem->isAllCovered();
00827 }
00828
00829 inline bool EBGraph::isIrregular(const IntVect& a_iv) const
00830 {
00831 return m_implem->isIrregular(a_iv);
00832 }
00833
00834 inline bool EBGraph::isCovered(const IntVect& a_iv) const
00835 {
00836 return m_implem->isCovered(a_iv);
00837 }
00838
00839 inline bool EBGraph::isCovered(const Box& a_box) const
00840 {
00841 return m_implem->isCovered(a_box);
00842 }
00843
00844 inline bool EBGraph::isRegular(const Box& a_box) const
00845 {
00846 return m_implem->isRegular(a_box);
00847 }
00848
00849 inline Vector<FaceIndex>
00850 EBGraph::getFaces(const VolIndex& a_vof,
00851 const int& a_idir,
00852 const Side::LoHiSide& a_sd) const
00853 {
00854 return m_implem->getFaces(a_vof, a_idir, a_sd);
00855 }
00856
00857 inline Vector<VolIndex>
00858 EBGraph::refine(const VolIndex& a_coarVoF) const
00859 {
00860 return m_implem->refine(a_coarVoF);
00861 }
00862
00863 inline Vector<FaceIndex>
00864 EBGraph::refine(const FaceIndex& a_coarFace, const EBGraph& a_fineGraph) const
00865 {
00866 return m_implem->refine(a_coarFace, *a_fineGraph.m_implem);
00867 }
00868
00869 inline FaceIndex EBGraph::coarsen(const FaceIndex& a_fineFace) const
00870 {
00871 return m_implem->coarsen(a_fineFace);
00872 }
00873
00874 inline VolIndex EBGraph::coarsen(const VolIndex& a_fineVoF) const
00875 {
00876 return m_implem->coarsen(a_fineVoF);
00877 }
00878
00879 inline bool EBGraph::operator==(const EBGraph& a_ebiin)
00880 {
00881 return (m_implem == a_ebiin.m_implem);
00882 }
00883
00884 inline bool EBGraph::operator<(const EBGraph& a_ebiin) const
00885 {
00886 return (m_implem < a_ebiin.m_implem);
00887 }
00888
00889 inline const ProblemDomain& EBGraph::getDomain() const
00890 {
00891 return (m_implem->getDomain());
00892 }
00893
00894 inline void EBGraph::setDomain(const ProblemDomain& a_domain)
00895 {
00896 m_implem->setDomain(a_domain);
00897 }
00898
00899 inline void EBGraph::setToAllRegular()
00900 {
00901 m_implem->setToAllRegular();
00902 }
00903
00904 inline void EBGraph::setToAllCovered()
00905 {
00906 m_implem->setToAllCovered();
00907 }
00908
00909 inline void EBGraph::
00910 coarsenVoFs(const EBGraph& a_fineEBIS,
00911 const Box& a_coarRegion)
00912 {
00913 m_implem->coarsenVoFs(*a_fineEBIS.m_implem, a_coarRegion);
00914 }
00915
00916 inline void EBGraph::
00917 coarsenFaces(const EBGraph& a_coarGhost, const EBGraph& a_fineEBIS)
00918 {
00919 m_implem->coarsenFaces(*a_coarGhost.m_implem, *a_fineEBIS.m_implem);
00920 }
00921
00922 inline void EBGraph::
00923 fixFineToCoarse(EBGraph& a_fineEBIS) const
00924 {
00925 m_implem->fixFineToCoarse(*a_fineEBIS.m_implem);
00926 }
00927
00928 inline Vector<FaceIndex>
00929 EBGraph::getAllFaces(const IntVect& a_iv,
00930 const int& a_idir,
00931 const Side::LoHiSide& a_sd) const
00932 {
00933 return m_implem->getAllFaces(a_iv, a_idir, a_sd);
00934 }
00935
00936
00937
00938 inline int
00939 EBGraph::numVoFs(const IntVect& a_iv) const
00940 {
00941 return m_implem->numVoFs(a_iv);
00942 }
00943
00944 inline
00945 const FaceIterator& EBGraph::FaceIteratorCache(const Box& a_region, int a_direction,
00946 FaceStop::WhichFaces a_loc) const
00947 {
00948 return m_implem->FaceIteratorCache(a_region, a_direction, a_loc, *this);
00949 }
00950
00951 inline
00952 const FaceIterator& EBGraph::FaceIteratorCache(const IntVectSet& a_region, int a_direction,
00953 FaceStop::WhichFaces a_loc) const
00954 {
00955 return m_implem->FaceIteratorCache(a_region, a_direction, a_loc, *this);
00956 }
00957 inline
00958 const VoFIterator& EBGraph::VoFIteratorCache(const IntVectSet& ivs) const
00959 {
00960 return m_implem->VoFIteratorCache(ivs, *this);
00961 }
00962
00963 #include "NamespaceFooter.H"
00964 #endif