Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
SWIFTsim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
72
Issues
72
List
Boards
Labels
Milestones
Merge Requests
12
Merge Requests
12
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SWIFT
SWIFTsim
Commits
647eceac
Commit
647eceac
authored
Apr 22, 2018
by
Matthieu Schaller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into improved_grackle
parents
55c84bb5
c08467a4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
341 additions
and
628 deletions
+341
-628
examples/process_cells
examples/process_cells
+3
-3
src/cell.c
src/cell.c
+21
-16
src/debug.c
src/debug.c
+1
-2
src/engine.c
src/engine.c
+12
-4
src/part.c
src/part.c
+23
-3
src/part.h
src/part.h
+2
-0
src/space.c
src/space.c
+265
-582
src/space.h
src/space.h
+14
-18
No files found.
examples/process_cells
View file @
647eceac
...
...
@@ -38,7 +38,7 @@ ranks=$(ls -v cells_*.dat | sed 's,cells_\(.*\)_.*.dat,\1,' | sort | uniq | wc -
echo
"Number of ranks =
$ranks
"
# Now construct a list of files ordered by rank, not step.
files
=
$(
ls
cells_
*
.dat |
sort
-t
"_"
-k
3,3
-n
| xargs
-n
4
)
files
=
$(
ls
cells_
*
.dat |
sort
-t
"_"
-k
3,3
-n
| xargs
-n
$ranks
)
# Need number of steps.
nfiles
=
$(
echo
$files
|
wc
-w
)
...
...
@@ -48,10 +48,10 @@ echo "Number of steps = $steps"
# And process them,
echo
"Processing cell dumps files..."
echo
$files
| xargs
-P
$NPROCS
-n
4 /bin/bash
-c
"
${
SCRIPTHOME
}
/process_cells_helper
$NX
$NY
$NZ
\$
0
\$
1
\$
2
\$
3"
echo
$files
| xargs
-P
$NPROCS
-n
$ranks
${
SCRIPTHOME
}
/process_cells_helper
$NX
$NY
$NZ
# Create summary.
grep
"top cells"
step
*
-active-cells
.dat |
sort
-
h
>
active_cells.log
grep
"top cells"
step
*
-active-cells
.dat |
sort
-
n
-k
1.5
>
active_cells.log
# And plot of active cells to edge cells.
stilts plot2plane
ifmt
=
ascii
in
=
active_cells.log
xmin
=
-0
.1
xmax
=
1.1
ymin
=
0
ymax
=
$steps
grid
=
1
\
...
...
src/cell.c
View file @
647eceac
...
...
@@ -835,11 +835,15 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
memswap
(
&
parts
[
j
],
&
part
,
sizeof
(
struct
part
));
memswap
(
&
xparts
[
j
],
&
xpart
,
sizeof
(
struct
xpart
));
memswap
(
&
buff
[
j
],
&
temp_buff
,
sizeof
(
struct
cell_buff
));
if
(
parts
[
j
].
gpart
)
parts
[
j
].
gpart
->
id_or_neg_offset
=
-
(
j
+
parts_offset
);
bid
=
temp_buff
.
ind
;
}
parts
[
k
]
=
part
;
xparts
[
k
]
=
xpart
;
buff
[
k
]
=
temp_buff
;
if
(
parts
[
k
].
gpart
)
parts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
parts_offset
);
}
bucket_count
[
bid
]
++
;
}
...
...
@@ -852,10 +856,6 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
c
->
progeny
[
k
]
->
xparts
=
&
c
->
xparts
[
bucket_offset
[
k
]];
}
/* Re-link the gparts. */
if
(
count
>
0
&&
gcount
>
0
)
part_relink_gparts_to_parts
(
parts
,
count
,
parts_offset
);
#ifdef SWIFT_DEBUG_CHECKS
/* Check that the buffs are OK. */
for
(
int
k
=
1
;
k
<
count
;
k
++
)
{
...
...
@@ -952,10 +952,14 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
}
memswap
(
&
sparts
[
j
],
&
spart
,
sizeof
(
struct
spart
));
memswap
(
&
sbuff
[
j
],
&
temp_buff
,
sizeof
(
struct
cell_buff
));
if
(
sparts
[
j
].
gpart
)
sparts
[
j
].
gpart
->
id_or_neg_offset
=
-
(
j
+
sparts_offset
);
bid
=
temp_buff
.
ind
;
}
sparts
[
k
]
=
spart
;
sbuff
[
k
]
=
temp_buff
;
if
(
sparts
[
k
].
gpart
)
sparts
[
k
].
gpart
->
id_or_neg_offset
=
-
(
k
+
sparts_offset
);
}
bucket_count
[
bid
]
++
;
}
...
...
@@ -967,10 +971,6 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
c
->
progeny
[
k
]
->
sparts
=
&
c
->
sparts
[
bucket_offset
[
k
]];
}
/* Re-link the gparts. */
if
(
scount
>
0
&&
gcount
>
0
)
part_relink_gparts_to_sparts
(
sparts
,
scount
,
sparts_offset
);
/* Finally, do the same song and dance for the gparts. */
for
(
int
k
=
0
;
k
<
8
;
k
++
)
bucket_count
[
k
]
=
0
;
...
...
@@ -1005,10 +1005,23 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
}
memswap
(
&
gparts
[
j
],
&
gpart
,
sizeof
(
struct
gpart
));
memswap
(
&
gbuff
[
j
],
&
temp_buff
,
sizeof
(
struct
cell_buff
));
if
(
gparts
[
j
].
type
==
swift_type_gas
)
{
parts
[
-
gparts
[
j
].
id_or_neg_offset
-
parts_offset
].
gpart
=
&
gparts
[
j
];
}
else
if
(
gparts
[
j
].
type
==
swift_type_star
)
{
sparts
[
-
gparts
[
j
].
id_or_neg_offset
-
sparts_offset
].
gpart
=
&
gparts
[
j
];
}
bid
=
temp_buff
.
ind
;
}
gparts
[
k
]
=
gpart
;
gbuff
[
k
]
=
temp_buff
;
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
parts
[
-
gparts
[
k
].
id_or_neg_offset
-
parts_offset
].
gpart
=
&
gparts
[
k
];
}
else
if
(
gparts
[
k
].
type
==
swift_type_star
)
{
sparts
[
-
gparts
[
k
].
id_or_neg_offset
-
sparts_offset
].
gpart
=
&
gparts
[
k
];
}
}
bucket_count
[
bid
]
++
;
}
...
...
@@ -1019,14 +1032,6 @@ void cell_split(struct cell *c, ptrdiff_t parts_offset, ptrdiff_t sparts_offset,
c
->
progeny
[
k
]
->
gcount
=
bucket_count
[
k
];
c
->
progeny
[
k
]
->
gparts
=
&
c
->
gparts
[
bucket_offset
[
k
]];
}
/* Re-link the parts. */
if
(
count
>
0
&&
gcount
>
0
)
part_relink_parts_to_gparts
(
gparts
,
gcount
,
parts
-
parts_offset
);
/* Re-link the sparts. */
if
(
scount
>
0
&&
gcount
>
0
)
part_relink_sparts_to_gparts
(
gparts
,
gcount
,
sparts
-
sparts_offset
);
}
/**
...
...
src/debug.c
View file @
647eceac
...
...
@@ -326,8 +326,7 @@ static void dumpCells_map(struct cell *c, void *data) {
/* So output local super cells that are active and have MPI
* tasks as requested. */
if
(
c
->
nodeID
==
e
->
nodeID
&&
(
!
super
||
(
super
&&
c
->
super
==
c
))
&&
active
&&
mpiactive
)
{
if
(
c
->
nodeID
==
e
->
nodeID
&&
(
!
super
||
((
super
&&
c
->
super
==
c
)
||
(
c
->
parent
==
NULL
)))
&&
active
&&
mpiactive
)
{
/* If requested we work out how many particles are active in this cell. */
int
pactcount
=
0
;
...
...
src/engine.c
View file @
647eceac
...
...
@@ -565,7 +565,8 @@ void engine_redistribute(struct engine *e) {
/* Sort the particles according to their cell index. */
if
(
s
->
nr_parts
>
0
)
space_parts_sort
(
s
,
dest
,
s
->
nr_parts
,
0
,
nr_nodes
-
1
,
e
->
verbose
);
space_parts_sort
(
s
->
parts
,
s
->
xparts
,
dest
,
&
counts
[
nodeID
*
nr_nodes
],
nr_nodes
,
0
);
#ifdef SWIFT_DEBUG_CHECKS
/* Verify that the part have been sorted correctly. */
...
...
@@ -656,7 +657,8 @@ void engine_redistribute(struct engine *e) {
/* Sort the particles according to their cell index. */
if
(
s
->
nr_sparts
>
0
)
space_sparts_sort
(
s
,
s_dest
,
s
->
nr_sparts
,
0
,
nr_nodes
-
1
,
e
->
verbose
);
space_sparts_sort
(
s
->
sparts
,
s_dest
,
&
s_counts
[
nodeID
*
nr_nodes
],
nr_nodes
,
0
);
#ifdef SWIFT_DEBUG_CHECKS
/* Verify that the spart have been sorted correctly. */
...
...
@@ -748,7 +750,8 @@ void engine_redistribute(struct engine *e) {
/* Sort the gparticles according to their cell index. */
if
(
s
->
nr_gparts
>
0
)
space_gparts_sort
(
s
,
g_dest
,
s
->
nr_gparts
,
0
,
nr_nodes
-
1
,
e
->
verbose
);
space_gparts_sort
(
s
->
gparts
,
s
->
parts
,
s
->
sparts
,
g_dest
,
&
g_counts
[
nodeID
*
nr_nodes
],
nr_nodes
);
#ifdef SWIFT_DEBUG_CHECKS
/* Verify that the gpart have been sorted correctly. */
...
...
@@ -3678,6 +3681,11 @@ void engine_rebuild(struct engine *e, int clean_smoothing_length_values) {
/* Re-build the space. */
space_rebuild
(
e
->
s
,
e
->
verbose
);
#ifdef SWIFT_DEBUG_CHECKS
part_verify_links
(
e
->
s
->
parts
,
e
->
s
->
gparts
,
e
->
s
->
sparts
,
e
->
s
->
nr_parts
,
e
->
s
->
nr_gparts
,
e
->
s
->
nr_sparts
,
e
->
verbose
);
#endif
/* Initial cleaning up session ? */
if
(
clean_smoothing_length_values
)
space_sanitize
(
e
->
s
);
...
...
@@ -4151,7 +4159,7 @@ void engine_first_init_particles(struct engine *e) {
const
ticks
tic
=
getticks
();
/* Set the particles in a state where they are ready for a run */
/* Set the particles in a state where they are ready for a run
.
*/
space_first_init_parts
(
e
->
s
,
e
->
chemistry
,
e
->
cooling_func
);
space_first_init_gparts
(
e
->
s
,
e
->
gravity_properties
);
space_first_init_sparts
(
e
->
s
);
...
...
src/part.c
View file @
647eceac
...
...
@@ -94,6 +94,26 @@ void part_relink_sparts_to_gparts(struct gpart *gparts, size_t N,
}
}
/**
* @brief Re-link both the #part%s and #spart%s associated with the list of
* #gpart%s.
*
* @param gparts The list of #gpart.
* @param N The number of particles to re-link;
* @param parts The global #part array in which to find the #gpart offsets.
* @param sparts The global #spart array in which to find the #gpart offsets.
*/
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
struct
part
*
parts
,
struct
spart
*
sparts
)
{
for
(
size_t
k
=
0
;
k
<
N
;
k
++
)
{
if
(
gparts
[
k
].
type
==
swift_type_gas
)
{
parts
[
-
gparts
[
k
].
id_or_neg_offset
].
gpart
=
&
gparts
[
k
];
}
else
if
(
gparts
[
k
].
type
==
swift_type_star
)
{
sparts
[
-
gparts
[
k
].
id_or_neg_offset
].
gpart
=
&
gparts
[
k
];
}
}
}
/**
* @brief Verifies that the #gpart, #part and #spart are correctly linked
* together
...
...
@@ -128,19 +148,19 @@ void part_verify_links(struct part *parts, struct gpart *gparts,
/* Check that it is linked */
if
(
gparts
[
k
].
id_or_neg_offset
>
0
)
error
(
"Gas gpart not linked to anything
!"
);
error
(
"Gas gpart not linked to anything!"
);
/* Find its link */
const
struct
part
*
part
=
&
parts
[
-
gparts
[
k
].
id_or_neg_offset
];
/* Check the reverse link */
if
(
part
->
gpart
!=
&
gparts
[
k
])
error
(
"Linking problem
!"
);
if
(
part
->
gpart
!=
&
gparts
[
k
])
error
(
"Linking problem!"
);
/* Check that the particles are at the same place */
if
(
gparts
[
k
].
x
[
0
]
!=
part
->
x
[
0
]
||
gparts
[
k
].
x
[
1
]
!=
part
->
x
[
1
]
||
gparts
[
k
].
x
[
2
]
!=
part
->
x
[
2
])
error
(
"Linked particles are not at the same position
!
\n
"
"Linked particles are not at the same position!
\n
"
"gp->x=[%e %e %e] p->x=[%e %e %e] diff=[%e %e %e]"
,
gparts
[
k
].
x
[
0
],
gparts
[
k
].
x
[
1
],
gparts
[
k
].
x
[
2
],
part
->
x
[
0
],
part
->
x
[
1
],
part
->
x
[
2
],
gparts
[
k
].
x
[
0
]
-
part
->
x
[
0
],
...
...
src/part.h
View file @
647eceac
...
...
@@ -80,6 +80,8 @@ void part_relink_parts_to_gparts(struct gpart *gparts, size_t N,
struct
part
*
parts
);
void
part_relink_sparts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
struct
spart
*
sparts
);
void
part_relink_all_parts_to_gparts
(
struct
gpart
*
gparts
,
size_t
N
,
struct
part
*
parts
,
struct
spart
*
sparts
);
void
part_verify_links
(
struct
part
*
parts
,
struct
gpart
*
gparts
,
struct
spart
*
sparts
,
size_t
nr_parts
,
size_t
nr_gparts
,
size_t
nr_sparts
,
int
verbose
);
...
...
src/space.c
View file @
647eceac
This diff is collapsed.
Click to expand it.
src/space.h
View file @
647eceac
...
...
@@ -173,12 +173,14 @@ struct space {
};
/* function prototypes. */
void
space_parts_sort
(
struct
space
*
s
,
int
*
ind
,
size_t
N
,
int
min
,
int
max
,
int
verbose
);
void
space_gparts_sort
(
struct
space
*
s
,
int
*
ind
,
size_t
N
,
int
min
,
int
max
,
int
verbose
);
void
space_sparts_sort
(
struct
space
*
s
,
int
*
ind
,
size_t
N
,
int
min
,
int
max
,
int
verbose
);
void
space_free_buff_sort_indices
(
struct
space
*
s
);
void
space_parts_sort
(
struct
part
*
parts
,
struct
xpart
*
xparts
,
int
*
ind
,
int
*
counts
,
int
num_bins
,
ptrdiff_t
parts_offset
);
void
space_gparts_sort
(
struct
gpart
*
gparts
,
struct
part
*
parts
,
struct
spart
*
sparts
,
int
*
ind
,
int
*
counts
,
int
num_bins
);
void
space_sparts_sort
(
struct
spart
*
sparts
,
int
*
ind
,
int
*
counts
,
int
num_bins
,
ptrdiff_t
sparts_offset
);
void
space_getcells
(
struct
space
*
s
,
int
nr_cells
,
struct
cell
**
cells
);
int
space_getsid
(
struct
space
*
s
,
struct
cell
**
ci
,
struct
cell
**
cj
,
double
*
shift
);
...
...
@@ -199,12 +201,6 @@ void space_map_parts_xparts(struct space *s,
struct
cell
*
c
));
void
space_map_cells_post
(
struct
space
*
s
,
int
full
,
void
(
*
fun
)(
struct
cell
*
c
,
void
*
data
),
void
*
data
);
void
space_parts_sort_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
);
void
space_gparts_sort_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
);
void
space_sparts_sort_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
);
void
space_rebuild
(
struct
space
*
s
,
int
verbose
);
void
space_recycle
(
struct
space
*
s
,
struct
cell
*
c
);
void
space_recycle_list
(
struct
space
*
s
,
struct
cell
*
cell_list_begin
,
...
...
@@ -215,12 +211,12 @@ void space_split(struct space *s, struct cell *cells, int nr_cells,
int
verbose
);
void
space_split_mapper
(
void
*
map_data
,
int
num_elements
,
void
*
extra_data
);
void
space_list_cells_with_tasks
(
struct
space
*
s
);
void
space_parts_get_cell_index
(
struct
space
*
s
,
int
*
ind
,
struct
cell
*
cell
s
,
int
verbose
);
void
space_gparts_get_cell_index
(
struct
space
*
s
,
int
*
gind
,
struct
cell
*
cell
s
,
int
verbose
);
void
space_sparts_get_cell_index
(
struct
space
*
s
,
int
*
sind
,
struct
cell
*
cell
s
,
int
verbose
);
void
space_parts_get_cell_index
(
struct
space
*
s
,
int
*
ind
,
int
*
cell_count
s
,
struct
cell
*
cells
,
int
verbose
);
void
space_gparts_get_cell_index
(
struct
space
*
s
,
int
*
gind
,
int
*
cell_count
s
,
struct
cell
*
cells
,
int
verbose
);
void
space_sparts_get_cell_index
(
struct
space
*
s
,
int
*
sind
,
int
*
cell_count
s
,
struct
cell
*
cells
,
int
verbose
);
void
space_synchronize_particle_positions
(
struct
space
*
s
);
void
space_do_parts_sort
();
void
space_do_gparts_sort
();
...
...
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