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 "SPMD.H"
00018 #include "RefCountedPtr.H"
00019 #include "IntVect.H"
00020 #include "IntVectSet.H"
00021 #include "RealVect.H"
00022 #include "Interval.H"
00023 #include "BaseFab.H"
00024 #include "HDF5Portable.H"
00025
00026 #include "VolIndex.H"
00027 #include "FaceIndex.H"
00028 #include "IrregNode.H"
00029 #include "GraphNode.H"
00030 #include "FaceIterator.H"
00031 #include "VoFIterator.H"
00032
00033 #include "NamespaceHeader.H"
00034
00035 class EBIndexSpace;
00036
00037 class EBGraph;
00038
00039
00040
00041
00042
00043
00044 class EBGraphImplem
00045 {
00046 public:
00047 static IntVect s_ivDebug;
00048 static Box s_doDebug;
00049
00050
00051
00052
00053
00054
00055 enum TAG
00056 {
00057 AllRegular = 0,
00058 AllCovered,
00059 HasIrregular
00060 };
00061
00062
00063
00064
00065
00066 EBGraphImplem();
00067
00068
00069 ~EBGraphImplem();
00070
00071
00072
00073
00074
00075 const BaseFab<char>& getMask(int& a_regIrregCovered) const;
00076
00077
00078
00079
00080
00081 Vector<VolIndex> getVoFs(const IntVect& a_iv) const;
00082
00083
00084 long long numVoFs(const IntVect& a_iv) const;
00085
00086
00087 long long numVoFs(const Box& a_box) const ;
00088
00089
00090 long long numFaces(const Box& a_box, int a_dir) const ;
00091
00092
00093
00094
00095
00096 bool isAllRegular() const;
00097
00098
00099
00100
00101
00102 bool hasIrregular() const;
00103
00104
00105
00106
00107
00108 bool isAllCovered() const;
00109
00110
00111
00112
00113
00114 bool isIrregular(const IntVect& a_iv) const;
00115
00116
00117
00118
00119
00120
00121 bool isCovered(const Box& a_box) const;
00122
00123
00124
00125
00126
00127
00128 bool isRegular(const Box& a_box) const;
00129
00130
00131 bool isRegular(const IntVect& a_iv) const;
00132
00133
00134 bool isCovered(const IntVect& a_iv) const;
00135
00136
00137 bool isMultiValued(const IntVect& a_iv) const;
00138
00139
00140 bool isConnected(const VolIndex& a_vof1,
00141 const VolIndex& a_vof2) const;
00142
00143
00144
00145
00146
00147 Vector<FaceIndex> getFaces(const VolIndex& a_vof,
00148 const int& a_idir,
00149 const Side::LoHiSide& a_sd) const;
00150
00151
00152 Vector<Vector<VolIndex> > getVoFSets(const Box& a_region) const;
00153
00154
00155
00156
00157
00158
00159
00160 Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
00161
00162
00163
00164
00165
00166
00167
00168 Vector<FaceIndex> refine(const FaceIndex& a_coarFace, const EBGraphImplem& a_fineGraph) const;
00169
00170
00171
00172
00173
00174
00175
00176 FaceIndex coarsen(const FaceIndex& a_coarFace) const;
00177
00178
00179
00180
00181
00182
00183
00184 VolIndex coarsen(const VolIndex& a_fineVoF) const;
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 void
00202 buildGraph(const BaseFab<int>& a_regIrregCovered,
00203 const Vector<IrregNode>& a_irregGraph,
00204 const Box& a_validRegion,
00205 const ProblemDomain& a_domain);
00206
00207
00208 static void
00209 checkGraph(const BaseFab<int>& a_regIrregCovered,
00210 const Vector<IrregNode>& a_irregGraph,
00211 const Box& a_validRegion,
00212 const ProblemDomain& a_domain) ;
00213
00214
00215
00216
00217
00218 void setToAllRegular();
00219
00220
00221
00222
00223
00224 void setToAllCovered();
00225
00226
00227
00228
00229
00230
00231 void define(const Box& box);
00232
00233 EBGraphImplem(const Box& box);
00234
00235
00236
00237
00238
00239
00240
00241
00242 void copy(const Box& a_regionFrom,
00243 const Interval& Cd,
00244 const Box& a_regionto,
00245 const EBGraphImplem& a_source,
00246 const Interval& Cs);
00247
00248
00249 const Box& getRegion() const;
00250
00251
00252 const ProblemDomain& getDomain() const;
00253
00254
00255
00256
00257
00258 int size(const Box& R, const Interval& comps) const;
00259
00260
00261 void linearOut(void* buf, const Box& R, const Interval& comps) const;
00262
00263
00264 void linearIn(void* buf, const Box& R, const Interval& comps);
00265
00266
00267 static int preAllocatable()
00268 {
00269 return 2;
00270 }
00271
00272
00273 bool isDefined() const;
00274
00275
00276 bool isDomainSet() const;
00277
00278
00279
00280
00281
00282 void coarsenVoFs(const EBGraphImplem& a_fineGraph,
00283 const Box& a_coarRegion);
00284
00285
00286 void coarsenFaces(const EBGraphImplem& a_coarGhostGraph,
00287 const EBGraphImplem& a_fineEBIS);
00288
00289
00290 void fixFineToCoarse(EBGraphImplem& a_fineEBIS) const;
00291
00292
00293 Vector<int>
00294 coarsenFaces(const VolIndex& a_coarVoF,
00295 const EBGraphImplem& a_coarGhostGraph,
00296 const EBGraphImplem& a_fineGraph,
00297 const int& a_idir,
00298 const Side::LoHiSide& a_sd);
00299
00300
00301 void setDomain(const ProblemDomain& a_domain);
00302
00303
00304 IntVectSet getIrregCells(const Box& a_subbox) const;
00305
00306
00307 IntVectSet getMultiCells(const Box& a_subbox) const;
00308
00309
00310 Vector<FaceIndex>
00311 getAllFaces(const IntVect& a_iv,
00312 const int& a_idir,
00313 const Side::LoHiSide& a_sd) const;
00314
00315 Vector<FaceIndex>
00316 getIrregFaces(const Box& a_box, int a_dir) const;
00317
00318
00319
00320
00321
00322
00323 void fillMask(BaseFab<char>& a_mask) const;
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 void fillCellTypeMask(BaseFab<char>& a_mask) const;
00334
00335
00336
00337
00338 void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00339 const EBGraph& a_ghostGraph);
00340
00341 void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange);
00342
00343
00344 void
00345 getRegNextToMultiValued(IntVectSet& a_vofsToChange,
00346 const EBGraph& a_ghostGraph) const;
00347
00348
00349 Vector<FaceIndex> getMultiValuedFaces(const int& a_idir, const Box& a_box, const EBGraph& a_ebgraph) const;
00350
00351
00352
00353 const FaceIterator& FaceIteratorCache(const Box& a_region, int a_direction,
00354 FaceStop::WhichFaces a_loc, const EBGraph& parent) const;
00355
00356 const FaceIterator& FaceIteratorCache(const IntVectSet& ivs, int a_direction,
00357 FaceStop::WhichFaces a_loc, const EBGraph& parent) const;
00358
00359 const VoFIterator& VoFIteratorCache(const IntVectSet& ivs,
00360 const EBGraph& parent) const;
00361
00362 private:
00363
00364
00365 Box m_region;
00366
00367
00368 ProblemDomain m_domain;
00369
00370
00371
00372
00373
00374
00375 TAG m_tag;
00376
00377
00378
00379
00380
00381
00382
00383
00384 BaseFab<GraphNode> m_graph;
00385
00386
00387 bool m_isDefined;
00388
00389
00390 bool m_isDomainSet;
00391
00392
00393 IntVectSet* m_irregIVS;
00394
00395
00396 IntVectSet* m_multiIVS;
00397
00398 static bool s_verbose;
00399
00400
00401 mutable BaseFab<char> m_mask;
00402 mutable bool m_isMaskBuilt;
00403
00404 private:
00405
00406 void operator=(const EBGraphImplem& ebiin)
00407 {
00408 MayDay::Error("invalid operator");
00409 }
00410 EBGraphImplem(const EBGraphImplem& ebiin)
00411 {
00412 MayDay::Error("invalid operator");
00413 }
00414
00415 friend class EBIndexSpace;
00416 friend class EBISLevel;
00417 };
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427 class EBGraph
00428 {
00429 public:
00430
00431
00432
00433
00434
00435 enum TAG
00436 {
00437 AllRegular = 0,
00438 AllCovered,
00439 HasIrregular
00440 };
00441
00442
00443
00444
00445
00446 EBGraph();
00447
00448
00449 ~EBGraph();
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461 const BaseFab<char>& getMask(int& a_regIrregCovered) const;
00462
00463
00464
00465
00466
00467 Vector<VolIndex> getVoFs(const IntVect& a_iv) const;
00468
00469
00470 long long numVoFs(const IntVect& a_iv) const;
00471
00472
00473 long long numVoFs(const Box& a_box) const;
00474
00475
00476
00477
00478
00479 bool isAllRegular() const;
00480
00481
00482
00483
00484
00485 bool hasIrregular() const;
00486
00487
00488
00489
00490
00491 bool isAllCovered() const;
00492
00493
00494
00495
00496
00497 bool isIrregular(const IntVect& a_iv) const;
00498
00499
00500
00501
00502
00503
00504 bool isCovered(const Box& a_box) const;
00505
00506
00507
00508
00509
00510
00511 bool isRegular(const Box& a_box) const;
00512
00513
00514 bool isRegular(const IntVect& a_iv) const;
00515
00516
00517 bool isCovered(const IntVect& a_iv) const;
00518
00519
00520 bool isMultiValued(const IntVect& a_iv) const;
00521
00522
00523 bool isConnected(const VolIndex& a_vof1,
00524 const VolIndex& a_vof2) const;
00525
00526
00527
00528
00529
00530 Vector<FaceIndex> getFaces(const VolIndex& a_vof,
00531 const int& a_idir,
00532 const Side::LoHiSide& a_sd) const;
00533
00534
00535 Vector<Vector<VolIndex> > getVoFSets(const Box& a_region) const;
00536
00537
00538
00539
00540
00541
00542 Vector<VolIndex> refine(const VolIndex& a_coarVoF) const;
00543
00544
00545
00546
00547
00548
00549
00550 Vector<FaceIndex> refine(const FaceIndex& a_coarFace, const EBGraph& a_fineGraph) const;
00551
00552
00553
00554
00555
00556
00557
00558 FaceIndex coarsen(const FaceIndex& a_coarFace) const;
00559
00560
00561
00562
00563
00564
00565
00566 VolIndex coarsen(const VolIndex& a_fineVoF) const;
00567
00568
00569
00570
00571
00572
00573
00574 EBGraph(const Box& a_box, int a_comps);
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591 void
00592 buildGraph(const BaseFab<int>& a_regIrregCovered,
00593 const Vector<IrregNode>& a_irregGraph,
00594 const Box& a_validRegion,
00595 const ProblemDomain& a_domain);
00596
00597
00598
00599
00600
00601 void setToAllRegular();
00602
00603
00604
00605
00606
00607 void setToAllCovered();
00608
00609
00610
00611
00612
00613
00614 void define(const Box& box);
00615
00616
00617
00618
00619
00620
00621
00622
00623 void copy(const Box& a_regionFrom,
00624 const Interval& Cd,
00625 const Box& a_regionto,
00626 const EBGraph& a_source,
00627 const Interval& Cs);
00628
00629
00630 const Box& getRegion() const;
00631
00632
00633 const ProblemDomain& getDomain() const;
00634
00635
00636 bool isDefined() const;
00637
00638
00639 bool isDomainSet() const;
00640
00641
00642
00643
00644
00645 void coarsenVoFs(const EBGraph& a_fineGraph,
00646 const Box& a_coarRegion);
00647
00648
00649 void coarsenFaces(const EBGraph& a_coarGhostGraph,
00650 const EBGraph& a_fineEBIS);
00651
00652
00653 void fixFineToCoarse(EBGraph& a_fineEBIS) const;
00654
00655
00656 Vector<int>
00657 coarsenFaces(const VolIndex& a_coarVoF,
00658 const EBGraph& a_coarGhostGraph,
00659 const EBGraph& a_fineGraph,
00660 const int& a_idir,
00661 const Side::LoHiSide& a_sd);
00662
00663
00664 void setDomain(const ProblemDomain& a_domain);
00665
00666
00667 IntVectSet getIrregCells(const Box& a_subbox) const;
00668
00669
00670 IntVectSet getMultiCells(const Box& a_subbox) const;
00671
00672
00673 EBGraph& operator=(const EBGraph& ebiin);
00674
00675
00676 EBGraph(const EBGraph& a_ebiin);
00677
00678
00679 Vector<FaceIndex>
00680 getAllFaces(const IntVect& a_iv,
00681 const int& a_idir,
00682 const Side::LoHiSide& a_sd) const;
00683
00684
00685 Vector<FaceIndex>
00686 getIrregFaces(const Box& a_box, int a_dir) const;
00687
00688 void fillMask(BaseFab<char>& a_mask) const;
00689
00690
00691
00692
00693
00694
00695
00696
00697 void fillCellTypeMask(BaseFab<char>& a_mask) const;
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709 EBGraph(const Box& box);
00710
00711 bool operator==(const EBGraph& a_ebiin);
00712
00713
00714 bool operator<(const EBGraph& a_ebiin) const;
00715
00716
00717
00718
00719
00720 int size(const Box& R, const Interval& comps) const;
00721
00722
00723 void linearOut(void* buf, const Box& R, const Interval& comps) const;
00724
00725
00726 void linearIn(void* buf, const Box& R, const Interval& comps);
00727
00728
00729 static int preAllocatable()
00730 {
00731 return 2;
00732 }
00733
00734
00735 void addFullIrregularVoFs(const IntVectSet& a_vofsToChange,
00736 const EBGraph& a_ghostGraph);
00737
00738 void addEmptyIrregularVoFs(const IntVectSet& a_vofsToChange);
00739
00740
00741 void
00742 getRegNextToMultiValued(IntVectSet& a_vofsToChange,
00743 const EBGraph& a_ghostGraph) const;
00744
00745
00746 Vector<FaceIndex> getMultiValuedFaces(const int& a_idir, const Box& a_box) const;
00747
00748 long long numFaces(const Box& a_box, int a_dir) const ;
00749
00750 const FaceIterator& FaceIteratorCache(const IntVectSet& ivs, int a_direction,
00751 FaceStop::WhichFaces a_loc) const;
00752
00753 const FaceIterator& FaceIteratorCache(const Box& a_region, int a_direction,
00754 FaceStop::WhichFaces a_loc) const;
00755
00756 const VoFIterator& VoFIteratorCache(const IntVectSet& ivs) const;
00757
00758 private:
00759
00760
00761 RefCountedPtr<EBGraphImplem> m_implem;
00762
00763 friend class EBIndexSpace;
00764 friend class EBISLevel;
00765 };
00766
00767
00768
00769 template <>
00770 void dataTypes(Vector<hid_t>& a_types, const EBGraph& a_dummySpecializationArg);
00771
00772 template <>
00773 void dataSize(const EBGraph& item, Vector<int>& a_sizes,
00774 const Box& box, const Interval& comps);
00775
00776 template <>
00777 void write(const EBGraph& item, Vector<void*>& a_allocatedBuffers,
00778 const Box& box, const Interval& comps);
00779
00780 template <>
00781 void read(EBGraph& item, Vector<void*>& a_allocatedBuffers, const Box& box,
00782 const Interval& comps);
00783
00784 template <>
00785 const char* name(const EBGraph& a_dummySpecializationArg);
00786
00787
00788
00789
00790
00791
00792 inline
00793 const BaseFab<char>&
00794 EBGraph::getMask(int& a_regIrregCovered) const
00795 {
00796 return m_implem->getMask(a_regIrregCovered);
00797 }
00798
00799 inline void
00800 EBGraph::buildGraph(const BaseFab<int>& a_regIrregCovered,
00801 const Vector<IrregNode>& a_irregGraph,
00802 const Box& a_validRegion,
00803 const ProblemDomain& a_domain)
00804 {
00805 m_implem->buildGraph(a_regIrregCovered, a_irregGraph, a_validRegion, a_domain);
00806 }
00807
00808 inline void EBGraph::copy(const Box& a_regionFrom,
00809 const Interval& Cd,
00810 const Box& a_regionTo,
00811 const EBGraph& a_source,
00812 const Interval& Cs)
00813 {
00814 m_implem->copy(a_regionFrom, Cd, a_regionTo,
00815 *(a_source.m_implem), Cs);
00816 }
00817
00818 inline bool EBGraph::isDefined() const
00819 {
00820 return m_implem->isDefined();
00821 }
00822
00823 inline bool EBGraph::isConnected(const VolIndex& a_vof1,
00824 const VolIndex& a_vof2) const
00825 {
00826 return m_implem->isConnected(a_vof1, a_vof2);
00827 }
00828
00829 inline const Box& EBGraph::getRegion() const
00830 {
00831 return m_implem->getRegion();
00832 }
00833
00834 inline EBGraph& EBGraph::operator=(const EBGraph& a_ebiin)
00835 {
00836 if (&a_ebiin != this)
00837 {
00838 m_implem = a_ebiin.m_implem;
00839 }
00840 return *this;
00841 }
00842
00843
00844 inline IntVectSet EBGraph::getMultiCells(const Box& a_subbox) const
00845 {
00846 return m_implem->getMultiCells(a_subbox);
00847 }
00848
00849 inline IntVectSet EBGraph::getIrregCells(const Box& a_subbox) const
00850 {
00851 return m_implem->getIrregCells(a_subbox);
00852 }
00853
00854 inline Vector<VolIndex> EBGraph::getVoFs(const IntVect& a_iv) const
00855 {
00856 return m_implem->getVoFs(a_iv);
00857 }
00858
00859 inline bool EBGraph::isRegular(const IntVect& a_iv) const
00860 {
00861 return m_implem->isRegular(a_iv);
00862 }
00863
00864 inline bool EBGraph::isAllRegular() const
00865 {
00866 return m_implem->isAllRegular();
00867 }
00868
00869 inline bool EBGraph::isAllCovered() const
00870 {
00871 return m_implem->isAllCovered();
00872 }
00873
00874 inline bool EBGraph::isIrregular(const IntVect& a_iv) const
00875 {
00876 return m_implem->isIrregular(a_iv);
00877 }
00878
00879 inline bool EBGraph::isCovered(const IntVect& a_iv) const
00880 {
00881 return m_implem->isCovered(a_iv);
00882 }
00883
00884 inline bool EBGraph::isMultiValued(const IntVect& a_iv) const
00885 {
00886 return m_implem->isMultiValued(a_iv);
00887 }
00888
00889 inline bool EBGraph::isCovered(const Box& a_box) const
00890 {
00891 return m_implem->isCovered(a_box);
00892 }
00893
00894 inline bool EBGraph::isRegular(const Box& a_box) const
00895 {
00896 return m_implem->isRegular(a_box);
00897 }
00898
00899 inline Vector<FaceIndex>
00900 EBGraph::getFaces(const VolIndex& a_vof,
00901 const int& a_idir,
00902 const Side::LoHiSide& a_sd) const
00903 {
00904 return m_implem->getFaces(a_vof, a_idir, a_sd);
00905 }
00906
00907 inline Vector<VolIndex>
00908 EBGraph::refine(const VolIndex& a_coarVoF) const
00909 {
00910 return m_implem->refine(a_coarVoF);
00911 }
00912
00913 inline Vector<FaceIndex>
00914 EBGraph::refine(const FaceIndex& a_coarFace, const EBGraph& a_fineGraph) const
00915 {
00916 return m_implem->refine(a_coarFace, *a_fineGraph.m_implem);
00917 }
00918
00919 inline FaceIndex EBGraph::coarsen(const FaceIndex& a_fineFace) const
00920 {
00921 return m_implem->coarsen(a_fineFace);
00922 }
00923
00924 inline VolIndex EBGraph::coarsen(const VolIndex& a_fineVoF) const
00925 {
00926 return m_implem->coarsen(a_fineVoF);
00927 }
00928
00929 inline bool EBGraph::operator==(const EBGraph& a_ebiin)
00930 {
00931 return (m_implem == a_ebiin.m_implem);
00932 }
00933
00934 inline bool EBGraph::operator<(const EBGraph& a_ebiin) const
00935 {
00936 return (m_implem < a_ebiin.m_implem);
00937 }
00938
00939 inline const ProblemDomain& EBGraph::getDomain() const
00940 {
00941 return (m_implem->getDomain());
00942 }
00943
00944 inline void EBGraph::setDomain(const ProblemDomain& a_domain)
00945 {
00946 m_implem->setDomain(a_domain);
00947 }
00948
00949 inline void EBGraph::setToAllRegular()
00950 {
00951 m_implem->setToAllRegular();
00952 }
00953
00954 inline void EBGraph::setToAllCovered()
00955 {
00956 m_implem->setToAllCovered();
00957 }
00958
00959 inline void EBGraph::
00960 coarsenVoFs(const EBGraph& a_fineEBIS,
00961 const Box& a_coarRegion)
00962 {
00963 m_implem->coarsenVoFs(*a_fineEBIS.m_implem, a_coarRegion);
00964 }
00965
00966 inline void EBGraph::
00967 coarsenFaces(const EBGraph& a_coarGhost, const EBGraph& a_fineEBIS)
00968 {
00969 m_implem->coarsenFaces(*a_coarGhost.m_implem, *a_fineEBIS.m_implem);
00970 }
00971
00972 inline void EBGraph::
00973 fixFineToCoarse(EBGraph& a_fineEBIS) const
00974 {
00975 m_implem->fixFineToCoarse(*a_fineEBIS.m_implem);
00976 }
00977
00978 inline Vector<FaceIndex>
00979 EBGraph::getAllFaces(const IntVect& a_iv,
00980 const int& a_idir,
00981 const Side::LoHiSide& a_sd) const
00982 {
00983 return m_implem->getAllFaces(a_iv, a_idir, a_sd);
00984 }
00985
00986
00987
00988 inline long long
00989 EBGraph::numVoFs(const IntVect& a_iv) const
00990 {
00991 return m_implem->numVoFs(a_iv);
00992 }
00993
00994 inline long long
00995 EBGraph::numVoFs(const Box& a_box) const
00996 {
00997 return m_implem->numVoFs(a_box);
00998 }
00999
01000 inline
01001 const FaceIterator& EBGraph::FaceIteratorCache(const Box& a_region, int a_direction,
01002 FaceStop::WhichFaces a_loc) const
01003 {
01004 return m_implem->FaceIteratorCache(a_region, a_direction, a_loc, *this);
01005 }
01006
01007 inline
01008 const FaceIterator& EBGraph::FaceIteratorCache(const IntVectSet& a_region, int a_direction,
01009 FaceStop::WhichFaces a_loc) const
01010 {
01011 return m_implem->FaceIteratorCache(a_region, a_direction, a_loc, *this);
01012 }
01013 inline
01014 const VoFIterator& EBGraph::VoFIteratorCache(const IntVectSet& ivs) const
01015 {
01016 return m_implem->VoFIteratorCache(ivs, *this);
01017 }
01018
01019 #include "NamespaceFooter.H"
01020 #endif