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 #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
00122
00123
00124
00125
00126
00127
00128
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
00170
00171
00172
00173
00174
00175
00176
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;
00198
00199 mutable size_t m_sendcapacity;
00200 mutable void* m_recbuffer;
00201
00202 mutable size_t m_reccapacity;
00203
00204 #ifdef MPI
00205
00206 struct bufEntry
00207 {
00208 void* bufPtr;
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
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
00246
00247
00248
00249
00250
00251 #include "LevelDataI.H"
00252
00253
00254
00255 #endif