Proto  3.2
Proto_LevelOp.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_LEVEL_OP_
3 #define _PROTO_LEVEL_OP_
4 
5 #include "Proto_LevelBoxData.H"
6 #include "Proto_LevelBC.H"
7 
8 namespace Proto {
9 
10 /// Level-Scope Operator
11 /**
12  LevelOp contains the necessary tools to apply a user-defined descendent of
13  BoxOp on a level.
14 
15  \tparam OpType A BoxOp class
16  \tparam T Datatype of the data holder (e.g. int, double, etc.)
17  \tparam MEM Proto::MemType of the data holder
18 */
19 
20 template <
21  template<typename, MemType> class OpType,
22  typename T,
23  template<typename, unsigned int, MemType, Centering> class BCType = PeriodicBC,
25 class LevelOp
26 {
27  public:
28 
29  typedef OpType<T, MEM> OP;
30  typedef BCType<T, OP::numState(), MEM, PR_CELL> BC;
35 
36  static constexpr unsigned int numState() { return OP::numState(); }
37  static constexpr unsigned int numAux() { return OP::numAux(); }
38 
39  /// Ghost Region Size (State)
40  /**
41  Amount of data needed in ghost regions of state variables to apply the operator
42  */
43  static Point ghost() {return OP::ghost(); }
44 
45  /// Ghost Region Size (Auxiliary)
46  /**
47  Amount of data needed in ghost regions of auxiliary variables to apply the operator
48  */
49  static Point auxGhost()
50  {
51  if (numAux() > 0) { return OP::auxGhost(); }
52  return Point::Zeros();
53  }
54 
55  static int order()
56  {
57  return OP::order();
58  }
59 
60  /// Default Constructor
61  inline LevelOp();
62 
63  /// Non-Trivial Constructor
64  /**
65  \param dx Grid spacing
66  */
67  inline LevelOp(DisjointBoxLayout& a_layout, T a_dx);
68  inline LevelOp(DisjointBoxLayout& a_layout, Array<T, DIM> a_dx);
69 
70  inline LevelOp(LevelOp<OpType, T, BCType, MEM>&& a_op) = default;
73 
74  /// Lazy Constructor
75  /**
76  \param dx Grid spacing
77  */
78  inline void define(DisjointBoxLayout& a_layout, T a_dx);
79  inline void define(DisjointBoxLayout& a_layout, Array<T, DIM> a_dx);
80 
81  /// Spectral Radius
82  inline T spectralRadius() const {return (*m_ops[0]).spectralRadius(); }
83 
84  /// Apply
85  /**
86  Compute L(phi, rho)
87 
88  \param output Evaluated operator (output)
89  \param state State variables
90  \param aux Auxiliary variables
91  */
92  inline void
93  operator()(
94  LevelStateData& a_output,
95  const LevelStateData& a_state,
96  const LevelAuxData& a_aux,
97  T a_scale = 1.0) const;
98 
99  /// Apply
100  /**
101  Compute L(phi)
102 
103  \param output Evaluated operator (output)
104  \param state State variables
105  */
106  inline void
107  operator()(
108  LevelStateData& a_output,
109  const LevelStateData& a_state,
110  T a_scale = 1.0) const;
111 
112  // Apply Boundary Conditions
113  /**
114  This is a stopgap implementation until I can finish the LevelBC implementation
115  */
116  inline void applyBC(LevelStateData& a_state) const;
117 
118  inline void setDiagScale(T a_value);
119  inline void setFluxScale(T a_value);
120  inline void setTime(T a_time);
121  inline void setRKStage(unsigned int a_stage);
122  inline T diagScale() const { return m_diagScale; }
123  inline T fluxScale() const { return m_fluxScale; }
124  inline T time() const {return m_time; }
125  inline unsigned int RKStage() const {return m_rkStage; }
126  inline Array<T, DIM> dx() const { return m_dx; }
127  inline BC& bc() { return m_bc; }
128  inline const DisjointBoxLayout& layout() const {return m_layout; }
129  inline const OP& operator[](const LevelIndex& a_index) const { return *m_ops[a_index]; }
130  inline OP& operator[](const LevelIndex& a_index) { return *m_ops[a_index]; }
131  private:
132 
136  unsigned int m_rkStage;
140  std::vector<std::shared_ptr<OP>> m_ops;
141  BC m_bc;
142 };
143 
144 #include "implem/Proto_LevelOpImplem.H"
145 } // end proto namespace
146 #endif // end include guard
BCType< T, OP::numState(), MEM, PR_CELL > BC
Definition: Proto_LevelOp.H:30
const OP & operator[](const LevelIndex &a_index) const
Definition: Proto_LevelOp.H:129
OpType< T, MEM > OP
Definition: Proto_LevelOp.H:29
std::vector< std::shared_ptr< OP > > m_ops
Definition: Proto_LevelOp.H:140
void setFluxScale(T a_value)
Definition: Proto_LevelOp.H:138
void setDiagScale(T a_value)
Definition: Proto_LevelOp.H:125
Array< T, DIM > dx() const
Definition: Proto_LevelOp.H:126
T time() const
Definition: Proto_LevelOp.H:124
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
static constexpr unsigned int numAux()
Definition: Proto_LevelOp.H:37
Disjoint Box Layout.
Definition: Proto_DisjointBoxLayout.H:30
T diagScale() const
Definition: Proto_LevelOp.H:122
LevelBoxData< T, OP::numAux(), MEM, PR_CELL > LevelAuxData
Definition: Proto_LevelOp.H:34
T spectralRadius() const
Spectral Radius.
Definition: Proto_LevelOp.H:82
MemType
Definition: Proto_MemType.H:7
DisjointBoxLayout m_layout
Definition: Proto_LevelOp.H:139
Level Box Data.
Definition: Proto_HDF5.H:17
static int order()
Definition: Proto_LevelOp.H:55
LevelOp< OpType, T, BCType, MEM > & operator=(LevelOp< OpType, T, BCType, MEM > &&a_op)=default
OP & operator[](const LevelIndex &a_index)
Definition: Proto_LevelOp.H:130
BC & bc()
Definition: Proto_LevelOp.H:127
Periodic Boundary Condition.
Definition: Proto_LevelBCLib.H:13
Level-Scope Operator.
Definition: Proto_LevelOp.H:25
unsigned int RKStage() const
Definition: Proto_LevelOp.H:125
static Point auxGhost()
Ghost Region Size (Auxiliary)
Definition: Proto_LevelOp.H:49
Array< T, DIM > m_dx
Definition: Proto_LevelOp.H:137
T fluxScale() const
Definition: Proto_LevelOp.H:123
T m_diagScale
Definition: Proto_LevelOp.H:133
void operator()(LevelStateData &a_output, const LevelStateData &a_state, T a_scale=1.0) const
Apply.
Definition: Proto_LevelOp.H:89
static ACCEL_DECORATION Point Zeros()
Get Zeros.
Definition: Proto_Array.H:17
void setRKStage(unsigned int a_stage)
Definition: Proto_LevelOp.H:165
LevelBoxData< T, OP::numState(), MEM, PR_CELL > LevelStateData
Definition: Proto_LevelOp.H:33
T m_fluxScale
Definition: Proto_LevelOp.H:134
void define(DisjointBoxLayout &a_layout, T a_dx)
Lazy Constructor.
Definition: Proto_LevelOp.H:31
BoxData< T, OP::numAux(), MEM > AuxData
Definition: Proto_LevelOp.H:32
Integer Valued Vector.
Definition: Proto_Point.H:24
static constexpr unsigned int numState()
Definition: Proto_LevelOp.H:36
T m_time
Definition: Proto_LevelOp.H:135
void applyBC(LevelStateData &a_state) const
Definition: Proto_LevelOp.H:116
LevelOp()
Default Constructor.
Definition: Proto_LevelOp.H:7
const DisjointBoxLayout & layout() const
Definition: Proto_LevelOp.H:128
BC m_bc
Definition: Proto_LevelOp.H:141
void setTime(T a_time)
Definition: Proto_LevelOp.H:151
unsigned int m_rkStage
Definition: Proto_LevelOp.H:136
BoxData< T, OP::numState(), MEM > StateData
Definition: Proto_LevelOp.H:31
#define MEMTYPE_DEFAULT
Definition: Proto_MemType.H:24
static Point ghost()
Ghost Region Size (State)
Definition: Proto_LevelOp.H:43
void operator()(LevelStateData &a_output, const LevelStateData &a_state, const LevelAuxData &a_aux, T a_scale=1.0) const
Apply.
Definition: Proto_LevelOp.H:63