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
329517a3
Commit
329517a3
authored
May 27, 2017
by
James Willis
Browse files
Updated brute force density pair calculations to include periodic boundary conditions.
parent
5022edc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tools.c
View file @
329517a3
...
...
@@ -182,6 +182,16 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
float
r2
,
hi
,
hj
,
hig2
,
hjg2
,
dx
[
3
];
struct
part
*
pi
,
*
pj
;
const
struct
engine
*
restrict
e
=
r
->
e
;
/* Get the sort ID. */
double
shift
[
3
]
=
{
0
.
0
,
0
.
0
,
0
.
0
};
const
int
sid
=
space_getsid
(
e
->
s
,
&
ci
,
&
cj
,
shift
);
/* Get the cutoff shift. */
double
rshift
=
0
.
0
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
rshift
+=
shift
[
k
]
*
runner_shift
[
sid
][
k
];
/* Implements a double-for loop and checks every interaction */
for
(
int
i
=
0
;
i
<
ci
->
count
;
++
i
)
{
...
...
@@ -196,7 +206,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Pairwise distance */
r2
=
0
.
0
f
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
ci
->
parts
[
i
].
x
[
k
]
-
cj
->
parts
[
j
].
x
[
k
];
dx
[
k
]
=
(
ci
->
parts
[
i
].
x
[
k
]
-
shift
[
k
])
-
cj
->
parts
[
j
].
x
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
}
...
...
@@ -223,7 +233,7 @@ void pairs_all_density(struct runner *r, struct cell *ci, struct cell *cj) {
/* Pairwise distance */
r2
=
0
.
0
f
;
for
(
int
k
=
0
;
k
<
3
;
k
++
)
{
dx
[
k
]
=
cj
->
parts
[
j
].
x
[
k
]
-
ci
->
parts
[
i
].
x
[
k
];
dx
[
k
]
=
(
cj
->
parts
[
j
].
x
[
k
]
+
shift
[
k
])
-
ci
->
parts
[
i
].
x
[
k
];
r2
+=
dx
[
k
]
*
dx
[
k
];
}
...
...
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