Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
c929113c
Commit
c929113c
authored
Dec 13, 2016
by
James Willis
Browse files
Added function to caclculate the kernel with one set of vectors.
parent
1b0030c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/kernel_hydro.h
View file @
c929113c
...
...
@@ -372,6 +372,82 @@ static const vector wendland_const_c4 = FILL_VEC(0.f);
static
const
vector
wendland_const_c5
=
FILL_VEC
(
1
.
f
);
#endif
/**
* @brief Computes the kernel function and its derivative for two particles
* using interleaved vectors.
*
* Return 0 if $u > \\gamma = H/h$
*
* @param u The ratio of the distance to the smoothing length $u = x/h$.
* @param w (return) The value of the kernel function $W(x,h)$.
* @param dw_dx (return) The norm of the gradient of $|\\nabla W(x,h)|$.
* @param u2 The ratio of the distance to the smoothing length $u = x/h$ for
* second particle.
* @param w2 (return) The value of the kernel function $W(x,h)$ for second
* particle.
* @param dw_dx2 (return) The norm of the gradient of $|\\nabla W(x,h)|$ for
* second particle.
*/
__attribute__
((
always_inline
))
INLINE
static
void
kernel_deval_1_vec
(
vector
*
u
,
vector
*
w
,
vector
*
dw_dx
)
{
/* Go to the range [0,1[ from [0,H[ */
vector
x
;
x
.
v
=
vec_mul
(
u
->
v
,
kernel_gamma_inv_vec
.
v
);
#ifdef WENDLAND_C2_KERNEL
/* Init the iteration for Horner's scheme. */
w
->
v
=
vec_fma
(
wendland_const_c0
.
v
,
x
.
v
,
wendland_const_c1
.
v
);
dw_dx
->
v
=
wendland_const_c0
.
v
;
/* Calculate the polynomial interleaving vector operations */
dw_dx
->
v
=
vec_fma
(
dw_dx
->
v
,
x
.
v
,
w
->
v
);
w
->
v
=
vec_fma
(
x
.
v
,
w
->
v
,
wendland_const_c2
.
v
);
dw_dx
->
v
=
vec_fma
(
dw_dx
->
v
,
x
.
v
,
w
->
v
);
w
->
v
=
vec_fma
(
x
.
v
,
w
->
v
,
wendland_const_c3
.
v
);
dw_dx
->
v
=
vec_fma
(
dw_dx
->
v
,
x
.
v
,
w
->
v
);
w
->
v
=
vec_fma
(
x
.
v
,
w
->
v
,
wendland_const_c4
.
v
);
dw_dx
->
v
=
vec_fma
(
dw_dx
->
v
,
x
.
v
,
w
->
v
);
w
->
v
=
vec_fma
(
x
.
v
,
w
->
v
,
wendland_const_c5
.
v
);
/* Return everything */
w
->
v
=
vec_mul
(
w
->
v
,
vec_mul
(
kernel_constant_vec
.
v
,
kernel_gamma_inv_dim_vec
.
v
));
dw_dx
->
v
=
vec_mul
(
dw_dx
->
v
,
vec_mul
(
kernel_constant_vec
.
v
,
kernel_gamma_inv_dim_plus_one_vec
.
v
));
#else
/* Load x and get the interval id. */
vector
ind
;
ind
.
m
=
vec_ftoi
(
vec_fmin
(
x
.
v
*
kernel_ivals_vec
.
v
,
kernel_ivals_vec
.
v
));
/* load the coefficients. */
vector
c
[
kernel_degree
+
1
];
for
(
int
k
=
0
;
k
<
VEC_SIZE
;
k
++
)
for
(
int
j
=
0
;
j
<
kernel_degree
+
1
;
j
++
)
{
c
[
j
].
f
[
k
]
=
kernel_coeffs
[
ind
.
i
[
k
]
*
(
kernel_degree
+
1
)
+
j
];
}
/* Init the iteration for Horner's scheme. */
w
->
v
=
(
c
[
0
].
v
*
x
.
v
)
+
c
[
1
].
v
;
dw_dx
->
v
=
c
[
0
].
v
;
/* And we're off! */
for
(
int
k
=
2
;
k
<=
kernel_degree
;
k
++
)
{
dw_dx
->
v
=
(
dw_dx
->
v
*
x
.
v
)
+
w
->
v
;
w
->
v
=
(
x
.
v
*
w
->
v
)
+
c
[
k
].
v
;
}
/* Return everything */
w
->
v
=
w
->
v
*
kernel_constant_vec
.
v
*
kernel_gamma_inv_dim_vec
.
v
;
dw_dx
->
v
=
dw_dx
->
v
*
kernel_constant_vec
.
v
*
kernel_gamma_inv_dim_plus_one_vec
.
v
;
#endif
}
/**
* @brief Computes the kernel function and its derivative for two particles
* using interleaved vectors.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment