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   bool
00529   isEmpty() const;
00530 
00532 
00533   bool
00534   isDense() const;
00535 
00536 
00538 
00539   bool
00540   contains(const IntVect& iv) const;
00541 
00543 
00544   bool
00545   contains(const IntVectSet& iv) const;
00546   bool contains_intvectset(const IntVectSet& iv) const {return contains(iv);}
00547 
00549 
00552   bool
00553   contains(const Box& box) const;
00554   bool contains_box(const Box& b) const {return contains(b);}
00555 
00557 
00560   Vector<Box>
00561   boxes() const;
00562 
00564 
00569   void compact() const;
00570 
00572 
00575   void
00576   printBoxes(std::ostream& a_ostrm) const;
00577 
00578   void p() const { printBoxes(pout());}
00579 
00580   friend
00581   std::ostream& operator<<(std::ostream& os, const IntVectSet& ivs);
00582 
00583 
00584   void convert() const; // turn dense rep into Tree rep.  very costly. 
00585                         // it is 'logically' const, but does modify data structures;
00586 
00587   // not for public consumption.  used in memory tracking.
00588   static long int count;
00589   static long int peakcount;
00590 private:
00591 
00592   bool m_isdense;
00593   TreeIntVectSet m_ivs;
00594   DenseIntVectSet m_dense;
00595 
00596   // not a user function.  called by memory tracking system on
00597   // exit to clean up static allocation pools used for the optimization
00598   // of these routines.
00599   friend void dumpmemoryatexit();
00600   static void clearStaticMemory(); // after this functon is called, you cannot
00601                               // do any other operations with IntVectSet.
00602 };
00603 
00604 
00605 
00606 
00607 
00609 
00625 class IVSIterator
00626 {
00627 public:
00629   IVSIterator():m_isdense(true) {;}
00630 
00632   IVSIterator(const IntVectSet& ivs);
00633 
00634   ~IVSIterator(){;}
00635 
00637   void define(const IntVectSet& ivs);
00638 
00640   const IntVect& operator()() const ;
00641 
00642   const IntVect& iv() const { return this->operator()();}
00643 
00645   bool ok() const;
00646 
00648   void operator++();
00649 
00650   void incr() { ++(*this);}
00651 
00653   void begin();
00654 
00656   void reset();
00657 
00659   void end();
00660 private:
00661   bool m_isdense;
00662   DenseIntVectSetIterator m_dense;
00663   TreeIntVectSetIterator  m_tree;
00664 };
00665 
00666 
00667 
00668 #ifndef WRAPPER
00669 
00670 
00671 
00672 inline const IntVect& IVSIterator::operator()() const
00673 {
00674   if(m_isdense) return m_dense();
00675   return m_tree();
00676 }
00677 
00678 inline bool IVSIterator::ok() const
00679 {
00680   if(m_isdense) return m_dense.ok();
00681   return m_tree.ok();
00682 }
00683 
00684 inline void  IVSIterator::operator++()
00685 {
00686   if(m_isdense) ++m_dense;
00687   else          ++m_tree;
00688 }
00689 inline void IVSIterator::reset()
00690 {
00691   begin();
00692 }
00693 
00694 inline void IVSIterator::begin()
00695 {
00696   if(m_isdense) m_dense.begin();
00697   else          m_tree.begin();
00698 }
00699 
00700 inline void IVSIterator::end()
00701 {
00702   if(m_isdense) m_dense.end();
00703   else          m_tree.end();
00704 }
00705 
00706 
00707 inline IntVectSet::IntVectSet(): m_isdense(true) 
00708 {
00709   count++;
00710   if(count > peakcount) peakcount = count;
00711 }
00712 
00713 inline void IntVectSet::define(const IntVectSet& ige_in)
00714 {
00715   *this = ige_in;
00716 }
00717 
00718 inline IntVectSet::IntVectSet(const IntVectSet& ige_in)
00719 {
00720   count++;
00721   if(count > peakcount) peakcount = count;
00722 
00723   *this = ige_in;
00724 }
00725 
00726 inline   bool
00727 IntVectSet::isDense() const
00728 {
00729   return m_isdense;
00730 }
00731 
00732 #endif /* WRAPPER */
00733 
00734 #endif

Generated on Tue Jul 2 10:42:20 2002 for Chombo by doxygen1.2.16