Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
c929113c
Commit
c929113c
authored
8 years ago
by
James Willis
Browse files
Options
Downloads
Patches
Plain Diff
Added function to caclculate the kernel with one set of vectors.
parent
1b0030c6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!320
Dopair1 vectorisation merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_hydro.h
+76
-0
76 additions, 0 deletions
src/kernel_hydro.h
with
76 additions
and
0 deletions
src/kernel_hydro.h
+
76
−
0
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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment