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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _BASEFAB_H_
00053 #define _BASEFAB_H_
00054
00055 #include <cstdlib>
00056 #include <assert.h>
00057 #include <string>
00058 #include <typeinfo>
00059
00060 #include "Box.H"
00061 #include "Arena.H"
00062 #include "Interval.H"
00063 #include "REAL.H"
00064
00111 extern Real BaseFabRealSetVal;
00112
00113 template <class T> class BaseFab
00114 {
00115 public:
00117
00124 BaseFab ();
00125
00127
00130 BaseFab(const Box& a_bx,
00131 int a_n,
00132 T* a_alias = NULL);
00133
00147 BaseFab(const Interval& a_comps,
00148 BaseFab<T>& a_original);
00149
00151
00155 virtual ~BaseFab();
00156
00166 void resize(const Box& a_b,
00167 int a_n = 1,
00168 T* a_alias=NULL);
00169
00174 virtual void define(const Box& a_box,
00175 int a_comps,
00176 T* a_alias = NULL)
00177 {
00178 resize(a_box, a_comps, a_alias);
00179 }
00180
00185 virtual void define(const Interval& a_comps,
00186 BaseFab<T>& a_original);
00187
00192 void clear();
00193
00195
00197
00200 int nComp() const;
00201
00203
00206 const Box& box() const;
00207
00212 const int* size() const;
00213
00217 const IntVect& smallEnd() const;
00218
00222 const IntVect& bigEnd() const;
00223
00225
00228 Interval interval() const
00229 {
00230 return Interval(0, m_nvar-1);
00231 }
00232
00238 T& operator () (const IntVect& a_p,
00239 int a_N);
00240
00241 T& operator () (const IntVect& a_p);
00242
00248 const T& operator () (const IntVect& p,
00249 int N) const;
00250
00251 const T& operator () (const IntVect& p) const;
00252
00258 void getVal(T* a_data,
00259 const IntVect& a_pos,
00260 int a_N,
00261 int a_numcomp) const;
00262
00268 void getVal(T* a_data,
00269 const IntVect& a_pos) const;
00270
00272
00280 const int* loVect() const;
00281
00289 const int* hiVect() const;
00290
00296 const int* nCompPtr() const;
00297
00307 T* dataPtr(int a_n = 0);
00308
00318 const T* dataPtr(int a_n = 0) const;
00319
00321
00326 bool contains(const BaseFab<T>& a_fab) const;
00327
00332 bool contains(const Box& a_bx) const;
00333
00335
00341 void setVal(T a_x,
00342 const Box& a_bx,
00343 int a_nstart,
00344 int a_numcomp);
00345
00347
00351 void setVal(T a_x,
00352 const Box& a_bx,
00353 int a_n);
00354
00356
00360 void setVal(T a_x,
00361 int a_n);
00362
00364
00368 void setVal(T a_x);
00369
00385 BaseFab<T>& copy(const BaseFab<T>& a_src,
00386 const Box& a_srcbox,
00387 int a_srccomp,
00388 const Box& a_destbox,
00389 int a_destcomp,
00390 int a_numcomp);
00391
00399 BaseFab<T>& copy(const BaseFab<T>& a_src,
00400 int a_srccomp,
00401 int a_destcomp,
00402 int a_numcomp = 1);
00403
00410 BaseFab<T>& copy(const BaseFab<T>& a_src,
00411 const Box& a_destbox);
00412
00418 BaseFab<T>& copy(const BaseFab<T>& a_src);
00419
00421
00426 void copy(const Box& a_RegionFrom,
00427 const Interval& a_Cdest,
00428 const Box& a_RegionTo,
00429 const BaseFab<T>& a_src,
00430 const Interval& a_Csrc);
00431
00433
00435
00440 BaseFab<T>& shift(const IntVect& a_v);
00441
00443
00449 BaseFab<T>& shift(int a_idir,
00450 int a_ncells);
00451
00453
00463 BaseFab<T>& shiftHalf(int a_dir,
00464 int a_numHalfs);
00465
00467
00472 BaseFab<T>& shiftHalf(const IntVect& a_v);
00473
00475
00477
00483 virtual int size(const Box& a_box,
00484 const Interval& a_comps) const;
00485
00487
00492 virtual void linearOut(void* a_buf,
00493 const Box& a_R,
00494 const Interval& a_comps) const;
00495
00497 virtual void linearIn(void* a_buf,
00498 const Box& a_R,
00499 const Interval& a_comps);
00500
00502 static int preAllocatable()
00503 {
00504 return 0;
00505 }
00506
00507
00508 protected:
00509
00510
00511
00512 void define();
00513
00514
00515
00516
00517 void undefine();
00518
00519 static std::string name();
00520
00521
00522
00523
00524 virtual void performCopy(const BaseFab<T>& a_src,
00525 const Box& a_srcbox,
00526 int a_srccomp,
00527 const Box& a_destbox,
00528 int a_destcomp,
00529 int a_numcomp);
00530
00531
00532
00533
00534 void performSetVal(T a_x,
00535 const Box& a_bx,
00536 int a_nstart,
00537 int a_numcomp);
00538
00539
00540
00541
00542
00543
00544 static Arena* s_Arena;
00545
00546 Box m_domain;
00547 int m_nvar;
00548 long m_numpts;
00549 long m_truesize;
00550
00551 T* m_dptr;
00552 bool m_aliased;
00553
00554 private:
00555
00556
00557
00558
00559 BaseFab<T>& operator= (const BaseFab<T>&);
00560 BaseFab (const BaseFab<T>&);
00561 };
00562
00563 #include "BaseFabImplem.H"
00564
00565 #endif