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

LevelData.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 #ifndef LEVELARRAY_H
00029 #define LEVELARRAY_H
00030 
00031 #include "IntVect.H"
00032 #include "BoxLayoutData.H"
00033 #include "DisjointBoxLayout.H"
00034 #include "Copier.H"
00035 #include "SPMD.H"
00036 
00038 
00051 template<class T> class LevelData : public BoxLayoutData<T>
00052 {
00053 public:
00054 
00056   LevelData();
00057 
00059   LevelData(const DisjointBoxLayout& dp, int comps,
00060             const IntVect& ghost = IntVect::TheZeroVector(),
00061             const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00062 
00063   virtual ~LevelData();
00065 
00067   virtual void define(const DisjointBoxLayout& dp, int comps, 
00068                       const IntVect& ghost = IntVect::TheZeroVector(),
00069                       const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00070 
00071 
00073 
00076   virtual void define(const LevelData<T>& da, 
00077                       const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00078 
00080 
00085   virtual void define(const LevelData<T>& da, const Interval& comps,
00086                       const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00087 
00089   virtual void copyTo(const Interval& srcComps, 
00090                       BoxLayoutData<T>& dest,
00091                       const Interval& destComps) const;
00092 
00094   virtual void copyTo(const Interval& srcComps,
00095                       BoxLayoutData<T>& dest,
00096                       const Interval& destComps,
00097                       const Copier& copier) const;
00099 
00101   virtual void copyTo(const Interval& srcComps, 
00102                       LevelData<T>& dest,
00103                       const Interval& destComps) const;
00104 
00106   virtual void copyTo(const Interval& srcComps,
00107                       LevelData<T>& dest,
00108                       const Interval& destComps,
00109                       const Copier& copier) const;
00111   virtual void exchange(const Interval& comps);
00112 
00114   virtual void exchange(const Interval& comps,
00115                         const Copier& copier);
00116 
00118   const IntVect& ghostVect() const { return m_ghost;}
00119 
00120   /*
00121     These functions will invoke error messages when invoked.
00122     C++ will ensure that constructors are not called for the
00123     base class by a user, but a 'define' function has no such protection,
00124     hence the need to prevent such usage.  A runtime error is not
00125     a perfect solution...(strong construction gets around this  *sigh*).
00126     classes that derive from LevelData will have to turn it's valid
00127     defines into runtime errors also and make it's own defines.  Thus
00128     taking over the job of the compiler.
00129     */
00130 
00132   virtual void define(const BoxLayout& dp, int comps,
00133                       const DataFactory<T>& factory);
00134 
00136   virtual void define(const BoxLayoutData<T>& da,
00137                       const DataFactory<T>& factory = DefaultDataFactory<T>());
00138 
00140   virtual void define(const BoxLayoutData<T>& da, const Interval& comps,
00141                       const DataFactory<T>& factory = DefaultDataFactory<T>());
00142 
00143   virtual void define(const BoxLayout& deadFunction);
00144 
00146   const DisjointBoxLayout& getBoxes() const
00147   {
00148     return m_disjointBoxLayout;
00149   }
00150 
00152   const DisjointBoxLayout& disjointBoxLayout() const
00153   {
00154     return m_disjointBoxLayout;
00155   }
00156 
00157 protected:
00158 
00159   void makeItSo(const Interval&     a_srcComps, 
00160                 const LevelData<T>& a_src,
00161                 BoxLayoutData<T>&   a_dest,
00162                 const Interval&     a_destComps,
00163                 const Copier&       a_copier) const;
00164 
00165   DisjointBoxLayout m_disjointBoxLayout;
00166 
00167   IntVect   m_ghost;
00168 
00169   // attempt to speed up the periodic code
00170   //Copier m_exchangeCopier;
00171 
00172   //========================================================================
00173   //
00174   // data structures used by makeItSo when we have some
00175   // data that needs to be moved (ie. there are entries
00176   // in the 'FROM' or 'TO' CopyIterators)
00177   //
00178   void completePendingSends() const;
00179 
00180   void allocateBuffers(const LevelData<T>& a_src, 
00181                        const Interval& a_srcComps,
00182                        const BoxLayoutData<T>& a_dest,
00183                        const Interval& a_destComps,
00184                        const Copier&   a_copier) const;
00185 
00186   void writeSendDataFromMeIntoBuffers(const LevelData<T>& a_src, 
00187                                       const Interval& a_srcComps) const;
00188 
00189   void postSendsFromMe() const ;
00190 
00191   void postReceivesToMe() const ;
00192 
00193   void unpackReceivesToMe(BoxLayoutData<T>& a_dest, 
00194                           const Interval&   a_destComps) const ;
00195 
00196 
00197   mutable void*  m_sendbuffer; // pointer member OK here, 
00198                                // since LevelData<T> has no copy
00199   mutable size_t m_sendcapacity;
00200   mutable void*  m_recbuffer;  // pointer member OK here, 
00201                                // since LevelData<T> has no copy
00202   mutable size_t m_reccapacity;
00203 
00204 #ifdef MPI
00205 
00206   struct bufEntry
00207   {
00208     void* bufPtr; // pointer into contiguous m_buffer
00209     size_t size;
00210     const MotionItem* item;
00211     unsigned int procID;
00212     bool operator < (const bufEntry& rhs) const
00213       { 
00214         if(procID == rhs.procID) 
00215           {
00216             const Box& left = item->toRegion;
00217             const Box& right= rhs.item->toRegion;
00218             if(left.smallEnd() == right.smallEnd())
00219               {
00220                 return left.bigEnd().lexLT(right.bigEnd());
00221               }
00222             else
00223               {
00224                 return item->toRegion < rhs.item->toRegion;
00225               }
00226           }
00227         //else
00228         return procID < rhs.procID;
00229       }
00230   };
00231 
00232 
00233   mutable std::vector<bufEntry> m_fromMe;
00234   mutable std::vector<bufEntry> m_toMe;
00235 
00236   mutable MPI_Request  *m_sendRequests, *m_receiveRequests;
00237   mutable MPI_Status   *m_sendStatus,   *m_receiveStatus;
00238   mutable int numSends, numReceives;
00239 
00240 #endif
00241 
00242 };
00243 
00244 
00245 // ====== inlined function definitions ================
00246 
00247 // As with the BoxLayoutData implementation file.  This file
00248 // just gives the interface and the inline implmentations
00249 // are given in LevelDataI.H
00250 
00251 #include "LevelDataI.H"
00252 
00253 
00254 
00255 #endif

Generated on Thu Aug 29 11:05:45 2002 for Chombo&INS by doxygen1.2.16