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
e0837986
Commit
e0837986
authored
Mar 10, 2016
by
Pedro Gonnet
Browse files
pack and unpack cells with the gcount.
parent
91fb4f07
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
e0837986
...
...
@@ -89,14 +89,18 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
c
->
ti_end_min
=
pc
->
ti_end_min
;
c
->
ti_end_max
=
pc
->
ti_end_max
;
c
->
count
=
pc
->
count
;
c
->
gcount
=
pc
->
gcount
;
c
->
tag
=
pc
->
tag
;
/* Number of new cells created. */
int
count
=
1
;
/* Fill the progeny recursively, depth-first. */
int
count
=
1
;
for
(
int
k
=
0
;
k
<
8
;
k
++
)
if
(
pc
->
progeny
[
k
]
>=
0
)
{
struct
cell
*
temp
=
space_getcell
(
s
);
temp
->
count
=
0
;
temp
->
gcount
=
0
;
temp
->
loc
[
0
]
=
c
->
loc
[
0
];
temp
->
loc
[
1
]
=
c
->
loc
[
1
];
temp
->
loc
[
2
]
=
c
->
loc
[
2
];
...
...
@@ -122,7 +126,7 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
}
/**
* @brief Link the cells recursively to the given part array.
* @brief Link the cells recursively to the given
#
part array.
*
* @param c The #cell.
* @param parts The #part array.
...
...
@@ -130,7 +134,7 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
* @return The number of particles linked.
*/
int
cell_link
(
struct
cell
*
c
,
struct
part
*
parts
)
{
int
cell_link
_parts
(
struct
cell
*
c
,
struct
part
*
parts
)
{
c
->
parts
=
parts
;
...
...
@@ -139,14 +143,40 @@ int cell_link(struct cell *c, struct part *parts) {
int
offset
=
0
;
for
(
int
k
=
0
;
k
<
8
;
k
++
)
{
if
(
c
->
progeny
[
k
]
!=
NULL
)
offset
+=
cell_link
(
c
->
progeny
[
k
],
&
parts
[
offset
]);
offset
+=
cell_link
_parts
(
c
->
progeny
[
k
],
&
parts
[
offset
]);
}
}
/* Return the total number of
unpacked cell
s. */
/* Return the total number of
linked particle
s. */
return
c
->
count
;
}
/**
* @brief Link the cells recursively to the given #gpart array.
*
* @param c The #cell.
* @param gparts The #gpart array.
*
* @return The number of particles linked.
*/
int
cell_link_gparts
(
struct
cell
*
c
,
struct
gpart
*
gparts
)
{
c
->
gparts
=
gparts
;
/* Fill the progeny recursively, depth-first. */
if
(
c
->
split
)
{
int
offset
=
0
;
for
(
int
k
=
0
;
k
<
8
;
k
++
)
{
if
(
c
->
progeny
[
k
]
!=
NULL
)
offset
+=
cell_link_gparts
(
c
->
progeny
[
k
],
&
gparts
[
offset
]);
}
}
/* Return the total number of linked particles. */
return
c
->
gcount
;
}
/**
* @brief Pack the data of the given cell and all it's sub-cells.
*
...
...
@@ -164,6 +194,7 @@ int cell_pack(struct cell *c, struct pcell *pc) {
pc
->
ti_end_min
=
c
->
ti_end_min
;
pc
->
ti_end_max
=
c
->
ti_end_max
;
pc
->
count
=
c
->
count
;
pc
->
gcount
=
c
->
gcount
;
c
->
tag
=
pc
->
tag
=
atomic_inc
(
&
cell_next_tag
)
%
cell_max_tag
;
/* Fill in the progeny, depth-first recursion. */
...
...
src/cell.h
View file @
e0837986
...
...
@@ -44,7 +44,7 @@ struct pcell {
int
ti_end_min
,
ti_end_max
;
/* Number of particles in this cell. */
int
count
;
int
count
,
gcount
;
/* tag used for MPI communication. */
int
tag
;
...
...
@@ -175,7 +175,8 @@ void cell_gunlocktree(struct cell *c);
int
cell_pack
(
struct
cell
*
c
,
struct
pcell
*
pc
);
int
cell_unpack
(
struct
pcell
*
pc
,
struct
cell
*
c
,
struct
space
*
s
);
int
cell_getsize
(
struct
cell
*
c
);
int
cell_link
(
struct
cell
*
c
,
struct
part
*
parts
);
int
cell_link_parts
(
struct
cell
*
c
,
struct
part
*
parts
);
int
cell_link_gparts
(
struct
cell
*
c
,
struct
gpart
*
gparts
);
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
);
void
cell_convert_hydro
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
);
...
...
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