Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

IntVectSet.H

Go to the documentation of this file.
00001 /* _______              __
00002   / ___/ /  ___  __ _  / /  ___
00003  / /__/ _ \/ _ \/  ' \/ _ \/ _ \
00004  \___/_//_/\___/_/_/_/_.__/\___/ 
00005 */
00006 //
00007 // This software is copyright (C) by the Lawrence Berkeley
00008 // National Laboratory.  Permission is granted to reproduce
00009 // this software for non-commercial purposes provided that
00010 // this notice is left intact.
00011 // 
00012 // It is acknowledged that the U.S. Government has rights to
00013 // this software under Contract DE-AC03-765F00098 between
00014 // the U.S.  Department of Energy and the University of
00015 // California.
00016 //
00017 // This software is provided as a professional and academic
00018 // contribution for joint exchange. Thus it is experimental,
00019 // is provided ``as is'', with no warranties of any kind
00020 // whatsoever, no support, no promise of updates, or printed
00021 // documentation. By using this software, you acknowledge
00022 // that the Lawrence Berkeley National Laboratory and
00023 // Regents of the University of California shall have no
00024 // liability with respect to the infringement of other
00025 // copyrights by any part of this software.
00026 //
00027 
00028 #ifndef _INTVECTSET_H_
00029 #define _INTVECTSET_H_
00030 
00031 #include "SPACE.H"
00032 
00033 #ifndef WRAPPER
00034 #include <iostream>
00035 #include "Box.H"
00036 #include "IntVect.H"
00037 #include "TreeIntVectSet.H"
00038 #include "DenseIntVectSet.H"
00039 #include "parstream.H"
00040 
00041 #endif
00042 
00044 
00059 class IntVectSet
00060 {
00061 public:
00062   friend
00063   class IVSIterator;
00065 
00066   ~IntVectSet();
00068 
00070   IntVectSet();
00071   void
00072   define();
00073 
00075 
00077   IntVectSet(const IntVectSet& ige_in);
00078   void
00079   define(const IntVectSet& ige_in);
00080   
00081   IntVectSet copy() const {return *this;}
00082 
00083   void define_intvectset(const IntVectSet& ige_in){ define(ige_in);}
00085 
00086   explicit
00087   IntVectSet(const DenseIntVectSet& a_dense);
00088   void
00089   define (const DenseIntVectSet& a_dense);
00090 
00092 
00093   explicit
00094   IntVectSet(const TreeIntVectSet& a_tree);
00095   void
00096   define (const TreeIntVectSet& a_tree);
00097 
00099 
00101   explicit
00102   IntVectSet(const IntVect& iv_in);
00103   void define(const IntVect& iv_in);
00104   void define_intvect(const IntVect& iv_in){define(iv_in);}
00106 
00108   explicit
00109   IntVectSet(const Box& b);
00110   void
00111   define(const Box& b);
00112   void define_box(const Box& b){define(b);}
00113 
00114 
00116 
00118 
00125   friend
00126   IntVectSet 
00127   operator|(const IntVectSet& ivs1, const IntVectSet& ivs2);
00128 
00130 
00138   friend
00139   IntVectSet 
00140   operator|(const IntVectSet& ivs, const IntVect& iv);
00141 
00143 
00151   friend
00152   IntVectSet 
00153   operator|(const IntVect& iv, const IntVectSet& ivs);
00154 
00156 
00164   friend
00165   IntVectSet 
00166   operator|(const IntVectSet& ivs, const Box& b);
00167 
00169 
00177   friend
00178   IntVectSet 
00179   operator|(const Box& b, const IntVectSet& ivs);
00180 
00181 
00183 
00192   IntVectSet&
00193   operator|=(const IntVectSet& ivs);
00194 
00195   void or_intvectset(const IntVectSet& ivs) { *this |= ivs;}
00196 
00198 
00207   IntVectSet&
00208   operator|=(const IntVect& iv);
00209   void or_intvect(const IntVect& ivs) { *this |= ivs;}
00210 
00211 
00213 
00222   IntVectSet&
00223   operator|=(const Box& b);
00224   void or_box(const Box& b) { *this |= b;}
00225 
00226 
00227 
00229 
00231 
00234   IntVectSet
00235   operator-(const IntVectSet& ivs) const;
00236 
00238 
00241   IntVectSet
00242   operator-(const Box& b) const;
00243 
00245   IntVectSet 
00249   operator-(const IntVect& iv) const;
00250 
00252 
00258   IntVectSet&
00259   operator-=(const IntVectSet& ivs);
00260   void minus(const IntVectSet& ivs){*this -= ivs;}
00261 
00263 
00269   IntVectSet&
00270   operator-=(const Box& b);
00271   void minus_box(const Box& b){ *this -=b;}
00272 
00273 
00275 
00281   IntVectSet&
00282   operator-=(const IntVect& iv);
00283   void minus_intvect(const IntVect& iv){ *this -=iv;}
00284 
00286 
00288 
00295   friend 
00296   IntVectSet
00297   operator&(const IntVectSet& ivs1, const IntVectSet& ivs2);
00298 
00300 
00307   friend
00308   IntVectSet 
00309   operator&(const IntVectSet& ivs, const Box& b);
00310 
00312 
00319   friend
00320   IntVectSet 
00321   operator&(const Box& b, const IntVectSet& ivs);
00322 
00324 
00333   IntVectSet&
00334   operator&=(const IntVectSet& ivs);
00335   void and_intvectset(const IntVectSet& ivs){*this &= ivs;}
00336 
00337 
00338 
00340 
00349   IntVectSet&
00350   operator&=(const Box& b);
00351   void and_box(const Box& b){*this &= b;}
00352 
00354 
00363   IntVectSet&
00364   operator&=(const ProblemDomain& domain);
00365   void and_domain(const ProblemDomain& d){*this &= d;}
00366 
00367 
00369 
00371 
00382   void 
00383   grow(int igrow);
00385 
00394   friend
00395   IntVectSet
00396   grow(const IntVectSet& ivs, int igrow);
00397 
00398 
00399 
00401 
00413   IntVectSet&
00414   grow(int idir, int igrow);
00415   void grow_dir(int idir, int igrow){grow(idir, igrow);}
00416 
00418 
00427   IntVectSet&
00428   refine(int iref = 2);
00429 
00431 
00439   friend
00440   IntVectSet
00441   refine(const IntVectSet& ivs, int iref = 2);
00442 
00443 
00445 
00454   IntVectSet&
00455   coarsen(int iref = 2);
00456 
00458 
00466   friend
00467   IntVectSet
00468   coarsen(const IntVectSet& ivs, int iref = 2);
00469 
00471 
00475   void
00476   shift(const IntVect& iv);
00477 
00479 
00484   void
00485   nestingRegion(int radius, const Box& domain);
00486 
00488 
00494   void
00495   nestingRegion(int radius, const ProblemDomain& domain);
00496   void  nestingRegion_prob(int radius, const ProblemDomain& domain)
00497   {nestingRegion(radius, domain);}
00498 
00500 
00501   void
00502   makeEmpty();
00503 
00505 
00510   IntVectSet
00511   chop(int dir, int chop_pnt);
00512 
00513 
00515 
00517 
00518   int
00519   numPts() const;
00520 
00522 
00523   const Box&
00524   minBox() const;
00525 
00527 
00528   void recalcMinBox() const;
00529 
00531 
00532   bool
00533   isEmpty() const;
00534 
00536 
00537   bool
00538   isDense() const;
00539 
00540 
00542 
00543   bool
00544   contains(const IntVect& iv) const;
00545 
00547 
00548   bool
00549   contains(const IntVectSet& iv) const;
00550   bool contains_intvectset(const IntVectSet& iv) const {return contains(iv);}
00551 
00553 
00556   bool
00557   contains(const Box& box) const;
00558   bool contains_box(const Box& b) const {return contains(b);}
00559 
00561 
00564   Vector<Box>
00565   boxes() const;
00566 
00568 
00573   void compact() const;
00574 
00576 
00579   void
00580   printBoxes(std::ostream& a_ostrm) const;
00581 
00582   void p() const { printBoxes(pout());}
00583 
00584   friend
00585   std::ostream& operator<<(std::ostream& os, const IntVectSet& ivs);
00586 
00587 
00588   void convert() const; // turn dense rep into Tree rep.  very costly. 
00589                         // it is 'logically' const, but does modify data structures;
00590 
00591   // not for public consumption.  used in memory tracking.
00592   static long int count;
00593   static long int peakcount;
00594 private:
00595 
00596   bool m_isdense;
00597   TreeIntVectSet m_ivs;
00598   DenseIntVectSet m_dense;
00599 
00600   // not a user function.  called by memory tracking system on
00601   // exit to clean up static allocation pools used for the optimization
00602   // of these routines.
00603   friend void dumpmemoryatexit();
00604   static void clearStaticMemory(); // after this functon is called, you cannot
00605                               // do any other operations with IntVectSet.
00606 };
00607 
00608 
00609 
00610 
00611 
00613 
00629 class IVSIterator
00630 {
00631 public:
00633   IVSIterator():m_isdense(true) {;}
00634 
00636   IVSIterator(const IntVectSet& ivs);
00637 
00638   ~IVSIterator(){;}
00639 
00641   void define(const IntVectSet& ivs);
00642 
00644   const IntVect& operator()() const ;
00645 
00646   const IntVect& iv() const { return this->operator()();}
00647 
00649   bool ok() const;
00650 
00652   void operator++();
00653 
00654   void incr() { ++(*this);}
00655 
00657   void begin();
00658 
00660   void reset();
00661 
00663   void end();
00664 private:
00665   bool m_isdense;
00666   DenseIntVectSetIterator m_dense;
00667   TreeIntVectSetIterator  m_tree;
00668 };
00669 
00670 
00671 
00672 #ifndef WRAPPER
00673 
00674 
00675 
00676 inline const IntVect& IVSIterator::operator()() const
00677 {
00678   if(m_isdense) return m_dense();
00679   return m_tree();
00680 }
00681 
00682 inline bool IVSIterator::ok() const
00683 {
00684   if(m_isdense) return m_dense.ok();
00685   return m_tree.ok();
00686 }
00687 
00688 inline void  IVSIterator::operator++()
00689 {
00690   if(m_isdense) ++m_dense;
00691   else          ++m_tree;
00692 }
00693 inline void IVSIterator::reset()
00694 {
00695   begin();
00696 }
00697 
00698 inline void IVSIterator::begin()
00699 {
00700   if(m_isdense) m_dense.begin();
00701   else          m_tree.begin();
00702 }
00703 
00704 inline void IVSIterator::end()
00705 {
00706   if(m_isdense) m_dense.end();
00707   else          m_tree.end();
00708 }
00709 
00710 
00711 inline IntVectSet::IntVectSet(): m_isdense(true) 
00712 {
00713   count++;
00714   if(count > peakcount) peakcount = count;
00715 }
00716 
00717 inline void IntVectSet::define(const IntVectSet& ige_in)
00718 {
00719   *this = ige_in;
00720 }
00721 
00722 inline IntVectSet::IntVectSet(const IntVectSet& ige_in)
00723 {
00724   count++;
00725   if(count > peakcount) peakcount = count;
00726 
00727   *this = ige_in;
00728 }
00729 
00730 inline   bool
00731 IntVectSet::isDense() const
00732 {
00733   return m_isdense;
00734 }
00735 
00736 #endif /* WRAPPER */
00737 
00738 #endif

Generated on Wed Apr 16 14:31:05 2003 for EBChombo by doxygen1.2.16