Proto  3.2
Proto_MBLevelFluxRegister.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_MB_FLUX_REGISTER_
3 #define _PROTO_MB_FLUX_REGISTER_
4 
5 #include "Proto.H"
6 
7 namespace Proto
8 {
9  template<typename T, unsigned int C, MemType MEM>
11  template<typename T, unsigned int C, MemType MEM>
13  template<typename T, unsigned int C, MemType MEM>
15 
16  template <typename T, unsigned int C, MemType MEM=MEMTYPE_DEFAULT>
18  {
19  public:
21  inline const std::vector<Register<T, C, MEM>>& getCoarseRegistersAtIndex(MBIndex a_coarseIndex) const;
22  inline const std::vector<Register<T, C, MEM>>& getFineRegistersAtIndex(MBIndex a_fineIndex) const;
23 
24  private:
26  };
27 
28  template<typename T, unsigned int C=1, MemType MEM=MEMTYPE_DEFAULT>
30  {
31  friend class MBFluxRegisterCopier<T,C,MEM>;
32  private:
34 
35  public:
38 
39  /// Get Serialized Size
40  inline int linearSize(const Box& a_bx,
41  const MBIndex& a_index) const;
42 
43  /// Serial Write To Buffer
44  inline void linearOut(void* a_buf, const MBMotionItem& a_info) const;
45 
46  /// Serial Read From Buffer
47  inline void linearIn(void* a_buf, const MBMotionItem& a_info) const;
48 
49  /// Local Copy
50  inline void localCopy(const MBMotionItem& a_info) const;
51 
52  }; // end class MBFluxRegisterCopierOp
53 
54  template<typename T, unsigned int C=1, MemType MEM=MEMTYPE_DEFAULT>
56  : public Copier<MBFluxRegisterCopierOp<T, C, MEM>, MBBoxPartition, MBBoxPartition, MEM, MEM>
57  {
58  public:
59 
61 
62  /// Build Copier Motion Plan
63  inline void buildMotionPlans(MBFluxRegisterCopierOp<T, C, MEM>& a_op);
64 
65  private:
66 
67  inline void addCoarseMotionItems(MBLevelFluxRegister<T,C,MEM>& a_fluxRegister);
68  inline void addFineMotionItems(MBLevelFluxRegister<T,C,MEM>& a_fluxRegister);
69  inline MBIndex getCoarseIndex(
70  MBLevelFluxRegister<T,C,MEM>& a_fluxRegister,
71  MBIndex a_fineIndex,
72  Point a_dir);
73  }; //end class MBFluxRegisterCopier
74 
75  template<typename T, unsigned int C, MemType MEM=MEMTYPE_DEFAULT>
77  {
78  friend class MBLevelFluxRegisterTester<T,C,MEM>;
79  friend class MBFluxRegisterCopierOp<T,C,MEM>;
80  friend class MBFluxRegisterCopier<T,C,MEM>;
81 
82  public:
84  MBLevelFluxRegister(const MBDisjointBoxLayout& a_dblCoarse,
85  const MBDisjointBoxLayout& a_dblFine,
86  const Point& a_refRatio);
87  MBLevelFluxRegister(const MBDisjointBoxLayout& a_dblCoarse,
88  const MBDisjointBoxLayout& a_dblFine,
89  const Point& a_refRatio,
90  Array<T, DIM>& a_dxCoarse);
91 
92  MBLevelFluxRegister(const MBDisjointBoxLayout& a_dblCoarse,
93  const MBDisjointBoxLayout& a_dblFine,
94  const std::vector<Point>& a_refRatios,
95  std::vector<Array<T, DIM>>& a_dxCoarse);
96 
97  void define(const MBDisjointBoxLayout& a_dblCoarse,
98  const MBDisjointBoxLayout& a_dblFine,
99  const Point& a_refRatios,
100  Array<T, DIM>& a_dxCoarse);
101 
102  void define(const MBDisjointBoxLayout& a_dblCoarse,
103  const MBDisjointBoxLayout& a_dblFine,
104  const std::vector<Point>& a_refRatios,
105  std::vector<Array<T, DIM>>& a_dxCoarse);
106 
107  void clearInternalData();
108  void initCoarseRegisters(T a_val = 0);
109  void initFineRegisters(T a_val = 0);
110  void initIncrement(T a_val = 0);
111 
112  /** Increments all coarse registers associated with an index, in a given coordinate direction */
113  void incrementCoarseRegister(
114  const BoxData<T,C,MEM>& a_flux,
115  const MBIndex& a_index,
116  int a_dir,
117  const T& a_weight = 1.0);
118 
119  /** Increments all fine registers associated with an index, in a given coordinate direction */
120  void incrementFineRegister(const BoxData<T,C,MEM>& a_flux,
121  const MBIndex& a_index,
122  int a_dir,
123  const T& a_weight = 1.0);
124 
125  /// Reflux
126  /**
127  Performs the reflux correction on input coarse data.
128  */
129  void applyRefluxCorrection(MBLevelBoxData<T,C,MEM>& a_coarseData, const T& a_weight);
130 
131  void print() const;
132 
133  /// Access to layouts.
134  MBDisjointBoxLayout crseLayout() const {return m_crseLayout;};
135  MBDisjointBoxLayout fineLayout() const {return m_fineLayout;};
136 
137  protected:
138  void validateInputs(const MBDisjointBoxLayout &a_dblCoarse,
139  const MBDisjointBoxLayout &a_dblFine,
140  const std::vector<Point> &a_refRatios,
141  std::vector<Array<T, DIM>> &a_dxCoarse) const;
142  void defineCoarse();
143  void addCoarseRegisters(PatchID a_finePatch, MBIndex a_coarseIndex);
144  void addFineRegisters(MBIndex a_fineIndex);
145  void initFineRegisterIndices();
146  bool adjacentInProblemDomain(MBIndex a_fineIndex, Point a_dir) const;
147  void addCoarseRegisterFromAdjacent(PatchID a_finePatch, MBIndex a_coarseIndex, Point a_dir, MBIndex a_fineIndexAdj);
148  void addFineRegisterFromAdjacent(MBIndex a_fineIndex, Point a_dir);
149  int computeTileIndex(const Box& a_bx,const MBIndex& a_di);
150  void defineFine();
151  void defineAverageStencils();
152 
153 
154  BoxData<T, C, MEM> &findFineRegisterData(const Box &a_bx, const MBIndex &di);
155  BoxData<T, C, MEM> &findCoarseRegisterData(const Box &a_bx, const MBIndex &di);
156 
159  std::vector<Array<T, DIM>> m_dxCrse;
161  std::vector<Point> m_refRatios;
162 
163  // Registers for coarse data
164  std::vector<std::vector<Register<T, C, MEM>>> m_crseRegisters;
165  // Registers for fine data on coarse layout
166  std::vector<std::vector<shared_ptr<BoxData<T, C, MEM>>>> m_crseIncrement;
167  // Registers for fine data
168  std::vector<std::vector<Register<T, C, MEM>>> m_fineRegisters;
169  // crseIndices is a map because there are in general multiple registers for each (dir, side)
170  std::vector<unordered_map<unsigned int, unsigned int>> m_crseIndices;
171  // fineIndices are not a map because there is at most one register for each (dir, side)
172  std::vector<Array<Array<int, 2>, DIM>> m_fineIndices;
173  std::vector<Array<Array<Stencil<T>, 2>, DIM>> m_avgFlux;
174  }; //end class MBLevelFluxRegister
175 #include "implem/Proto_MBLevelFluxRegisterImplem.H"
176 } // end namespace Proto
177 #endif // end include guard
Definition: Proto_MBLevelFluxRegister.H:12
Definition: Proto_MBLevelFluxRegister.H:14
MBLevelFluxRegisterTester(const MBLevelFluxRegister< T, C, MEM > &a_register)
Definition: Proto_MBLevelFluxRegister.H:20
MBDisjointBoxLayout m_fineLayout
Definition: Proto_MBLevelFluxRegister.H:158
Definition: Proto_MBLevelFluxRegister.H:29
int linearSize(const T &inputT)
Definition: Proto_PointLIO.H:55
const std::vector< Register< T, C, MEM > > & getCoarseRegistersAtIndex(MBIndex a_coarseIndex) const
Definition: Proto_MBLevelFluxRegister.H:4
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
std::vector< Array< Array< int, 2 >, DIM > > m_fineIndices
Definition: Proto_MBLevelFluxRegister.H:172
void linearOut(void *const a_outBuf, const T &inputT)
Definition: Proto_PointLIO.H:67
MBDisjointBoxLayout m_crseLayout
Definition: Proto_MBLevelFluxRegister.H:157
MBLevelFluxRegister()
Definition: Proto_MBLevelFluxRegister.H:83
std::vector< std::vector< Register< T, C, MEM > > > m_crseRegisters
Definition: Proto_MBLevelFluxRegister.H:164
MBDisjointBoxLayout fineLayout() const
Definition: Proto_MBLevelFluxRegister.H:135
Multiblock Level Box Data.
Definition: Proto_MBLevelBoxData.H:17
std::vector< Array< Array< Stencil< T >, 2 >, DIM > > m_avgFlux
Definition: Proto_MBLevelFluxRegister.H:173
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
void linearIn(void *a_buf, const MBMotionItem &a_info) const
Serial Read From Buffer.
Definition: Proto_MBLevelFluxRegister.H:42
MBFluxRegisterCopier< T, C, MEM > m_copier
Definition: Proto_MBLevelFluxRegister.H:160
const std::vector< Register< T, C, MEM > > & getFineRegistersAtIndex(MBIndex a_fineIndex) const
Definition: Proto_MBLevelFluxRegister.H:11
MBFluxRegisterCopier()
Definition: Proto_MBLevelFluxRegister.H:60
const MBLevelFluxRegister< T, C, MEM > & m_register
Definition: Proto_MBLevelFluxRegister.H:25
Definition: Proto_MBLevelFluxRegister.H:10
std::vector< std::vector< Register< T, C, MEM > > > m_fineRegisters
Definition: Proto_MBLevelFluxRegister.H:168
std::vector< unordered_map< unsigned int, unsigned int > > m_crseIndices
Definition: Proto_MBLevelFluxRegister.H:170
MBLevelFluxRegister< T, C, MEM > * m_register
Definition: Proto_MBLevelFluxRegister.H:33
std::vector< Array< T, DIM > > m_dxCrse
Definition: Proto_MBLevelFluxRegister.H:159
std::vector< std::vector< shared_ptr< BoxData< T, C, MEM > > > > m_crseIncrement
Definition: Proto_MBLevelFluxRegister.H:166
Definition: Proto_Array.H:17
Integer Valued Vector.
Definition: Proto_Point.H:24
Definition: Proto_MBDisjointBoxLayout.H:14
MBDisjointBoxLayout crseLayout() const
Access to layouts.
Definition: Proto_MBLevelFluxRegister.H:134
std::vector< Point > m_refRatios
Definition: Proto_MBLevelFluxRegister.H:161
MBFluxRegisterCopierOp()
Definition: Proto_MBLevelFluxRegister.H:36
Abstract Generic Parallel Copier.
Definition: Proto_Copier.H:60
Definition: Proto_Copier.H:22