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
ad54b220
Commit
ad54b220
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Use SWIFT's long-range forces correction instead of Gadget's
parent
73996edd
No related branches found
No related tags found
2 merge requests
!566
Periodic gravity calculation
,
!565
Mesh force task
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_long_gravity.h
+16
-6
16 additions, 6 deletions
src/kernel_long_gravity.h
with
16 additions
and
6 deletions
src/kernel_long_gravity.h
+
16
−
6
View file @
ad54b220
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
/* Standard headers */
/* Standard headers */
#include
<math.h>
#include
<math.h>
#define GADGET2_LONG_RANGE_CORRECTION
//
#define GADGET2_LONG_RANGE_CORRECTION
/**
/**
* @brief Computes the long-range correction term for the potential calculation
* @brief Computes the long-range correction term for the potential calculation
...
@@ -51,7 +51,7 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_pot_eval(
...
@@ -51,7 +51,7 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_pot_eval(
#else
#else
const
float
x
=
2
.
f
*
u
;
const
float
x
=
2
.
f
*
u
;
const
float
exp_x
=
good_approx_expf
(
x
);
const
float
exp_x
=
expf
(
x
);
//
good_approx_expf(x);
const
float
alpha
=
1
.
f
/
(
1
.
f
+
exp_x
);
const
float
alpha
=
1
.
f
/
(
1
.
f
+
exp_x
);
/* We want 2 - 2 exp(x) * alpha */
/* We want 2 - 2 exp(x) * alpha */
...
@@ -84,12 +84,22 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_force_eval(
...
@@ -84,12 +84,22 @@ __attribute__((always_inline)) INLINE static void kernel_long_grav_force_eval(
*
W
=
term1
+
term2
;
*
W
=
term1
+
term2
;
#else
#else
const
float
arg
=
2
.
f
*
u
;
const
float
x
=
2
.
f
*
u
;
const
float
exp_
arg
=
good_approx_expf
(
arg
);
const
float
exp_
x
=
expf
(
x
);
//
good_approx_expf(
x
);
const
float
term
=
1
.
f
/
(
1
.
f
+
exp_
arg
);
const
float
alpha
=
1
.
f
/
(
1
.
f
+
exp_
x
);
*
W
=
arg
*
exp_arg
*
term
*
term
-
exp_arg
*
term
+
1
.
f
;
/* We want 2*(x*alpha - x*alpha^2 - exp(x)*alpha + 1) */
*
W
=
1
.
f
-
alpha
;
*
W
=
*
W
*
x
-
exp_x
;
*
W
=
*
W
*
alpha
+
1
.
f
;
*
W
*=
2
.
f
;
*
W
*=
2
.
f
;
/* const float arg = 2.f * u; */
/* const float exp_arg = good_approx_expf(arg); */
/* const float term = 1.f / (1.f + exp_arg); */
/* *W = arg * exp_arg * term * term - exp_arg * term + 1.f; */
/* *W *= 2.f; */
#endif
#endif
}
}
...
...
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