Proto  3.2
Proto_MBMapOp.H
Go to the documentation of this file.
1 #pragma once
2 #ifndef _PROTO_MB_MAP_OP_
3 #define _PROTO_MB_MAP_OP_
4 
6 #include "Proto_MBLevelBoxData.H"
7 #include "Proto_Operator.H"
8 
9 namespace Proto
10 {
11 
12 template<MemType MEM>
13 class MBMapOp
14 {
15  public:
16 
17  /// Trivial Constructor
18  inline MBMapOp(){}
19 
20  /// Constructor
21  inline MBMapOp(
22  Array<double, DIM> a_dx,
23  unsigned int a_block,
24  unsigned int a_focalBlock = 0);
25 
26  /// Lazy Constructor
27  inline void define(
28  Array<double, DIM> a_dx,
29  unsigned int a_block,
30  unsigned int a_focalBlock = 0);
31 
32  /// User Defined Initialization
33  /** Users should override this function with any code they would like to run
34  * when the map is constructed.
35  */
36  inline virtual void init() {}
37 
38  /// Compute Map
39  /** Users should override this function when defining their map if they do not want
40  * to explicitly define the metric tensor (NT). The domains of the coordinate and
41  * Jacobian quantities are assumed to be defined before they are input to this function.
42  * Note that the ghost values used to define the map during construction have absolutely
43  * no bearing on the valid domains for this function, so long as the relevant analytic
44  * functions are defined.
45  *
46  * \param a_X: Coordinates at nodes [input/output]
47  * \param a_J: Cell averaged jacobian [input/output]
48  */
49  inline virtual void apply(
52 
53  /// Compute Map (With Metrics)
54  /** Users should override this function when defining their map if they want
55  * to explicitly define the metric tensor (NT). The domains of the coordinate and
56  * Jacobian quantities are assumed to be defined before they are input to this function.
57  * Note that the ghost values used to define the map during construction have absolutely
58  * no bearing on the valid domains for this function, so long as the relevant analytic
59  * functions are defined.
60  *
61  * \param a_X: Coordinates at nodes [input/output]
62  * \param a_J: Cell averaged jacobian [input/output]
63  * \param a_NT: Face averaged metric terms in each coordinate direction [output]
64  */
65  inline virtual void apply(
69 
70 
71  /// Analytic Map
72  /** Users should override this function
73  */
74  inline virtual Array<double, DIM> apply(const Array<double, DIM>& a_xi)
75  {
76  PROTO_ASSERT(false,
77  "MBMapOp::apply (analytic) | Error: function not implemented in subclass");
78  }
79 
80  inline virtual void inverse(
82  const BoxData<double, DIM, MEM>& a_XCart)
83  {
84  PROTO_ASSERT(false,
85  "MBMapOp::inverse | Error: function not implemented in subclass");
86  }
87  /// Analytic Inverse Map
88  /** Users should override this function if the inverse map is needed
89  */
90  inline virtual Array<double, DIM> inverse(const Array<double, DIM>& a_x) {
91  PROTO_ASSERT(false,
92  "MBMapOp::inverse (analytic) | Error: function not implemented in subclass");
93  }
94 
95  // Used internally to fix inheritance of virtual functions
96  inline void _apply(
99  {
100  apply(a_X, a_J);
101  }
102 
103  // Used internally to fix inheritance of virtual functions
104  inline void _apply(
108  {
109  apply(a_X, a_J, a_NT);
110  }
111 
112  /// Get Mapped Grid Spacing
113  inline const Array<double, DIM>& dx() const;
114 
115  /// Get Block
116  inline unsigned int block() const;
117 
118  /// Get Mapped Coordinate Values
119  /** Given a node-centered box and grid spacing, generate the node centered mapped
120  * coordinates. This assumes that the origin corresponds to the point (0,0,...,0) and
121  * that the input box already accounts for node centering (e.g. Box::grow(PR_NODE) is
122  * assumed to already have been called.)
123  *
124  * /param a_box A box that already accounts for node centering
125  * /param a_dx Grid spacing
126  */
127  inline BoxData<double, DIM, MEM> X(const Box& a_box, const Array<double, DIM>& a_dx) const;
128 
129  ///
130  inline void setFocalBlock(unsigned int a_block) { m_focalBlock = a_block; this->init(); }
131 
132  ///
133  inline unsigned int focalBlock() const { return m_focalBlock; }
134  private:
135 
136 
137 
138  Array<double, DIM> m_dx; ///< Grid spacing in mapped space
139  Stencil<double> m_c2c; ///< Cached corners-to-cells Stencil
140  unsigned int m_block; ///< Block in which this map is applied
141  unsigned int m_focalBlock; ///< Block on which this map is focused (often unused)
142 };
143 #include "implem/Proto_MBMapOpImplem.H"
144 } //end Proto namespace
145 #endif //end include guard
MBMapOp()
Trivial Constructor.
Definition: Proto_MBMapOp.H:18
void define(Array< double, DIM > a_dx, unsigned int a_block, unsigned int a_focalBlock=0)
Lazy Constructor.
Definition: Proto_MBMapOp.H:13
BoxData< double, DIM, MEM > X(const Box &a_box, const Array< double, DIM > &a_dx) const
Get Mapped Coordinate Values.
Definition: Proto_MBMapOp.H:56
virtual void init()
User Defined Initialization.
Definition: Proto_MBMapOp.H:36
Multidimensional Rectangular Array.
Definition: Proto_BoxData.H:314
void setFocalBlock(unsigned int a_block)
Definition: Proto_MBMapOp.H:130
const Array< double, DIM > & dx() const
Get Mapped Grid Spacing.
Definition: Proto_MBMapOp.H:50
Array< double, DIM > m_dx
Grid spacing in mapped space.
Definition: Proto_MBMapOp.H:138
virtual Array< double, DIM > inverse(const Array< double, DIM > &a_x)
Analytic Inverse Map.
Definition: Proto_MBMapOp.H:90
An interval in DIM dimensional space.
Definition: Proto_Box.H:29
Definition: Proto_MBMapOp.H:13
virtual void apply(BoxData< double, DIM, MEM > &a_X, BoxData< double, 1, MEM > &a_J)
Compute Map.
Definition: Proto_MBMapOp.H:29
Stencil< double > m_c2c
Cached corners-to-cells Stencil.
Definition: Proto_MBMapOp.H:139
void _apply(BoxData< double, DIM, MEM > &a_X, BoxData< double, 1, MEM > &a_J, FluxBoxData< double, DIM, MEM > &a_NT)
Definition: Proto_MBMapOp.H:104
unsigned int m_block
Block in which this map is applied.
Definition: Proto_MBMapOp.H:140
unsigned int focalBlock() const
Definition: Proto_MBMapOp.H:133
virtual void inverse(BoxData< double, DIM, MEM > &a_XMap, const BoxData< double, DIM, MEM > &a_XCart)
Definition: Proto_MBMapOp.H:80
void _apply(BoxData< double, DIM, MEM > &a_X, BoxData< double, 1, MEM > &a_J)
Definition: Proto_MBMapOp.H:96
#define PROTO_ASSERT(stmt, args...)
Definition: Proto_PAssert.H:48
Definition: Proto_Array.H:17
unsigned int block() const
Get Block.
Definition: Proto_MBMapOp.H:53
unsigned int m_focalBlock
Block on which this map is focused (often unused)
Definition: Proto_MBMapOp.H:141
virtual Array< double, DIM > apply(const Array< double, DIM > &a_xi)
Analytic Map.
Definition: Proto_MBMapOp.H:74
Definition: Proto_BoxData.H:1436