SpatialOps
FVStaggeredOperatorTypes.h
1 /*
2  * Copyright (c) 2014-2017 The University of Utah
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  */
22 
23 #ifndef SpatialOps_structured_FVStaggeredOpTypes_h
24 #define SpatialOps_structured_FVStaggeredOpTypes_h
25 
26 #include <spatialops/SpatialOpsConfigure.h>
29 #include <spatialops/Nebo.h>
30 
31 namespace SpatialOps{
32 
65  template<typename OpT, typename SrcT, typename DestT>
67 
68  // no-op. Note that you should avoid this since it adds some overhead to Nebo.
69  template< typename FieldT >
70  struct OperatorTypeBuilder<Interpolant,FieldT,FieldT>{
72  FieldT,
73  FieldT>
74  type;
75  };
76 
114  template< typename CellT > struct BasicOpTypes;
115 
116 
117 
118  //-----------------------------------------------------------------------
119  //---- Below are macros to instantiate the supported operator types. ----
120  //---- Generally, you should not use these macros from user code. ----
121  //-----------------------------------------------------------------------
122 
123 #define OP_BUILDER( STYLE, OP, SRC, DEST ) \
124  template<> \
125  struct OperatorTypeBuilder<OP,SRC,DEST>{ \
126  typedef NeboStencilBuilder<OP, \
127  STYLE<OP,SRC,DEST>::StPtCollection, \
128  SRC, \
129  DEST> \
130  type; \
131  };
132 
133 #define BASIC_OPTYPE_BUILDER( VOL ) \
134  OP_BUILDER( Stencil2Collection, Interpolant, VOL, FaceTypes<VOL>::XFace ) \
135  OP_BUILDER( Stencil2Collection, Interpolant, VOL, FaceTypes<VOL>::YFace ) \
136  OP_BUILDER( Stencil2Collection, Interpolant, VOL, FaceTypes<VOL>::ZFace ) \
137  OP_BUILDER( Stencil2Collection, Interpolant, FaceTypes<VOL>::XFace, VOL ) \
138  OP_BUILDER( Stencil2Collection, Interpolant, FaceTypes<VOL>::YFace, VOL ) \
139  OP_BUILDER( Stencil2Collection, Interpolant, FaceTypes<VOL>::ZFace, VOL ) \
140  OP_BUILDER( Stencil2Collection, Gradient, VOL, FaceTypes<VOL>::XFace ) \
141  OP_BUILDER( Stencil2Collection, Gradient, VOL, FaceTypes<VOL>::YFace ) \
142  OP_BUILDER( Stencil2Collection, Gradient, VOL, FaceTypes<VOL>::ZFace ) \
143  OP_BUILDER( Stencil2Collection, Divergence, FaceTypes<VOL>::XFace, VOL ) \
144  OP_BUILDER( Stencil2Collection, Divergence, FaceTypes<VOL>::YFace, VOL ) \
145  OP_BUILDER( Stencil2Collection, Divergence, FaceTypes<VOL>::ZFace, VOL ) \
146  template<> \
147  struct BasicOpTypes<VOL> \
148  { \
149  typedef OperatorTypeBuilder< Interpolant, VOL, FaceTypes<VOL>::XFace >::type InterpC2FX; \
150  typedef OperatorTypeBuilder< Interpolant, VOL, FaceTypes<VOL>::YFace >::type InterpC2FY; \
151  typedef OperatorTypeBuilder< Interpolant, VOL, FaceTypes<VOL>::ZFace >::type InterpC2FZ; \
152  typedef OperatorTypeBuilder< Interpolant, FaceTypes<VOL>::XFace, VOL >::type InterpF2CX; \
153  typedef OperatorTypeBuilder< Interpolant, FaceTypes<VOL>::YFace, VOL >::type InterpF2CY; \
154  typedef OperatorTypeBuilder< Interpolant, FaceTypes<VOL>::ZFace, VOL >::type InterpF2CZ; \
155  typedef OperatorTypeBuilder< Gradient, VOL, FaceTypes<VOL>::XFace >::type GradX; \
156  typedef OperatorTypeBuilder< Gradient, VOL, FaceTypes<VOL>::YFace >::type GradY; \
157  typedef OperatorTypeBuilder< Gradient, VOL, FaceTypes<VOL>::ZFace >::type GradZ; \
158  typedef OperatorTypeBuilder< Divergence, FaceTypes<VOL>::XFace, VOL >::type DivX; \
159  typedef OperatorTypeBuilder< Divergence, FaceTypes<VOL>::YFace, VOL >::type DivY; \
160  typedef OperatorTypeBuilder< Divergence, FaceTypes<VOL>::ZFace, VOL >::type DivZ; \
161  };
162 
163 
164  BASIC_OPTYPE_BUILDER( SVolField )
165  BASIC_OPTYPE_BUILDER( XVolField )
166  BASIC_OPTYPE_BUILDER( YVolField )
167  BASIC_OPTYPE_BUILDER( ZVolField )
168 
169 
171  OP_BUILDER( Stencil2Collection, Gradient, XVolField, YSurfXField )
172  OP_BUILDER( Stencil2Collection, Interpolant, XVolField, ZSurfXField )
173  OP_BUILDER( Stencil2Collection, Gradient, XVolField, ZSurfXField )
174 
175  OP_BUILDER( Stencil2Collection, Interpolant, YVolField, XSurfYField )
176  OP_BUILDER( Stencil2Collection, Gradient, YVolField, XSurfYField )
177  OP_BUILDER( Stencil2Collection, Interpolant, YVolField, ZSurfYField )
178  OP_BUILDER( Stencil2Collection, Gradient, YVolField, ZSurfYField )
179 
180  OP_BUILDER( Stencil2Collection, Interpolant, ZVolField, XSurfZField )
181  OP_BUILDER( Stencil2Collection, Gradient, ZVolField, XSurfZField )
182  OP_BUILDER( Stencil2Collection, Interpolant, ZVolField, YSurfZField )
183  OP_BUILDER( Stencil2Collection, Gradient, ZVolField, YSurfZField )
184 
185  OP_BUILDER( Stencil2Collection, Interpolant, SVolField, XVolField )
186  OP_BUILDER( Stencil2Collection, Gradient, SVolField, XVolField )
187 
188  OP_BUILDER( Stencil2Collection, Interpolant, SVolField, YVolField )
189  OP_BUILDER( Stencil2Collection, Gradient, SVolField, YVolField )
190 
191  OP_BUILDER( Stencil2Collection, Interpolant, SVolField, ZVolField )
192  OP_BUILDER( Stencil2Collection, Gradient, SVolField, ZVolField )
193 
194  OP_BUILDER( Stencil2Collection, Interpolant, XVolField, SVolField )
195  OP_BUILDER( Stencil2Collection, Gradient, XVolField, SVolField )
196 
197  OP_BUILDER( Stencil2Collection, Interpolant, YVolField, SVolField )
198  OP_BUILDER( Stencil2Collection, Gradient, YVolField, SVolField )
199 
200  OP_BUILDER( Stencil2Collection, Interpolant, ZVolField, SVolField )
201  OP_BUILDER( Stencil2Collection, Gradient, ZVolField, SVolField )
202 
203  // the following six operators are needed for calculating the strain tensor on a collocated grid
204  OP_BUILDER( Stencil2Collection, Gradient, XSurfYField, SSurfYField )
205  OP_BUILDER( Stencil2Collection, Gradient, XSurfZField, SSurfZField )
206 
207  OP_BUILDER( Stencil2Collection, Gradient, YSurfXField, SSurfXField )
208  OP_BUILDER( Stencil2Collection, Gradient, YSurfZField, SSurfZField )
209 
210  OP_BUILDER( Stencil2Collection, Gradient, ZSurfXField, SSurfXField )
211  OP_BUILDER( Stencil2Collection, Gradient, ZSurfYField, SSurfYField )
212 #define NULL_OP_BUILDER( OP, SRC, DEST ) \
213  template<> \
214  struct OperatorTypeBuilder<OP,SRC,DEST>{ \
215  typedef NeboSumStencilBuilder<NullStencilCollection::StPtCollection, \
216  SRC, \
217  DEST> \
218  type; \
219  };
220 
221  NULL_OP_BUILDER( Interpolant, XVolField, SSurfXField )
222  NULL_OP_BUILDER( Interpolant, YVolField, SSurfYField )
223  NULL_OP_BUILDER( Interpolant, ZVolField, SSurfZField )
224 
225  NULL_OP_BUILDER( Interpolant, SSurfXField, XVolField )
226  NULL_OP_BUILDER( Interpolant, SSurfYField, YVolField )
227  NULL_OP_BUILDER( Interpolant, SSurfZField, ZVolField )
228 
229  NULL_OP_BUILDER( Interpolant, SVolField, XSurfXField )
230  NULL_OP_BUILDER( Interpolant, SVolField, YSurfYField )
231  NULL_OP_BUILDER( Interpolant, SVolField, ZSurfZField )
232 
233  NULL_OP_BUILDER( Interpolant, XSurfXField, SVolField )
234  NULL_OP_BUILDER( Interpolant, YSurfYField, SVolField )
235  NULL_OP_BUILDER( Interpolant, ZSurfZField, SVolField )
236 
237  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, XSurfYField )
238  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, XSurfZField )
239 
240  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, YSurfXField )
241  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, YSurfZField )
242 
243  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, ZSurfXField )
244  OP_BUILDER( Stencil4Collection, Interpolant, SVolField, ZSurfYField )
245 
246  OP_BUILDER( Stencil4Collection, Interpolant, XSurfYField, SVolField )
247  OP_BUILDER( Stencil4Collection, Interpolant, XSurfZField, SVolField )
248  OP_BUILDER( Stencil4Collection, Interpolant, YSurfXField, SVolField )
249  OP_BUILDER( Stencil4Collection, Interpolant, YSurfZField, SVolField )
250  OP_BUILDER( Stencil4Collection, Interpolant, ZSurfXField, SVolField )
251  OP_BUILDER( Stencil4Collection, Interpolant, ZSurfYField, SVolField )
252 
253  OP_BUILDER( Stencil4Collection, Interpolant, XVolField, YVolField )
254  OP_BUILDER( Stencil4Collection, Interpolant, XVolField, ZVolField )
255  OP_BUILDER( Stencil4Collection, Interpolant, YVolField, XVolField )
256  OP_BUILDER( Stencil4Collection, Interpolant, YVolField, ZVolField )
257  OP_BUILDER( Stencil4Collection, Interpolant, ZVolField, XVolField )
258  OP_BUILDER( Stencil4Collection, Interpolant, ZVolField, YVolField )
259 
260  // Filter operators
261 #define AVE_OP_BUILDER( FIELDT ) \
262  template<> struct OperatorTypeBuilder<Filter,FIELDT,FIELDT>{ \
263  typedef NeboAverageStencilBuilder<BoxFilter3DStencilCollection::StPtCollection, \
264  FIELDT, \
265  FIELDT> \
266  type; \
267  };
268 
269  AVE_OP_BUILDER( SVolField )
270  AVE_OP_BUILDER( XVolField )
271  AVE_OP_BUILDER( YVolField )
272  AVE_OP_BUILDER( ZVolField )
273 
274  AVE_OP_BUILDER( XSurfXField )
275  AVE_OP_BUILDER( XSurfYField )
276  AVE_OP_BUILDER( XSurfZField )
277 
278  AVE_OP_BUILDER( YSurfXField )
279  AVE_OP_BUILDER( YSurfYField )
280  AVE_OP_BUILDER( YSurfZField )
281 
282  AVE_OP_BUILDER( ZSurfXField )
283  AVE_OP_BUILDER( ZSurfYField )
284  AVE_OP_BUILDER( ZSurfZField )
285 
286  // finite difference:
287 #define FD_OP_BUILDER( OP, FIELDT ) \
288  template<> struct OperatorTypeBuilder<OP,FIELDT,FIELDT>{ \
289  typedef NeboStencilBuilder<OP, \
290  FDStencilCollection<OP,FIELDT,FIELDT>::StPtCollection, \
291  FIELDT, \
292  FIELDT> \
293  type; \
294  };
295 
296 #define FD_ALL_VOL_FIELDS( OP ) \
297  FD_OP_BUILDER(OP,SVolField) \
298  FD_OP_BUILDER(OP,XVolField) \
299  FD_OP_BUILDER(OP,YVolField) \
300  FD_OP_BUILDER(OP,ZVolField) \
301  FD_OP_BUILDER(OP,VertexField)
302 
303  FD_ALL_VOL_FIELDS( InterpolantX )
304  FD_ALL_VOL_FIELDS( InterpolantY )
305  FD_ALL_VOL_FIELDS( InterpolantZ )
306  FD_ALL_VOL_FIELDS( GradientX )
307  FD_ALL_VOL_FIELDS( GradientY )
308  FD_ALL_VOL_FIELDS( GradientZ )
309 
310 } // namespace SpatialOps
311 
312 #endif // SpatialOps_structured_FVStaggeredOpTypes_h
Y-interpolant for use with FD operations whose src and dest fields are the same type.
Z-interpolant for use with FD operations whose src and dest fields are the same type.
Supports definition of new Nebo sum stencils, which sums given stencil points WITHOUT coefficients...
Y-interpolant for use with FD operations whose src and dest fields are the same type.
X-interpolant for use with FD operations whose src and dest fields are the same type.
Provides typedefs for common operator types on a given volume.
X-interpolant for use with FD operations whose src and dest fields are the same type.
Defines a type for Gradient operators.
Builds operator types from field types and operator type descriptors.
Abstracts a field.
Definition: SpatialField.h:132
Defines a type for Interpolant operators.
Z-interpolant for use with FD operations whose src and dest fields are the same type.