00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _LEVELDATA_H_
00012 #define _LEVELDATA_H_
00013
00014 #include "IntVect.H"
00015 #include "BoxLayoutData.H"
00016 #include "DisjointBoxLayout.H"
00017 #include "Copier.H"
00018 #include "SPMD.H"
00019 #include "NamespaceHeader.H"
00020
00022
00035 template <class T>
00036 void aliasLevelData(LevelData<T>& a_alias,
00037 LevelData<T>* a_original,
00038 const Interval& a_interval);
00039
00040 template<class T> class LevelData : public BoxLayoutData<T>
00041 {
00042 public:
00043
00045 LevelData();
00046
00048 LevelData(const DisjointBoxLayout& dp, int comps,
00049 const IntVect& ghost = IntVect::Zero,
00050 const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00051
00053 virtual ~LevelData();
00054
00056 virtual void define(const DisjointBoxLayout& dp, int comps,
00057 const IntVect& ghost = IntVect::Zero,
00058 const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00059
00061
00064 virtual void define(const LevelData<T>& da,
00065 const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00066
00068
00073 virtual void define(const LevelData<T>& da, const Interval& comps,
00074 const DataFactory<T>& a_factory = DefaultDataFactory<T>());
00075
00077 virtual void copyTo(const Interval& srcComps,
00078 BoxLayoutData<T>& dest,
00079 const Interval& destComps) const;
00080
00082 virtual void copyTo(BoxLayoutData<T>& dest) const;
00083
00085 virtual void copyTo(const Interval& srcComps,
00086 BoxLayoutData<T>& dest,
00087 const Interval& destComps,
00088 const Copier& copier) const;
00089
00091 virtual void copyTo(BoxLayoutData<T>& dest,
00092 const Copier& copier) const;
00094
00096 virtual void copyTo(const Interval& srcComps,
00097 LevelData<T>& dest,
00098 const Interval& destComps) const;
00099
00101 virtual void copyTo(LevelData<T>& dest) const;
00102
00104
00107 virtual void copyTo(const Interval& srcComps,
00108 LevelData<T>& dest,
00109 const Interval& destComps,
00110 const Copier& copier,
00111 const LDOperator<T>& a_op = LDOperator<T>()) const;
00112
00114 virtual void copyTo(LevelData<T>& dest,
00115 const Copier& copier,
00116 const LDOperator<T>& a_op = LDOperator<T>()) const;
00117
00119 virtual void exchange(const Interval& comps);
00120
00122 virtual void exchange(void);
00123
00125 virtual void exchange(const Interval& comps,
00126 const Copier& copier);
00127
00129 virtual void exchange(const Copier& copier);
00130
00132 virtual void exchangeBegin(const Copier& copier);
00134 virtual void exchangeEnd();
00135
00136 virtual void exchangeNoOverlap(const Copier& copier);
00137
00139 const IntVect& ghostVect() const { return m_ghost;}
00140
00154 virtual void define(const BoxLayout& dp, int comps,
00155 const DataFactory<T>& factory);
00156
00158 virtual void define(const BoxLayoutData<T>& da,
00159 const DataFactory<T>& factory = DefaultDataFactory<T>());
00160
00162 virtual void define(const BoxLayoutData<T>& da, const Interval& comps,
00163 const DataFactory<T>& factory = DefaultDataFactory<T>());
00164
00165 virtual void define(const BoxLayout& deadFunction);
00168
00169 const DisjointBoxLayout& getBoxes() const
00170 {
00171 return m_disjointBoxLayout;
00172 }
00173
00175 const DisjointBoxLayout& disjointBoxLayout() const
00176 {
00177 return m_disjointBoxLayout;
00178 }
00179
00181
00206 virtual void apply( void (*a_Function)(const Box&, int, T&) );
00207
00208
00210 struct ApplyFunctor
00211 {
00212 virtual ~ApplyFunctor() {}
00213 virtual void operator()( const Box&, int, T& ) const = 0;
00214 };
00215
00243 virtual void apply( const ApplyFunctor& );
00244
00245 void degenerate( LevelData<T>& a_to, const SliceSpec& a_ss ) const;
00246
00247 protected:
00248 DisjointBoxLayout m_disjointBoxLayout;
00249
00250 IntVect m_ghost;
00251
00252 friend void aliasLevelData<T>(LevelData<T>& a_alias,
00253 LevelData<T>* a_original,
00254 const Interval& a_interval);
00255
00256 Copier m_exchangeCopier;
00257 };
00258
00260
00287 template <class T>
00288 void aliasLevelData(LevelData<T>& a_alias, LevelData<T>* a_original,
00289 const Interval& a_interval)
00290 {
00291 AliasDataFactory<T> factory(a_original, a_interval);
00292 a_alias.define(a_original->disjointBoxLayout(), a_interval.size(), a_original->ghostVect(), factory);
00293 }
00294
00295
00296
00297
00298
00299
00300
00301 #include "NamespaceFooter.H"
00302 #include "LevelDataI.H"
00303
00304 #endif