Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

BaseFab.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 //CH_COPYRIGHT_NOTICE
00029 
00030 #ifndef CH_BASEFAB_H
00031 #define CH_BASEFAB_H
00032 
00033 //
00034 // $Id: BaseFab.H,v 1.11 2004/03/12 01:42:13 dmartin Exp $
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;} // static preAllocatable
00488 
00489 protected:
00490   //
00491   // Allocates memory for the `BaseFab<T>'.
00492   //
00493   void define ();
00494   //
00495   // Deallocates memory for the `BaseFab<T>'.
00496   //
00497   void undefine ();
00498   //
00499   // template class static data member.  not sure if this will
00500   // work with all compilers.  It has been in the draft standard
00501   // for some time
00502   //
00503   static Arena* s_Arena;
00504   //
00505   //
00506   static std::string name();
00507   //
00508   // The function called by BaseFab copy operations.
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   // This function is called by the `BaseFab' setVal operations.
00519   //
00520   void performSetVal (T          x,
00521                       const Box& bx,
00522                       int        nstart,
00523                       int        numcomp);
00524 
00525 
00526 private:
00527   //
00528   // These functions are made private to prevent use of the default 
00529   // functions provided by the C++ compiler.
00530   //
00531 
00532   BaseFab<T>& operator= (const BaseFab<T>&);
00533   BaseFab (const BaseFab<T>&);
00534 
00535 protected:
00536 
00537   Box  domain;   // My index space.
00538   int  nvar;     // Number components.
00539   long numpts;   // Cached number of points in FAB.
00540   long truesize; // nvar*numpts that was allocated on heap (only if alias==false).
00541   T*   dptr;     // The data pointer.
00542   bool aliased;  // The BaseFab is not allocated memory, but is an alias. bvs
00543 };
00544 
00545 #include "BaseFabImplem.H"
00546 
00547 #endif /*CH_BASEFAB_H*/
00548 

Generated on Wed Jun 2 13:53:31 2004 for Chombo&INSwithParticles by doxygen 1.3.2