Skip to content
GitLab
Menu
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
b4f29fee
Commit
b4f29fee
authored
Mar 29, 2016
by
Pedro Gonnet
Browse files
first pass through space.c.
parent
2e9a2c28
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/space.c
View file @
b4f29fee
...
@@ -167,7 +167,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
...
@@ -167,7 +167,7 @@ void space_regrid(struct space *s, double cell_max, int verbose) {
if
(
s
->
cells
[
k
].
h_max
>
h_max
)
h_max
=
s
->
cells
[
k
].
h_max
;
if
(
s
->
cells
[
k
].
h_max
>
h_max
)
h_max
=
s
->
cells
[
k
].
h_max
;
}
}
}
else
{
}
else
{
for
(
in
t
k
=
0
;
k
<
nr_parts
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
nr_parts
;
k
++
)
{
if
(
s
->
parts
[
k
].
h
>
h_max
)
h_max
=
s
->
parts
[
k
].
h
;
if
(
s
->
parts
[
k
].
h
>
h_max
)
h_max
=
s
->
parts
[
k
].
h
;
}
}
s
->
h_max
=
h_max
;
s
->
h_max
=
h_max
;
...
@@ -314,8 +314,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -314,8 +314,8 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
/* Re-grid if necessary, or just re-set the cell data. */
/* Re-grid if necessary, or just re-set the cell data. */
space_regrid
(
s
,
cell_max
,
verbose
);
space_regrid
(
s
,
cell_max
,
verbose
);
in
t
nr_parts
=
s
->
nr_parts
;
size_
t
nr_parts
=
s
->
nr_parts
;
in
t
nr_gparts
=
s
->
nr_gparts
;
size_
t
nr_gparts
=
s
->
nr_gparts
;
struct
cell
*
restrict
cells
=
s
->
cells
;
struct
cell
*
restrict
cells
=
s
->
cells
;
const
double
ih
[
3
]
=
{
s
->
ih
[
0
],
s
->
ih
[
1
],
s
->
ih
[
2
]};
const
double
ih
[
3
]
=
{
s
->
ih
[
0
],
s
->
ih
[
1
],
s
->
ih
[
2
]};
...
@@ -328,7 +328,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -328,7 +328,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
int
*
ind
;
int
*
ind
;
if
((
ind
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
ind_size
))
==
NULL
)
if
((
ind
=
(
int
*
)
malloc
(
sizeof
(
int
)
*
ind_size
))
==
NULL
)
error
(
"Failed to allocate temporary particle indices."
);
error
(
"Failed to allocate temporary particle indices."
);
for
(
in
t
k
=
0
;
k
<
nr_parts
;
k
++
)
{
for
(
size_
t
k
=
0
;
k
<
nr_parts
;
k
++
)
{
struct
part
*
restrict
p
=
&
s
->
parts
[
k
];
struct
part
*
restrict
p
=
&
s
->
parts
[
k
];
for
(
int
j
=
0
;
j
<
3
;
j
++
)
for
(
int
j
=
0
;
j
<
3
;
j
++
)
if
(
p
->
x
[
j
]
<
0
.
0
)
if
(
p
->
x
[
j
]
<
0
.
0
)
...
@@ -365,7 +365,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -365,7 +365,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
#ifdef WITH_MPI
#ifdef WITH_MPI
/* Move non-local parts to the end of the list. */
/* Move non-local parts to the end of the list. */
const
int
local_nodeID
=
s
->
e
->
nodeID
;
const
int
local_nodeID
=
s
->
e
->
nodeID
;
for
(
in
t
k
=
0
;
k
<
nr_parts
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
nr_parts
;
k
++
)
if
(
cells
[
ind
[
k
]].
nodeID
!=
local_nodeID
)
{
if
(
cells
[
ind
[
k
]].
nodeID
!=
local_nodeID
)
{
cells
[
ind
[
k
]].
count
-=
1
;
cells
[
ind
[
k
]].
count
-=
1
;
nr_parts
-=
1
;
nr_parts
-=
1
;
...
@@ -431,7 +431,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -431,7 +431,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
}
}
/* Assign each particle to its cell. */
/* Assign each particle to its cell. */
for
(
in
t
k
=
nr_parts
;
k
<
s
->
nr_parts
;
k
++
)
{
for
(
size_
t
k
=
nr_parts
;
k
<
s
->
nr_parts
;
k
++
)
{
const
struct
part
*
const
p
=
&
s
->
parts
[
k
];
const
struct
part
*
const
p
=
&
s
->
parts
[
k
];
ind
[
k
]
=
ind
[
k
]
=
cell_getid
(
cdim
,
p
->
x
[
0
]
*
ih
[
0
],
p
->
x
[
1
]
*
ih
[
1
],
p
->
x
[
2
]
*
ih
[
2
]);
cell_getid
(
cdim
,
p
->
x
[
0
]
*
ih
[
0
],
p
->
x
[
1
]
*
ih
[
1
],
p
->
x
[
2
]
*
ih
[
2
]);
...
@@ -447,7 +447,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
...
@@ -447,7 +447,7 @@ void space_rebuild(struct space *s, double cell_max, int verbose) {
space_parts_sort
(
s
,
ind
,
nr_parts
,
0
,
s
->
nr_cells
-
1
,
verbose
);
space_parts_sort
(
s
,
ind
,
nr_parts
,
0
,
s
->
nr_cells
-
1
,
verbose
);
/* Re-link the gparts. */
/* Re-link the gparts. */
for
(
in
t
k
=
0
;
k
<
nr_parts
;
k
++
)
for
(
size_
t
k
=
0
;
k
<
nr_parts
;
k
++
)
if
(
s
->
parts
[
k
].
gpart
!=
NULL
)
s
->
parts
[
k
].
gpart
->
part
=
&
s
->
parts
[
k
];
if
(
s
->
parts
[
k
].
gpart
!=
NULL
)
s
->
parts
[
k
].
gpart
->
part
=
&
s
->
parts
[
k
];
/* Verify space_sort_struct. */
/* Verify space_sort_struct. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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