00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _BASEFAB_H_
00012 #define _BASEFAB_H_
00013
00014 #include <cstdlib>
00015 #include "SPACE.H"
00016 #include <string>
00017 #include <typeinfo>
00018 #include <cmath>
00019
00020 #include "Box.H"
00021 #include "Arena.H"
00022 #include "Interval.H"
00023 #include "REAL.H"
00024 #include "NamespaceHeader.H"
00025
00026 class SliceSpec;
00027
00074 extern Real BaseFabRealSetVal;
00075
00076 template <class T> class BaseFab
00077 {
00078 public:
00080
00087 BaseFab ();
00088
00090
00093 BaseFab(const Box& a_bx,
00094 int a_n,
00095 T* a_alias = NULL);
00096
00110 BaseFab(const Interval& a_comps,
00111 BaseFab<T>& a_original);
00112
00114
00118 virtual ~BaseFab();
00119
00126 void resize(const Box& a_b,
00127 int a_n = 1,
00128 T* a_alias=NULL);
00129
00134 virtual void define(const Box& a_box,
00135 int a_comps,
00136 T* a_alias = NULL)
00137 {
00138 resize(a_box, a_comps, a_alias);
00139 }
00140
00145 virtual void define(const Interval& a_comps,
00146 BaseFab<T>& a_original);
00147
00152 void clear();
00153
00155
00157
00160 int nComp() const;
00161
00163
00166 const Box& box() const;
00167
00172 IntVect size() const;
00173
00177 const IntVect& smallEnd() const;
00178
00182 const IntVect& bigEnd() const;
00183
00185
00188 Interval interval() const
00189 {
00190 return Interval(0, m_nvar-1);
00191 }
00192
00198 T& operator () (const IntVect& a_p,
00199 int a_N);
00200
00201 T& operator () (const IntVect& a_p);
00202
00208 const T& operator () (const IntVect& p,
00209 int N) const;
00210
00211 const T& operator () (const IntVect& p) const;
00212
00218 void getVal(T* a_data,
00219 const IntVect& a_pos,
00220 int a_N,
00221 int a_numcomp) const;
00222
00228 void getVal(T* a_data,
00229 const IntVect& a_pos) const;
00230
00232
00240 const int* loVect() const;
00241
00249 const int* hiVect() const;
00250
00256 const int* nCompPtr() const;
00257
00267 T* dataPtr(int a_n = 0);
00268
00278 const T* dataPtr(int a_n = 0) const;
00279
00281
00286 bool contains(const BaseFab<T>& a_fab) const;
00287
00292 bool contains(const Box& a_bx) const;
00293
00295
00301 void setVal(T a_x,
00302 const Box& a_bx,
00303 int a_nstart,
00304 int a_numcomp);
00305
00307
00311 void setVal(T a_x,
00312 const Box& a_bx,
00313 int a_n);
00314
00316
00320 void setVal(T a_x,
00321 int a_n);
00322
00324
00328 void setVal(T a_x);
00329
00345 BaseFab<T>& copy(const BaseFab<T>& a_src,
00346 const Box& a_srcbox,
00347 int a_srccomp,
00348 const Box& a_destbox,
00349 int a_destcomp,
00350 int a_numcomp);
00351
00359 BaseFab<T>& copy(const BaseFab<T>& a_src,
00360 int a_srccomp,
00361 int a_destcomp,
00362 int a_numcomp = 1);
00363
00370 BaseFab<T>& copy(const BaseFab<T>& a_src,
00371 const Box& a_destbox);
00372
00378 BaseFab<T>& copy(const BaseFab<T>& a_src);
00379
00381
00386 void copy(const Box& a_RegionFrom,
00387 const Interval& a_Cdest,
00388 const Box& a_RegionTo,
00389 const BaseFab<T>& a_src,
00390 const Interval& a_Csrc);
00391
00393
00395
00400 BaseFab<T>& shift(const IntVect& a_v);
00401
00403
00409 BaseFab<T>& shift(int a_idir,
00410 int a_ncells);
00411
00413
00423 BaseFab<T>& shiftHalf(int a_dir,
00424 int a_numHalfs);
00425
00427
00432 BaseFab<T>& shiftHalf(const IntVect& a_v);
00433
00435
00437
00443 virtual int size(const Box& a_box,
00444 const Interval& a_comps) const;
00445
00447
00452 virtual void linearOut(void* a_buf,
00453 const Box& a_R,
00454 const Interval& a_comps) const;
00455
00457 virtual void linearIn(void* a_buf,
00458 const Box& a_R,
00459 const Interval& a_comps);
00460
00462 static int preAllocatable()
00463 {
00464 return 0;
00465 }
00466
00474 void degenerate(BaseFab<T>& a_slice, const SliceSpec& a_sliceSpec) const;
00475
00476
00478 bool isAliased() const;
00479
00480 protected:
00481
00482
00483
00484 void define();
00485
00486
00487
00488
00489 void undefine();
00490
00491 static std::string name();
00492
00493
00494
00495
00496 virtual void performCopy(const BaseFab<T>& a_src,
00497 const Box& a_srcbox,
00498 int a_srccomp,
00499 const Box& a_destbox,
00500 int a_destcomp,
00501 int a_numcomp);
00502
00503
00504
00505
00506 void performSetVal(T a_x,
00507 const Box& a_bx,
00508 int a_nstart,
00509 int a_numcomp);
00510
00511
00512
00513
00514
00515
00516 static Arena* s_Arena;
00517
00518 Box m_domain;
00519 int m_nvar;
00520 long m_numpts;
00521 long m_truesize;
00522
00523 T* m_dptr;
00524 bool m_aliased;
00525
00526 private:
00527
00528
00529
00530
00531 BaseFab<T>& operator= (const BaseFab<T>&);
00532 BaseFab (const BaseFab<T>&);
00533 };
00534
00535 #include "NamespaceFooter.H"
00536
00537 #include "BaseFabImplem.H"
00538
00539 #endif