00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef CH_BASEFAB_H
00031 #define CH_BASEFAB_H
00032
00033
00034
00035
00036
00037 #include <cstdlib>
00038 #include <assert.h>
00039 #include <string>
00040 #include <typeinfo>
00041 #include "Box.H"
00042 #include "Arena.H"
00043 #include "Interval.H"
00044 #include "REAL.H"
00045
00046
00047
00094 template <class T>
00095 class BaseFab
00096 {
00097 public:
00098
00100
00106 BaseFab ();
00107
00109
00112 BaseFab (const Box& bx,
00113 int n,
00114 T* alias=NULL);
00115
00129 BaseFab(const Interval& a_comps,
00130 BaseFab<T>& a_original);
00131
00133
00136 virtual ~BaseFab ();
00137
00147 void resize (const Box& b,
00148 int N = 1,
00149 T* alias=NULL);
00150
00154 virtual void define(const Box& box, int comps,
00155 T* alias = NULL) { resize(box, comps, alias);}
00156
00161 virtual void define(const Interval& a_comps, BaseFab<T>& a_original);
00162
00166 void clear ();
00167
00168
00170
00172
00175 int nComp () const;
00176
00178
00181 const Box& box () const;
00182
00186 const int* size () const;
00187
00191 const IntVect& smallEnd () const;
00192
00196 const IntVect& bigEnd () const;
00197
00199
00202 Interval interval() const
00203 { return Interval(0, nvar-1); }
00204
00210 T& operator() (const IntVect& p,
00211 int N);
00212
00213 T& operator() (const IntVect& p);
00214
00220 const T& operator() (const IntVect& p,
00221 int N) const;
00222
00223 const T& operator() (const IntVect& p) const;
00224
00229 void getVal (T* data,
00230 const IntVect& pos,
00231 int N,
00232 int numcomp) const;
00233
00238 void getVal (T* data,
00239 const IntVect& pos) const;
00240
00242
00251 const int* loVect () const;
00252
00261 const int* hiVect () const;
00262
00269 const int* nCompPtr () const;
00270
00282 T* dataPtr (int N = 0);
00283
00295 const T* dataPtr (int N = 0) const;
00296
00298
00302 bool contains (const BaseFab<T>& fab) const;
00303
00307 bool contains (const Box& bx) const;
00308
00310
00316 void setVal (T x,
00317 const Box& bx,
00318 int nstart,
00319 int ncomp);
00320
00322
00327 void setVal (T x,
00328 const Box& bx,
00329 int N);
00330
00332
00337 void setVal (T x,
00338 int N);
00339
00341
00346 void setVal (T x);
00347
00348
00366 BaseFab<T>& copy (const BaseFab<T>& src,
00367 const Box& srcbox,
00368 int srccomp,
00369 const Box& destbox,
00370 int destcomp,
00371 int numcomp);
00372
00381 BaseFab<T>& copy (const BaseFab<T>& src,
00382 int srccomp,
00383 int destcomp,
00384 int numcomp = 1);
00385
00393 BaseFab<T>& copy (const BaseFab<T>& src,
00394 const Box& destbox);
00395
00402 BaseFab<T>& copy (const BaseFab<T>& src);
00403
00405
00410 void copy(const Box& RegionFrom,
00411 const Interval& Cdest,
00412 const Box& RegionTo,
00413 const BaseFab<T>& src,
00414 const Interval& Csrc);
00415
00416
00418
00420
00426 BaseFab<T>& shift (const IntVect& v);
00427
00429
00436 BaseFab<T>& shift (int idir,
00437 int n_cell);
00438
00440
00452 BaseFab<T>& shiftHalf (int dir,
00453 int num_halfs);
00454
00456
00462 BaseFab<T>& shiftHalf (const IntVect& num_halfs);
00463
00465
00467
00473 virtual int size(const Box& b, const Interval& comps) const;
00474
00476
00481 virtual void linearOut(void* buf, const Box& R, const Interval& comps) const;
00482
00484 virtual void linearIn(void* buf, const Box& R, const Interval& comps);
00485
00487 static int preAllocatable(){ return 0;}
00488
00489 protected:
00490
00491
00492
00493 void define ();
00494
00495
00496
00497 void undefine ();
00498
00499
00500
00501
00502
00503 static Arena* s_Arena;
00504
00505
00506 static std::string name();
00507
00508
00509
00510 virtual void performCopy (const BaseFab<T>& src,
00511 const Box& srcbox,
00512 int srccomp,
00513 const Box& destbox,
00514 int destcomp,
00515 int numcomp);
00516
00517
00518
00519
00520 void performSetVal (T x,
00521 const Box& bx,
00522 int nstart,
00523 int numcomp);
00524
00525
00526 private:
00527
00528
00529
00530
00531
00532 BaseFab<T>& operator= (const BaseFab<T>&);
00533 BaseFab (const BaseFab<T>&);
00534
00535 protected:
00536
00537 Box domain;
00538 int nvar;
00539 long numpts;
00540 long truesize;
00541 T* dptr;
00542 bool aliased;
00543 };
00544
00545 #include "BaseFabImplem.H"
00546
00547 #endif
00548