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
aeb68375
Commit
aeb68375
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Prevent FPEs in the P-P gravity calculation.
parent
0d30fc96
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/gravity/Default/gravity_iact.h
+12
-7
12 additions, 7 deletions
src/gravity/Default/gravity_iact.h
src/runner_doiact_grav.h
+2
-1
2 additions, 1 deletion
src/runner_doiact_grav.h
with
14 additions
and
8 deletions
src/gravity/Default/gravity_iact.h
+
12
−
7
View file @
aeb68375
...
...
@@ -44,19 +44,19 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp_full(
float
r2
,
float
h2
,
float
h_inv
,
float
h_inv3
,
float
mass
,
float
*
f_ij
,
float
*
pot_ij
)
{
/* Get the inverse distance */
const
float
r_inv
=
1
.
f
/
sqrtf
(
r2
);
/* Should we soften ? */
if
(
r2
>=
h2
)
{
/* Get the inverse distance */
const
float
r_inv
=
1
.
f
/
sqrtf
(
r2
);
/* Get Newtonian gravity */
*
f_ij
=
mass
*
r_inv
*
r_inv
*
r_inv
;
*
pot_ij
=
-
mass
*
r_inv
;
}
else
{
const
float
r
=
r2
*
r_inv
;
const
float
r
=
sqrtf
(
r2
)
;
const
float
ui
=
r
*
h_inv
;
float
W_f_ij
,
W_pot_ij
;
...
...
@@ -89,19 +89,24 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp_truncated(
float
r2
,
float
h2
,
float
h_inv
,
float
h_inv3
,
float
mass
,
float
rlr_inv
,
float
*
f_ij
,
float
*
pot_ij
)
{
/* Get the inverse distance */
const
float
r_inv
=
1
.
f
/
sqrtf
(
r2
);
const
float
r
=
r2
*
r_inv
;
float
r
;
/* Should we soften ? */
if
(
r2
>=
h2
)
{
/* Get the inverse distance */
const
float
r_inv
=
1
.
f
/
sqrtf
(
r2
);
r
=
r2
*
r_inv
;
/* Get Newtonian gravity */
*
f_ij
=
mass
*
r_inv
*
r_inv
*
r_inv
;
*
pot_ij
=
-
mass
*
r_inv
;
}
else
{
/* Get the distance */
r
=
sqrtf
(
r2
);
const
float
ui
=
r
*
h_inv
;
float
W_f_ij
,
W_pot_ij
;
...
...
This diff is collapsed.
Click to expand it.
src/runner_doiact_grav.h
+
2
−
1
View file @
aeb68375
...
...
@@ -234,7 +234,8 @@ static INLINE void runner_dopair_grav_pp_full(const struct engine *e,
const
float
r2
=
dx
*
dx
+
dy
*
dy
+
dz
*
dz
;
#ifdef SWIFT_DEBUG_CHECKS
if
(
r2
==
0
.
f
)
error
(
"Interacting particles with 0 distance"
);
if
(
r2
==
0
.
f
&&
h_i
==
0
.)
error
(
"Interacting particles with 0 distance and 0 softening."
);
/* Check that particles have been drifted to the current time */
if
(
gparts_i
[
pid
].
ti_drift
!=
e
->
ti_current
)
...
...
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