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
b6070859
Commit
b6070859
authored
7 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Apply long-range gravity correction only when running with periodic BCs on.
parent
3e0ab104
No related branches found
No related tags found
1 merge request
!393
Periodic gravity speed and accuracy improvements
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/gravity/Default/gravity_iact.h
+10
-4
10 additions, 4 deletions
src/gravity/Default/gravity_iact.h
src/runner_doiact_grav.h
+7
-5
7 additions, 5 deletions
src/runner_doiact_grav.h
src/tools.c
+2
-2
2 additions, 2 deletions
src/tools.c
with
19 additions
and
11 deletions
src/gravity/Default/gravity_iact.h
+
10
−
4
View file @
b6070859
...
...
@@ -32,7 +32,7 @@
*/
__attribute__
((
always_inline
))
INLINE
static
void
runner_iact_grav_pp
(
float
rlr_inv
,
float
r2
,
const
float
*
dx
,
struct
gpart
*
gpi
,
struct
gpart
*
gpj
)
{
struct
gpart
*
gpj
,
int
periodic
)
{
/* Apply the gravitational acceleration. */
const
float
r
=
sqrtf
(
r2
);
...
...
@@ -49,7 +49,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp(
#endif
/* Get long-range correction */
kernel_long_grav_eval
(
u
,
&
f_lr
);
if
(
periodic
)
kernel_long_grav_eval
(
u
,
&
f_lr
);
else
f_lr
=
1
.
f
;
if
(
r
>=
hi
)
{
...
...
@@ -101,7 +104,7 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp(
*/
__attribute__
((
always_inline
))
INLINE
static
void
runner_iact_grav_pp_nonsym
(
float
rlr_inv
,
float
r2
,
const
float
*
dx
,
struct
gpart
*
gpi
,
const
struct
gpart
*
gpj
)
{
const
struct
gpart
*
gpj
,
int
periodic
)
{
/* Apply the gravitational acceleration. */
const
float
r
=
sqrtf
(
r2
);
...
...
@@ -116,7 +119,10 @@ __attribute__((always_inline)) INLINE static void runner_iact_grav_pp_nonsym(
#endif
/* Get long-range correction */
kernel_long_grav_eval
(
u
,
&
f_lr
);
if
(
periodic
)
kernel_long_grav_eval
(
u
,
&
f_lr
);
else
f_lr
=
1
.
f
;
if
(
r
>=
hi
)
{
...
...
This diff is collapsed.
Click to expand it.
src/runner_doiact_grav.h
+
7
−
5
View file @
b6070859
...
...
@@ -267,7 +267,7 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) {
#endif
/* Interact ! */
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
);
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
,
periodic
);
#ifdef SWIFT_DEBUG_CHECKS
gpi
->
num_interacted
++
;
...
...
@@ -310,7 +310,7 @@ void runner_dopair_grav_pp(struct runner *r, struct cell *ci, struct cell *cj) {
#endif
/* Interact ! */
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpj
,
gpi
);
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpj
,
gpi
,
periodic
);
#ifdef SWIFT_DEBUG_CHECKS
gpj
->
num_interacted
++
;
...
...
@@ -334,6 +334,8 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
/* Some constants */
const
struct
engine
*
e
=
r
->
e
;
const
struct
space
*
s
=
e
->
s
;
const
int
periodic
=
s
->
periodic
;
const
float
a_smooth
=
e
->
gravity_properties
->
a_smooth
;
const
float
rlr_inv
=
1
.
/
(
a_smooth
*
c
->
super
->
width
[
0
]);
...
...
@@ -397,7 +399,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
/* Interact ! */
if
(
gpart_is_active
(
gpi
,
e
)
&&
gpart_is_active
(
gpj
,
e
))
{
runner_iact_grav_pp
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
);
runner_iact_grav_pp
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
,
periodic
);
#ifdef SWIFT_DEBUG_CHECKS
gpi
->
num_interacted
++
;
...
...
@@ -408,7 +410,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
if
(
gpart_is_active
(
gpi
,
e
))
{
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
);
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
,
periodic
);
#ifdef SWIFT_DEBUG_CHECKS
gpi
->
num_interacted
++
;
...
...
@@ -419,7 +421,7 @@ void runner_doself_grav_pp(struct runner *r, struct cell *c) {
dx
[
0
]
=
-
dx
[
0
];
dx
[
1
]
=
-
dx
[
1
];
dx
[
2
]
=
-
dx
[
2
];
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpj
,
gpi
);
runner_iact_grav_pp_nonsym
(
rlr_inv
,
r2
,
dx
,
gpj
,
gpi
,
periodic
);
#ifdef SWIFT_DEBUG_CHECKS
gpj
->
num_interacted
++
;
...
...
This diff is collapsed.
Click to expand it.
src/tools.c
+
2
−
2
View file @
b6070859
...
...
@@ -430,7 +430,7 @@ void pairs_single_grav(double *dim, long long int pid,
fdx
[
i
]
=
dx
[
i
];
}
r2
=
fdx
[
0
]
*
fdx
[
0
]
+
fdx
[
1
]
*
fdx
[
1
]
+
fdx
[
2
]
*
fdx
[
2
];
runner_iact_grav_pp
(
0
.
f
,
r2
,
fdx
,
&
pi
,
&
pj
);
runner_iact_grav_pp
(
0
.
f
,
r2
,
fdx
,
&
pi
,
&
pj
,
0
);
a
[
0
]
+=
pi
.
a_grav
[
0
];
a
[
1
]
+=
pi
.
a_grav
[
1
];
a
[
2
]
+=
pi
.
a_grav
[
2
];
...
...
@@ -790,7 +790,7 @@ void gravity_n2(struct gpart *gparts, const int gcount,
if
(
r2
<
max_d2
||
1
)
{
/* Apply the gravitational acceleration. */
runner_iact_grav_pp
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
);
runner_iact_grav_pp
(
rlr_inv
,
r2
,
dx
,
gpi
,
gpj
,
0
);
}
}
}
...
...
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