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
58430327
Commit
58430327
authored
Feb 28, 2017
by
Matthieu Schaller
Browse files
Avoid division by zero in some rare cases when using the point-mass external potential
parent
d04809b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/potential/point_mass/potential.h
View file @
58430327
...
...
@@ -24,6 +24,7 @@
#include
"../config.h"
/* Some standard headers. */
#include
<float.h>
#include
<math.h>
/* Local includes. */
...
...
@@ -84,7 +85,10 @@ __attribute__((always_inline)) INLINE static float external_gravity_timestep(
const
float
a_2
=
g
->
a_grav
[
0
]
*
g
->
a_grav
[
0
]
+
g
->
a_grav
[
1
]
*
g
->
a_grav
[
1
]
+
g
->
a_grav
[
2
]
*
g
->
a_grav
[
2
];
return
potential
->
timestep_mult
*
sqrtf
(
a_2
/
dota_2
);
if
(
fabsf
(
dota_2
)
>
0
.
f
)
return
potential
->
timestep_mult
*
sqrtf
(
a_2
/
dota_2
);
else
return
FLT_MAX
;
}
/**
...
...
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