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
34c64550
Commit
34c64550
authored
5 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Make the code crash if the wrong softening kernel is used in the high-order derivatives
parent
0cfa5387
No related branches found
No related tags found
1 merge request
!1077
Improved multipole acceptance criterion (MAC)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gravity_properties.c
+7
-0
7 additions, 0 deletions
src/gravity_properties.c
src/kernel_gravity.h
+26
-2
26 additions, 2 deletions
src/kernel_gravity.h
with
33 additions
and
2 deletions
src/gravity_properties.c
+
7
−
0
View file @
34c64550
...
...
@@ -114,6 +114,13 @@ void gravity_props_init(struct gravity_props *p, struct swift_params *params,
p
->
use_tree_below_softening
=
parser_get_opt_param_int
(
params
,
"Gravity:use_tree_below_softening"
,
1
);
#ifdef GADGET2_SOFTENING_CORRECTION
if
(
p
->
use_tree_below_softening
)
error
(
"Cannot solve gravity via the tree below softening with the "
"Gadget2-type softening kernel"
);
#endif
/* Mesh dithering */
if
(
periodic
&&
!
with_external_potential
)
{
p
->
with_dithering
=
...
...
This diff is collapsed.
Click to expand it.
src/kernel_gravity.h
+
26
−
2
View file @
34c64550
...
...
@@ -162,8 +162,6 @@ __attribute__((always_inline)) INLINE static void kernel_grav_eval_force_double(
}
#endif
/* SWIFT_GRAVITY_FORCE_CHECKS */
#undef GADGET2_SOFTENING_CORRECTION
/************************************************/
/* Derivatives of softening kernel used for FMM */
/************************************************/
...
...
@@ -171,6 +169,10 @@ __attribute__((always_inline)) INLINE static void kernel_grav_eval_force_double(
__attribute__
((
const
))
INLINE
static
float
D_soft_1
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
/* phi(u) = 3u^7 - 15u^6 + 28u^5 - 21u^4 + 7u^2 - 3 */
float
phi
=
3
.
f
*
u
-
15
.
f
;
phi
=
phi
*
u
+
28
.
f
;
...
...
@@ -186,6 +188,10 @@ __attribute__((const)) INLINE static float D_soft_1(const float u,
__attribute__
((
const
))
INLINE
static
float
D_soft_3
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
/* phi'(u)/u = 21u^5 - 90u^4 + 140u^3 - 84u^2 + 14 */
float
phi
=
21
.
f
*
u
-
90
.
f
;
phi
=
phi
*
u
+
140
.
f
;
...
...
@@ -199,6 +205,10 @@ __attribute__((const)) INLINE static float D_soft_3(const float u,
__attribute__
((
const
))
INLINE
static
float
D_soft_5
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
/* (phi'(u)/u)'/u = 105u^3 - 360u^2 + 420u - 168 */
float
phi
=
105
.
f
*
u
-
360
.
f
;
phi
=
phi
*
u
+
420
.
f
;
...
...
@@ -209,11 +219,20 @@ __attribute__((const)) INLINE static float D_soft_5(const float u,
__attribute__
((
const
))
INLINE
static
float
D_soft_7
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
return
315
.
f
*
u
-
720
.
f
+
420
.
f
*
u_inv
;
}
__attribute__
((
const
))
INLINE
static
float
D_soft_9
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
/* -315 u^-1 + 420 u^-3 */
/* -315 u_inv + 420 u_inv^3 */
float
phi
=
420
.
f
*
u_inv
;
...
...
@@ -224,6 +243,11 @@ __attribute__((const)) INLINE static float D_soft_9(const float u,
__attribute__
((
const
))
INLINE
static
float
D_soft_11
(
const
float
u
,
const
float
u_inv
)
{
#ifdef GADGET2_SOFTENING_CORRECTION
error
(
"Invalid choice of softening kernel shape"
);
#endif
/* 315 u^-3 - 1260 u^-5 */
/* 315 u_inv^3 - 1260 u_inv^5 */
float
phi
=
-
1260
.
f
*
u_inv
;
...
...
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