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