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
01be20c4
Commit
01be20c4
authored
Aug 19, 2016
by
Matthieu Schaller
Browse files
Dead code elimination in the cell structure, better documentation and further MPI guards.
parent
ecc1a6f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/cell.c
View file @
01be20c4
...
...
@@ -63,7 +63,6 @@ int cell_next_tag = 0;
*
* @param c The #cell.
*/
int
cell_getsize
(
struct
cell
*
c
)
{
/* Number of cells in this subtree. */
...
...
@@ -87,9 +86,10 @@ int cell_getsize(struct cell *c) {
*
* @return The number of cells created.
*/
int
cell_unpack
(
struct
pcell
*
pc
,
struct
cell
*
c
,
struct
space
*
s
)
{
#ifdef WITH_MPI
/* Unpack the current pcell. */
c
->
h_max
=
pc
->
h_max
;
c
->
ti_end_min
=
pc
->
ti_end_min
;
...
...
@@ -130,6 +130,11 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
/* Return the total number of unpacked cells. */
c
->
pcell_size
=
count
;
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
...
...
@@ -140,7 +145,6 @@ int cell_unpack(struct pcell *pc, struct cell *c, struct space *s) {
*
* @return The number of particles linked.
*/
int
cell_link_parts
(
struct
cell
*
c
,
struct
part
*
parts
)
{
c
->
parts
=
parts
;
...
...
@@ -166,7 +170,6 @@ int cell_link_parts(struct cell *c, struct part *parts) {
*
* @return The number of particles linked.
*/
int
cell_link_gparts
(
struct
cell
*
c
,
struct
gpart
*
gparts
)
{
c
->
gparts
=
gparts
;
...
...
@@ -193,9 +196,10 @@ int cell_link_gparts(struct cell *c, struct gpart *gparts) {
*
* @return The number of packed cells.
*/
int
cell_pack
(
struct
cell
*
c
,
struct
pcell
*
pc
)
{
#ifdef WITH_MPI
/* Start by packing the data of the current cell. */
pc
->
h_max
=
c
->
h_max
;
pc
->
ti_end_min
=
c
->
ti_end_min
;
...
...
@@ -216,10 +220,25 @@ int cell_pack(struct cell *c, struct pcell *pc) {
/* Return the number of packed cells used. */
c
->
pcell_size
=
count
;
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
* @brief Pack the time information of the given cell and all it's sub-cells.
*
* @param c The #cell.
* @param ti_ends (output) The time information we pack into
*
* @return The number of packed cells.
*/
int
cell_pack_ti_ends
(
struct
cell
*
c
,
int
*
ti_ends
)
{
#ifdef WITH_MPI
/* Pack this cell's data. */
ti_ends
[
0
]
=
c
->
ti_end_min
;
...
...
@@ -232,10 +251,25 @@ int cell_pack_ti_ends(struct cell *c, int *ti_ends) {
/* Return the number of packed values. */
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
* @brief Unpack the time information of a given cell and its sub-cells.
*
* @param c The #cell
* @param s ti_ends The time information to unpack
*
* @return The number of cells created.
*/
int
cell_unpack_ti_ends
(
struct
cell
*
c
,
int
*
ti_ends
)
{
#ifdef WITH_MPI
/* Unpack this cell's data. */
c
->
ti_end_min
=
ti_ends
[
0
];
...
...
@@ -248,14 +282,19 @@ int cell_unpack_ti_ends(struct cell *c, int *ti_ends) {
/* Return the number of packed values. */
return
count
;
#else
error
(
"SWIFT was not compiled with MPI support."
);
return
0
;
#endif
}
/**
* @brief Lock a cell and hold its parents.
* @brief Lock a cell
for access to its array of #part
and hold its parents.
*
* @param c The #cell.
* @return 0 on success, 1 on failure
*/
int
cell_locktree
(
struct
cell
*
c
)
{
TIMER_TIC
...
...
@@ -314,6 +353,12 @@ int cell_locktree(struct cell *c) {
}
}
/**
* @brief Lock a cell for access to its array of #gpart and hold its parents.
*
* @param c The #cell.
* @return 0 on success, 1 on failure
*/
int
cell_glocktree
(
struct
cell
*
c
)
{
TIMER_TIC
...
...
@@ -373,11 +418,10 @@ int cell_glocktree(struct cell *c) {
}
/**
* @brief Unlock a cell's parents.
* @brief Unlock a cell's parents
for access to #part array
.
*
* @param c The #cell.
*/
void
cell_unlocktree
(
struct
cell
*
c
)
{
TIMER_TIC
...
...
@@ -392,6 +436,11 @@ void cell_unlocktree(struct cell *c) {
TIMER_TOC
(
timer_locktree
);
}
/**
* @brief Unlock a cell's parents for access to #gpart array.
*
* @param c The #cell.
*/
void
cell_gunlocktree
(
struct
cell
*
c
)
{
TIMER_TIC
...
...
@@ -413,7 +462,6 @@ void cell_gunlocktree(struct cell *c) {
* @param parts_offset Offset of the cell parts array relative to the
* space's parts array, i.e. c->parts - s->parts.
*/
void
cell_split
(
struct
cell
*
c
,
ptrdiff_t
parts_offset
)
{
int
i
,
j
;
...
...
@@ -630,57 +678,9 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset) {
part_relink_parts
(
gparts
,
gcount
,
parts
-
parts_offset
);
}
/**
* @brief Initialises all particles to a valid state even if the ICs were stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void
cell_init_parts
(
struct
cell
*
c
,
void
*
data
)
{
struct
part
*
restrict
p
=
c
->
parts
;
struct
xpart
*
restrict
xp
=
c
->
xparts
;
const
size_t
count
=
c
->
count
;
for
(
size_t
i
=
0
;
i
<
count
;
++
i
)
{
p
[
i
].
ti_begin
=
0
;
p
[
i
].
ti_end
=
0
;
xp
[
i
].
v_full
[
0
]
=
p
[
i
].
v
[
0
];
xp
[
i
].
v_full
[
1
]
=
p
[
i
].
v
[
1
];
xp
[
i
].
v_full
[
2
]
=
p
[
i
].
v
[
2
];
hydro_first_init_part
(
&
p
[
i
],
&
xp
[
i
]);
hydro_init_part
(
&
p
[
i
]);
hydro_reset_acceleration
(
&
p
[
i
]);
}
c
->
ti_end_min
=
0
;
c
->
ti_end_max
=
0
;
}
/**
* @brief Initialises all g-particles to a valid state even if the ICs were
*stupid
*
* @param c Cell to act upon
* @param data Unused parameter
*/
void
cell_init_gparts
(
struct
cell
*
c
,
void
*
data
)
{
struct
gpart
*
restrict
gp
=
c
->
gparts
;
const
size_t
gcount
=
c
->
gcount
;
for
(
size_t
i
=
0
;
i
<
gcount
;
++
i
)
{
gp
[
i
].
ti_begin
=
0
;
gp
[
i
].
ti_end
=
0
;
gravity_first_init_gpart
(
&
gp
[
i
]);
gravity_init_gpart
(
&
gp
[
i
]);
}
c
->
ti_end_min
=
0
;
c
->
ti_end_max
=
0
;
}
/**
* @brief Converts hydro quantities to a valid state after the initial density
*calculation
*
calculation
*
* @param c Cell to act upon
* @param data Unused parameter
...
...
@@ -709,7 +709,6 @@ void cell_clean_links(struct cell *c, void *data) {
}
/**
<<<<<<< HEAD
* @brief Checks whether the cells are direct neighbours ot not. Both cells have
* to be of the same size
*
...
...
@@ -794,8 +793,10 @@ void cell_check_multipole(struct cell *c, void *data) {
}
}
/*
/*
*
* @brief Frees up the memory allocated for this #cell
*
* @param c The #cell
*/
void
cell_clean
(
struct
cell
*
c
)
{
...
...
src/cell.h
View file @
01be20c4
...
...
@@ -73,7 +73,7 @@ struct cell {
/* The cell dimensions. */
double
width
[
3
];
/* Max
radii
in this cell. */
/* Max
smoothing length
in this cell. */
double
h_max
;
/* Minimum and maximum end of time step in this cell. */
...
...
@@ -85,7 +85,7 @@ struct cell {
/* Maximum slack allowed for particle movement. */
float
slack
;
/* Maximum particle movement in this cell. */
/* Maximum particle movement in this cell
since last construction
. */
float
dx_max
;
/* The depth of this cell in the tree. */
...
...
@@ -165,9 +165,14 @@ struct cell {
/* Linking pointer for "memory management". */
struct
cell
*
next
;
/* This cell's multipole. */
struct
multipole
multipole
;
/* ID of the node this cell lives on. */
int
nodeID
;
#ifdef WITH_MPI
/* Bit mask of the proxies this cell is registered with. */
unsigned
long
long
int
sendto
;
...
...
@@ -176,8 +181,7 @@ struct cell {
int
pcell_size
;
int
tag
;
/* This cell's multipole. */
struct
multipole
multipole
;
#endif
}
__attribute__
((
aligned
(
64
)));
...
...
@@ -198,8 +202,6 @@ int cell_unpack_ti_ends(struct cell *c, int *ti_ends);
int
cell_getsize
(
struct
cell
*
c
);
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_init_gparts
(
struct
cell
*
c
,
void
*
data
);
void
cell_convert_hydro
(
struct
cell
*
c
,
void
*
data
);
void
cell_clean_links
(
struct
cell
*
c
,
void
*
data
);
int
cell_are_neighbours
(
const
struct
cell
*
restrict
ci
,
...
...
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