 |
Shiokaze Framework
A research-oriented fluid solver for computer graphics
|
|
Go to the documentation of this file.
25 #ifndef SHKZ_ARRAY_DERIVATIVE2_H
26 #define SHKZ_ARRAY_DERIVATIVE2_H
53 double x = std::max(0.0,std::min(shape.
w-1.,p[0]));
54 double y = std::max(0.0,std::min(shape.
h-1.,p[1]));
55 int i = std::min(x,shape.
w-2.);
56 int j = std::min(y,shape.
h-2.);
58 indices[0] =
vec2i(i,j);
59 indices[1] =
vec2i(i+1,j);
60 indices[2] =
vec2i(i,j+1);
61 indices[3] =
vec2i(i+1,j+1);
63 coef[0][0] = -(j+1-y);
68 coef[1][0] = -(i+1-x);
86 T values[4];
vec2i indices[4];
double coef[DIM2][4];
87 for(
unsigned dim : DIMS2 ) result[dim] = T();
89 for(
unsigned dim : DIMS2 ) {
90 for(
unsigned n=0; n<4; ++n ) {
91 result[dim] += coef[dim][n] * array(indices[n][0],indices[n][1]);
111 derivative<T>(array,(p-origin)/dx,result.
v);
static void derivative_interpolate_coef(const shape2 &shape, const vec2d &p, vec2i indices[4], double coef[DIM2][4])
Get the coefficients for the gradient.
Definition: array_derivative2.h:51
static void derivative(const array2< T > &array, const vec2d &p, T result[DIM2])
Computes the the gradient of a physical quantity.
Definition: array_derivative2.h:84
Class that computes the derivative of physical quantities at arbitrary position.
Definition: array_derivative2.h:37
T v[D]
Vector value array.
Definition: vec.h:44
shape2 shape() const
Get the shape of the array.
Definition: array2.h:218
unsigned h
Height of the shape.
Definition: shape.h:466
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
unsigned w
Width of the shape.
Definition: shape.h:461
static vec2< T > derivative(const array2< T > &array, const vec2d &origin, double dx, const vec2d &p)
Computes the the gradient of a physical quantity.
Definition: array_derivative2.h:109
Fixed sized vector structure.
Definition: vec.h:38
Two dimensional array class designed to be defined as instance member in recursive_configurable class...
Definition: array2.h:42
Structure that defines shape such as width, height.
Definition: shape.h:42
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44