Proto  3.2
Proto_LevelFluxRegister.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_FLUX_REGISTER_
3 #define _PROTO_FLUX_REGISTER_
4 
5 #include "Proto_Register.H"
6 #include "Proto_BoxData.H"
7 #include "Proto_Copier.H"
8 
9 namespace Proto
10 {
11  // Forward Declarations
12  template<typename T, unsigned int C, MemType MEM>
14  template<typename T, unsigned int C, MemType MEM>
16 
17  // =======================================================================
18  // FLUX REGISTER COPIER OP
19 
20  /// Flux Register Copier Op
21  /**
22  */
23  template<typename T, unsigned int C=1, MemType MEM = MEMTYPE_DEFAULT>
25  {
26  friend class FluxRegisterCopier<T,C,MEM>;
27  private:
29 
30  public:
33 
34  /// Get Serialized Size
35  inline int linearSize(const Box& a_bx,
36  const DataIndex<BoxPartition>& a_index) const;
37 
38  /// Serial Write To Buffer
39  inline void linearOut(void* a_buf, const LevelMotionItem& a_info) const;
40  //inline void linearOut(void* a_buf,
41  // const Box& a_bx,
42  // const DataIndex<BoxPartition>& a_index) const;
43 
44  /// Serial Read From Buffer
45  inline void linearIn(void* a_buf, const LevelMotionItem& a_info) const;
46  //inline void linearIn(void* a_buf,
47  // const Box& a_bx,
48  // const DataIndex<BoxPartition>& a_index) const;
49 
50  /// Local Copy
51  inline void localCopy(const LevelMotionItem& a_info) const;
52  //inline void localCopy(
53  // const Box& a_domain, const DataIndex<BoxPartition>& a_domainIndex,
54  // const Box& a_range, const DataIndex<BoxPartition>& a_rangeIndex) const;
55 
56  }; // end class FluxRegisterCopierOp
57 
58  // =======================================================================
59  // FLUX REGISTER COPIER
60 
61  /// Flux Register Copier
62  /**
63  */
64  template<typename T, unsigned int C=1, MemType MEM=MEMTYPE_DEFAULT>
65  class FluxRegisterCopier
66  : public Copier<FluxRegisterCopierOp<T, C, MEM>, BoxPartition, BoxPartition, MEM, MEM>
67  {
68  public:
69 
70  inline FluxRegisterCopier(){};
71 
72  /// Build Copier Motion Plan
73  inline void buildMotionPlans(FluxRegisterCopierOp<T, C, MEM>& a_op);
74  }; //end class FluxRegisterCopier
75 
76  // =======================================================================
77  // FLUX REGISTER
78 
79  /// Flux Register
80  /**
81  */
82  template<typename T, unsigned int C, MemType MEM>
83  class LevelFluxRegister
84  {
85  friend class FluxRegisterCopierOp<T,C,MEM>;
86  friend class FluxRegisterCopier<T,C,MEM>;
87 
88  public:
89  /// Default constructor
91  /// Constructor
92  LevelFluxRegister(const DisjointBoxLayout& a_dblCoarse,
93  const DisjointBoxLayout& a_dblFine,
94  const Point& a_refRatio,
95  Array<T, DIM> a_dxCoarse);
96 
97  /// Define function
98  void define(const DisjointBoxLayout& a_dblCoarse,
99  const DisjointBoxLayout& a_dblFine,
100  const Point& a_refRatio,
101  Array<T, DIM> a_dxCoarse);
102 
103  /// Increment Coarse
104  /**
105  Increments all the registers contained in the coarse patch a_di, direction a_dir.
106  Assumes that a_flux is defined on all the a_dir faces in the patch.
107  */
108  void incrementCoarse(
109  const BoxData<T,C,MEM>& a_flux,
110  const DataIndex<BoxPartition>& a_di,
111  const T& a_weight,
112  unsigned int a_dir);
113 
114  /// Increment Fine
115  /**
116  Increments all the registers contained in the fine patch a_di, direction a_dir.
117  Assumes that a_flux is defined on all the a_dir faces in the patch.
118  */
119  void incrementFine(const BoxData<T,C,MEM>& a_flux,
120  const DataIndex<BoxPartition>& a_di,
121  const T& a_weight,
122  unsigned int a_dir);
123 
124  /// Reflux
125  /**
126  Performs the reflux correction on input coarse data.
127  */
128  void reflux(LevelBoxData<T,C,MEM>& a_coarseData, const T& a_weight);
129 
130  /// Reset
131  void reset(T a_val = 0);
132 
133  /// compute the hash key for a coarse register.
134  int key(const Box& a_bx,const DataIndex<BoxPartition>& a_di);
135 
136  void print() const;
137 
138  /// Access to layouts.
139  DisjointBoxLayout crseLayout() const {return m_crseLayout;};
140  DisjointBoxLayout fineLayout() const {return m_fineLayout;};
141  protected:
142 
143  BoxData<T,C,MEM>& sourceData(const Box& a_bx,const DataIndex<BoxPartition>& di);
144  BoxData<T,C,MEM>& destData(const Box& a_bx,const DataIndex<BoxPartition>& di);
145 
151 
152  // Registers for coarse data
153  std::vector<std::vector<Register<T,C,MEM> > > m_crseRegisters;
154  // Registers for fine data on coarse layout
155  std::vector<std::vector<shared_ptr<BoxData<T,C,MEM> > > > m_crseIncrement;
156  // Registers for fine data
157  std::vector<std::vector<Register<T,C,MEM> > > m_fineRegisters;
158  // crseIndices is a map because there are in general multiple registers for each (dir, side)
159  std::vector<unordered_map<unsigned int,unsigned int> >m_crseIndices;
160  // fineIndices are not a map because there is at most one register for each (dir, side)
161  std::vector<Array<Array<int,2>, DIM> > m_fineIndices;
163  }; //end class LevelFluxRegister
164 #include "implem/Proto_LevelFluxRegisterImplem.H"
165 } // end namespace Proto
166 #endif // end include guard
Flux Register.
Definition: Proto_LevelFluxRegister.H:13
std::vector< std::vector< shared_ptr< BoxData< T, C, MEM > > > > m_crseIncrement
Definition: Proto_LevelFluxRegister.H:155
LevelFluxRegister< T, C, MEM > * m_register
Definition: Proto_LevelFluxRegister.H:28
FluxRegisterCopier()
Definition: Proto_LevelFluxRegister.H:70
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
Flux Register Copier.
Definition: Proto_LevelFluxRegister.H:15
Disjoint Box Layout.
Definition: Proto_DisjointBoxLayout.H:30
std::vector< Array< Array< int, 2 >, DIM > > m_fineIndices
Definition: Proto_LevelFluxRegister.H:161
void localCopy(const LevelMotionItem &a_info) const
Local Copy.
Definition: Proto_LevelFluxRegister.H:40
DisjointBoxLayout m_fineLayout
Definition: Proto_LevelFluxRegister.H:147
Point m_refRatio
Definition: Proto_LevelFluxRegister.H:150
Level Box Data.
Definition: Proto_HDF5.H:17
void linearIn(void *a_buf, const LevelMotionItem &a_info) const
Serial Read From Buffer.
Definition: Proto_LevelFluxRegister.H:28
std::vector< std::vector< Register< T, C, MEM > > > m_crseRegisters
Definition: Proto_LevelFluxRegister.H:153
DisjointBoxLayout m_crseLayout
Definition: Proto_LevelFluxRegister.H:146
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
FluxRegisterCopierOp()
Definition: Proto_LevelFluxRegister.H:31
void linearOut(void *a_buf, const LevelMotionItem &a_info) const
Serial Write To Buffer.
Definition: Proto_LevelFluxRegister.H:16
Definition: Proto_Array.H:17
int linearSize(const Box &a_bx, const DataIndex< BoxPartition > &a_index) const
Get Serialized Size.
Definition: Proto_LevelFluxRegister.H:9
Flux Register Copier Op.
Definition: Proto_LevelFluxRegister.H:24
std::vector< std::vector< Register< T, C, MEM > > > m_fineRegisters
Definition: Proto_LevelFluxRegister.H:157
Integer Valued Vector.
Definition: Proto_Point.H:24
DisjointBoxLayout crseLayout() const
Access to layouts.
Definition: Proto_LevelFluxRegister.H:139
std::vector< unordered_map< unsigned int, unsigned int > > m_crseIndices
Definition: Proto_LevelFluxRegister.H:159
DisjointBoxLayout fineLayout() const
Definition: Proto_LevelFluxRegister.H:140
FluxRegisterCopier< T, C, MEM > m_copier
Definition: Proto_LevelFluxRegister.H:149
Array< T, DIM > m_dxCrse
Definition: Proto_LevelFluxRegister.H:148
LevelFluxRegister()
Default constructor.
Definition: Proto_LevelFluxRegister.H:90
Abstract Generic Parallel Copier.
Definition: Proto_Copier.H:60
Definition: Proto_Copier.H:22
Array< Array< Stencil< T >, 2 >, DIM > m_avgFlux
Definition: Proto_LevelFluxRegister.H:162