00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BL_BOXLIST_H
00024 #define BL_BOXLIST_H
00025
00026
00027
00028 #include <iosfwd>
00029 #include <list>
00030
00031 #include <IntVect.H>
00032 #include <IndexType.H>
00033 #include <Box.H>
00034
00035
00036
00037 class BoxArray;
00038 class BoxList;
00039
00040 namespace BoxLib
00041 {
00045 BoxList complementIn (const Box& b, const BoxList& bl);
00046
00047
00049
00050 BoxList boxDiff (const Box& b1in, const Box& b2);
00051
00055 BoxList refine (const BoxList& bl, int ratio);
00056
00060 BoxList coarsen (const BoxList& bl, int ratio);
00061
00063
00064 BoxList intersect (const BoxList& bl, const Box& b);
00065
00067
00068 BoxList intersect (const BoxList& bl, const BoxList& br);
00069
00073 BoxList accrete (const BoxList& bl, int sz);
00074 }
00075
00076
00078
00079 std::ostream& operator<< (std::ostream& os, const BoxList& blist);
00080
00081
00082
00084
00092 class BoxList
00093 {
00094 public:
00095
00096 friend class BoxDomain;
00097
00098 typedef std::list<Box>::iterator iterator;
00099 typedef std::list<Box>::const_iterator const_iterator;
00100
00102
00103 BoxList ();
00104
00106
00107 BoxList (const Box& bx);
00108
00110
00111 explicit BoxList (IndexType btyp);
00112
00114
00115 explicit BoxList (const BoxArray& ba);
00116
00117
00119
00120 void push_back (const Box& bn);
00121
00123
00124 void push_front (const Box& bn);
00125
00127
00128 void join (const BoxList& blist);
00129
00131
00132 void catenate (BoxList& blist);
00133
00135
00136 void clear ();
00137
00139
00140 int size () const;
00141
00142 iterator begin ();
00143 const_iterator begin () const;
00144
00145 iterator end ();
00146 const_iterator end () const;
00147
00152 bool ok () const;
00153
00155
00156 bool operator== (const BoxList& rhs) const;
00157
00159
00160 bool operator!= (const BoxList& rhs) const;
00161
00163
00164 bool isEmpty () const;
00165
00167
00168 bool isNotEmpty () const;
00169
00171
00172 bool isDisjoint () const;
00173
00175
00176 bool contains (const IntVect& v) const;
00177
00182 bool contains (const Box& b) const;
00183
00185
00186 bool contains (const BoxList& bl) const;
00187
00189
00190 bool contains (const BoxArray& ba) const;
00191
00195 BoxList& intersect (const Box& b);
00196
00200 BoxList& intersect (const BoxList& b);
00201
00203
00204 BoxList& remove (const Box& bx);
00205
00207
00208 BoxList& remove (iterator bli);
00209
00211
00212 BoxList& complementIn (const Box& b,
00213 const BoxList& bl);
00214
00216
00217 BoxList& refine (int ratio);
00218
00220
00221 BoxList& refine (const IntVect& ratio);
00222
00224
00225 BoxList& coarsen (int ratio);
00226
00228
00229 BoxList& coarsen (const IntVect& ratio);
00230
00232
00233 BoxList& accrete (int sz);
00234
00236
00237 BoxList& shift (int dir,
00238 int nzones);
00239
00241
00242 BoxList& shiftHalf (int dir,
00243 int num_halfs);
00244
00246
00247 BoxList& shiftHalf (const IntVect& iv);
00248
00252 int simplify ();
00253
00257 int minimize ();
00258
00260
00261 BoxList& maxSize (int chunk);
00262
00266 BoxList& maxSize (const IntVect& chunk);
00267
00269
00270 Box minimalBox () const;
00271
00273
00274 IndexType ixType () const;
00275
00279 BoxList& surroundingNodes ();
00280
00284 BoxList& surroundingNodes (int dir);
00285
00287
00288 BoxList& enclosedCells ();
00289
00291
00292 BoxList& enclosedCells (int dir);
00293
00295
00296 BoxList& convert (IndexType typ);
00297
00298 protected:
00299
00300
00301
00302 std::list<Box> lbox;
00303
00304
00305
00306 std::list<Box>& listBox();
00307
00308
00309
00310 const std::list<Box>& listBox() const;
00311
00312 private:
00313
00314
00315
00316 IndexType btype;
00317 };
00318
00319 inline
00320 BoxList::iterator
00321 BoxList::begin()
00322 {
00323 return lbox.begin();
00324 }
00325
00326 inline
00327 BoxList::const_iterator
00328 BoxList::begin() const
00329 {
00330 return lbox.begin();
00331 }
00332
00333 inline
00334 BoxList::iterator
00335 BoxList::end()
00336 {
00337 return lbox.end();
00338 }
00339
00340 inline
00341 BoxList::const_iterator
00342 BoxList::end() const
00343 {
00344 return lbox.end();
00345 }
00346
00347 inline
00348 IndexType
00349 BoxList::ixType () const
00350 {
00351 return btype;
00352 }
00353
00354 inline
00355 void
00356 BoxList::push_back (const Box& bn)
00357 {
00358 BL_ASSERT(ixType() == bn.ixType());
00359 lbox.push_back(bn);
00360 }
00361
00362 inline
00363 void
00364 BoxList::push_front (const Box& bn)
00365 {
00366 BL_ASSERT(ixType() == bn.ixType());
00367 lbox.push_front(bn);
00368 }
00369
00370 inline
00371 bool
00372 BoxList::isEmpty () const
00373 {
00374 return lbox.empty();
00375 }
00376
00377 inline
00378 int
00379 BoxList::size () const
00380 {
00381 return lbox.size();
00382 }
00383
00384 inline
00385 bool
00386 BoxList::isNotEmpty () const
00387 {
00388 return !lbox.empty();
00389 }
00390
00391 inline
00392 std::list<Box>&
00393 BoxList::listBox()
00394 {
00395 return lbox;
00396 }
00397
00398 inline
00399 const std::list<Box>&
00400 BoxList::listBox() const
00401 {
00402 return lbox;
00403 }
00404
00405 inline
00406 void
00407 BoxList::clear ()
00408 {
00409 lbox.clear();
00410 }
00411
00412 #endif