Shiokaze Framework
A research-oriented fluid solver for computer graphics
macarray_interpolator3.h
Go to the documentation of this file.
1 /*
2 ** macarray_interpolator3.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on Feb 25, 2018.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 //
25 #ifndef SHKZ_MACARRAY_INTERPOLATOR3_H
26 #define SHKZ_MACARRAY_INTERPOLATOR3_H
27 //
28 #include <shiokaze/math/vec.h>
29 #include "array_interpolator3.h"
30 //
32 //
34 namespace macarray_interpolator3 {
49  template<class T> static vec3<T> interpolate( const macarray3<T> &array, const vec3d &p, bool only_actives=false ) {
50  vec3<T> result;
51  for( int dim : DIMS3 ) {
52  const vec3d pos = vec3d(p[0]-0.5*(dim!=0),p[1]-0.5*(dim!=1),p[2]-0.5*(dim!=2));
53  result[dim] = array_interpolator3::interpolate<T>(array[dim],pos,only_actives);
54  }
55  return result;
56  }
73  template<class T> static vec3<T> interpolate( const macarray3<T> &array, const vec3d &origin, double dx, const vec3d &p, bool only_actives=false ) {
74  return interpolate<T>(array,(p-origin)/dx,only_actives);
75  }
76 };
77 //
79 //
80 #endif
81 //
array_interpolator3.h
macarray_interpolator3
Namespace that implements MAC array interpolation.
Definition: macarray_interpolator3.h:36
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
vec
Fixed sized vector structure.
Definition: vec.h:38
vec.h
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
macarray3
Three dimensional staggered grid class designed to be defined as instance member in recursive_configu...
Definition: macarray3.h:37