Proto  3.2
Proto_MBBoxOp.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_MB_BOX_OP_
3 #define _PROTO_MB_BOX_OP_
4 
5 #include "Proto_BoxOp.H"
6 #include "Proto_MBLevelMap.H"
7 namespace Proto {
8 
9 /// Abstract Box-Scope Operator for Mapped Multiblock
10 /**
11  MBBoxOp is the class from which all mapped multiblock operators are
12  derived. It is a special case of BoxOp with additional built in
13  capabilities for providing mapped coordinate context.
14 
15  //FIXME: update this for mapped
16  L(phi, rho) = d*D(phi, rho)*I + f*[Div(F(phi, rho)) + S(phi, rho)]
17  L: Full Operator
18  phi: State Variables
19  rho: Auxiliary Variables
20  D: Diagonal Component of L
21  F: Flux Component of L
22  S: Source Component of L
23  I: Identity
24  d: Diagonal Term Scaling
25  f: Flux and Source Term Scaling
26 
27  TODO: potentially template the op on the data-holder itself (e.g. BoxData) for
28  additional flexibility.
29 
30  \tparam T Datatype of the data holder (e.g. int, double, etc.)
31  \tparam MAP Datatype of the MBMapOp (this is the same as the MBLevelMap's MAP parameter)
32  \tparam C_STATE Number of state variables
33  \tparam C_AUX Number of auxiliary (non-state) variables
34  \tparam MEM Proto::MemType of the data holder
35 */
36 template <typename T, typename MAP,
37  unsigned int C_STATE, unsigned int C_AUX, MemType MEM = MEMTYPE_DEFAULT>
38 class MBBoxOp : public BoxOp<T, C_STATE, C_AUX, MEM>
39 {
40  public:
43 
44  //TODO: In addition to the following, the interface requires these
45  // static functions. There is no good way to specify necessary static
46  // functions in an interface which is extremely awkward...
47  //
48  // static Point ghost() const; (Needed ghost data in the state variables)
49  // static Point auxGhost() const; (Needed ghost data in the aux variables)
50 
51  /// Non-Trivial Constructor
52  inline MBBoxOp(const MBLevelMap<MAP, MEM>& a_map, const MBIndex& a_index);
53  inline MBBoxOp(MBBoxOp<T,MAP,C_STATE,C_AUX,MEM>&& a_bop) = default;
56 
57  /// Initialize
58  /**
59  User defined function that is called inside of define.
60  Useful for caching things like Stencil instances.
61  */
62  inline virtual void init() {}
63 
64  /// Spectral Radius (User Defined)
65  /**
66  Approximate spectral radius of the operator. Not required, but
67  Needed for iterative solvers.
68  */
69  inline virtual T spectralRadius() const { return 1; }
70 
71 #if 0 //CURRENTLY UNUSED
72 
73  /// Apply (In Place)
74  /**
75  Compute L(phi, rho)
76 
77  \param output Evaluated operator (output)
78  \param state State variables
79  \param aux Auxiliary variables
80  */
81  inline virtual void
82  operator()(
83  StateData& a_output,
84  const StateData& a_state,
85  const AuxData& a_aux,
86  T a_scale = 1.0) const ;
87 #endif
88  /// Apply (In Place)
89  /**
90  Compute L(phi)
91 
92  \param output Evaluated operator (output)
93  \param state State variables
94  */
95  inline void
96  operator()(
97  StateData& a_output,
98  const StateData& a_state,
99  T a_scale = 1.0) const ;
100 #if 0 // CURRENTLY UNUSED
101 
102  /// Apply (In Place, Flux Output)
103  /**
104  Compute L(phi, rho)
105 
106  \param output Evaluated operator (output)
107  \param state State variables
108  \param aux Auxiliary variables
109  */
110  inline virtual void
111  operator()(
112  StateData& a_output,
113  Array<StateData, DIM>& a_fluxes,
114  const StateData& a_state,
115  const AuxData& a_aux,
116  T a_scale = 1.0) const ;
117 #endif
118  /// Apply (In Place, Flux Output)
119  /**
120  Compute L(phi)
121 
122  \param output Evaluated operator (output)
123  \param state State variables
124  */
125  inline void
126  operator()(
127  StateData& a_output,
128  Array<StateData, DIM>& a_fluxes,
129  const StateData& a_state,
130  T a_scale = 1.0) const ;
131 
132  inline virtual void
134  StateData& a_output,
135  Array<StateData, DIM>& a_fluxes,
136  const StateData& a_state) const {}
137 
138 #if 0 //CURRENTLY UNUSED
139 
140  /// Apply (Out of Place)
141  /**
142  Compute L(phi, rho).
143 
144  \param state State variables
145  \param aux Auxiliary variables
146  \param range Range of the output data
147  */
148  inline virtual StateData
149  operator()(
150  const StateData& a_state,
151  const AuxData& a_aux,
152  Box a_range,
153  T a_scale = 1.0) const ;
154 #endif
155 
156  /// Apply (Out of Place)
157  /**
158  Compute L(phi)
159 
160  \param state State variables
161  \param range Range of the output data
162  */
163  inline StateData
164  operator()(
165  const StateData& a_state,
166  Box a_range,
167  T a_scale = 1.0) const ;
168 
169  /// Apply All Boundary Conditions
170  /**
171  * Executes logic for determining which Face of a patch is on a domain boundary.
172  * Calls the user defined boundary condition function as needed
173  */
174  inline void
176  Array<StateData, DIM>& a_fluxes,
177  const StateData& a_state) const;
178 
179 
180  inline void
181  divergence(
182  StateData& a_divergence,
183  const Array<StateData, DIM>& a_fluxes) const;
184 
185  /// Apply Boundary Condition (User Specified)
186  /**
187  * Use this function to specify problem domain boundary conditions.
188  * The default behavior is a null-op, leaving the flux argument unchanged.
189  */
190  inline virtual void
192  Array<StateData, DIM>& a_fluxes,
193  const StateData& a_state,
194  Face a_face) const {}
195 #if 0
196  /// User Defined Flux
197  /**
198  Compute F(phi, rho) in the direction dir
199 
200  \param flux Computed flux (output)
201  \param state State variables
202  \param aux Auxiliary variables
203  \param dir Direction in [0, DIM)
204  */
205 
206  inline virtual void flux(
207  StateData& a_flux,
208  const StateData& a_state,
209  const AuxData& a_aux,
210  int a_dir) const ;
211 
212  /// User Defined Flux
213  /**
214  Compute F(phi) in the direction dir
215 
216  \param flux Computed flux (output)
217  \param state State variables
218  \param dir Direction in [0, DIM)
219  */
220  inline virtual void flux(
221  StateData& a_flux,
222  const StateData& a_state,
223  int a_dir) const ;
224 
225  /// User Defined Source
226  /**
227  Compute S(phi, rho)
228 
229  \param source Computed flux (output)
230  \param state State variables
231  \param aux Auxiliary variables
232  */
233  inline virtual void source(
234  StateData& a_source,
235  const StateData& a_state,
236  const AuxData& a_aux) const ;
237 
238  /// User Defined Source
239  /**
240  Compute S(phi)
241 
242  \param source Computed flux (output)
243  \param state State variables
244  */
245  inline virtual void source(
246  StateData& a_source,
247  const StateData& a_state) const ;
248 
249  /// User Defined Diagonal
250  /**
251  Compute D(phi, rho)
252 
253  \param diag Computed flux (output)
254  \param state State variables
255  \param aux Auxiliary variables
256  */
257  inline virtual void diag(
258  StateData& a_diag,
259  const StateData& a_state,
260  const AuxData& a_aux) const ;
261 
262  /// User Defined Diagonal
263  /**
264  Compute D(phi)
265 
266  \param diag Computed flux (output)
267  \param state State variables
268  */
269  inline virtual void diag(
270  StateData& a_diag,
271  const StateData& a_state) const ;
272 #endif
273  /// Get Map
274  inline const MBLevelMap<MAP,MEM>& map() const;
275 
276  /// Get Index
277  inline MBIndex index() const;
278 
279  /// Get Layout
280  inline const MBDisjointBoxLayout& layout() const;
281 
282  /// Get Block
283  inline unsigned int block() const;
284 
285  /// Get Box
286  inline Box box() const;
287 
288  /// Get Grid Spacing (Mapped Coordinates)
289  inline Array<T, DIM> dx() const;
291  /// Get Differential Area (Mapped Coordinates)
292  inline Array<T, DIM> da() const;
293 
294  /// Get Coordinates
295  /** Output is immutable and node centered */
296  inline const BoxData<double, DIM, MEM>& x() const;
297 
298  /// Get Coordinates
299  /** Output is immutable and cell averaged */
300  inline const BoxData<double, 1, MEM>& jacobian() const;
301 
302 #if 0
303  /// Enforce Block Boundary Flux Matching condition
304  inline virtual void matchFlux(
305  StateData& a_rhs,
306  const StateData& a_locFlux,
307  const StateData& a_adjFlux,
308  const StateData& a_state,
309  Point a_localDir) const;
310 
311  /// Match Block Boundary Fluxes using the average of fluxes
312  inline void matchFluxAverage(
313  StateData& a_rhs,
314  const StateData& a_locFlux,
315  const StateData& a_adjFlux,
316  Point a_localDir) const;
317 #endif
318  protected:
319 
320  private:
321 
325 };
326 
327 #include "implem/Proto_MBBoxOpImplem.H"
328 } // end namespace Proto
329 
330 #endif // end include guard
void boundaryConditions(Array< StateData, DIM > &a_fluxes, const StateData &a_state) const
Apply All Boundary Conditions.
Definition: Proto_MBBoxOp.H:136
Definition: Proto_Face.H:122
Abstract Box-Scope Operator for Mapped Multiblock.
Definition: Proto_MBBoxOp.H:38
Abstract Box-Scope Operator.
Definition: Proto_BoxOp.H:33
MBIndex index() const
Get Index.
Definition: Proto_MBBoxOp.H:266
virtual void flux(StateData &a_flux, const StateData &a_state, const AuxData &a_aux, int a_dir) const
User Defined Flux.
Definition: Proto_BoxOp.H:269
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
const MBLevelMap< MAP, MEM > & map() const
Get Map.
Definition: Proto_MBBoxOp.H:258
Array< T, DIM > da() const
Get Differential Area (Mapped Coordinates)
Definition: Proto_MBBoxOp.H:298
const BoxData< double, 1, MEM > & jacobian() const
Get Coordinates.
Definition: Proto_MBBoxOp.H:324
BoxData< T, C_STATE, MEM > StateData
Definition: Proto_MBBoxOp.H:41
Single Level Mapped Multiblock Map.
Definition: Proto_MBLevelBoxData.H:19
unsigned int block() const
Get Block.
Definition: Proto_MBBoxOp.H:274
MemType
Definition: Proto_MemType.H:7
const BoxData< double, DIM, MEM > & x() const
Get Coordinates.
Definition: Proto_MBBoxOp.H:316
virtual void apply(StateData &a_output, Array< StateData, DIM > &a_fluxes, const StateData &a_state) const
Definition: Proto_MBBoxOp.H:133
Array< T, DIM > dx() const
Get Grid Spacing (Mapped Coordinates)
Definition: Proto_MBBoxOp.H:290
MBBoxOp< T, MAP, C_STATE, C_AUX, MEM > & operator=(MBBoxOp< T, MAP, C_STATE, C_AUX, MEM > &&a_bop)=default
Box box() const
Get Box.
Definition: Proto_MBBoxOp.H:282
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
const MBLevelMap< MAP, MEM > & m_map
Definition: Proto_MBBoxOp.H:323
void divergence(StateData &a_divergence, const Array< StateData, DIM > &a_fluxes) const
Definition: Proto_MBBoxOp.H:161
virtual void init()
Initialize.
Definition: Proto_MBBoxOp.H:62
BoxData< T, C_AUX, MEM > AuxData
Definition: Proto_MBBoxOp.H:42
MBIndex m_mbIndex
Definition: Proto_MBBoxOp.H:322
const MBDisjointBoxLayout & layout() const
Get Layout.
Definition: Proto_MBBoxOp.H:250
virtual void applyBC(Array< StateData, DIM > &a_fluxes, const StateData &a_state, Face a_face) const
Apply Boundary Condition (User Specified)
Definition: Proto_MBBoxOp.H:191
Definition: Proto_Array.H:17
A templated constant size array object similar to std::array, but with the ability to be used inside ...
Definition: Proto_Array.H:28
virtual void diag(StateData &a_diag, const StateData &a_state, const AuxData &a_aux) const
User Defined Diagonal.
Definition: Proto_BoxOp.H:329
Integer Valued Vector.
Definition: Proto_Point.H:24
Definition: Proto_MBDisjointBoxLayout.H:14
void operator()(StateData &a_output, const StateData &a_state, T a_scale=1.0) const
Apply (In Place)
Definition: Proto_MBBoxOp.H:47
#define MEMTYPE_DEFAULT
Definition: Proto_MemType.H:24
virtual void source(StateData &a_source, const StateData &a_state, const AuxData &a_aux) const
User Defined Source.
Definition: Proto_BoxOp.H:300
virtual T spectralRadius() const
Spectral Radius (User Defined)
Definition: Proto_MBBoxOp.H:69
MBBoxOp(const MBLevelMap< MAP, MEM > &a_map, const MBIndex &a_index)
Non-Trivial Constructor.
Definition: Proto_MBBoxOp.H:5