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
8a2c8f09
Commit
8a2c8f09
authored
May 31, 2017
by
James Willis
Browse files
Added explicit periodic BC checks in the brute force pair density interactions.
parent
274bc00f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/tools.c
View file @
8a2c8f09
...
...
@@ -38,6 +38,7 @@
#include
"hydro.h"
#include
"part.h"
#include
"runner.h"
#include
"periodic.h"
/**
* Factorize a given integer, attempts to keep larger pair of factors.
...
...
@@ -182,16 +183,6 @@ 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
)
{
...
...
@@ -206,7 +197,8 @@ 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
]
-
shift
[
k
])
-
cj
->
parts
[
j
].
x
[
k
];
dx
[
k
]
=
ci
->
parts
[
i
].
x
[
k
]
-
cj
->
parts
[
j
].
x
[
k
];
dx
[
k
]
=
nearest
(
dx
[
k
],
r
->
e
->
s
->
dim
[
k
]);
r2
+=
dx
[
k
]
*
dx
[
k
];
}
...
...
@@ -233,7 +225,8 @@ 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
]
+
shift
[
k
])
-
ci
->
parts
[
i
].
x
[
k
];
dx
[
k
]
=
cj
->
parts
[
j
].
x
[
k
]
-
ci
->
parts
[
i
].
x
[
k
];
dx
[
k
]
=
nearest
(
dx
[
k
],
r
->
e
->
s
->
dim
[
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