Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SWIFT
SWIFTsim
Commits
cc7872d5
Commit
cc7872d5
authored
2 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Plain Diff
Merge branch 'nu_replicate' into 'master'
Allow space replication and id remapping for neutrino particles Closes
#837
See merge request
!1673
parents
ffcea00e
276f35be
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!1715
Update planetary strength after planetary plus's master rebase
,
!1693
More threapool plotting tweaks
,
!1673
Allow space replication and id remapping for neutrino particles
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/RTD/source/ParameterFiles/parameter_description.rst
+8
-0
8 additions, 0 deletions
doc/RTD/source/ParameterFiles/parameter_description.rst
src/space.c
+26
-14
26 additions, 14 deletions
src/space.c
with
34 additions
and
14 deletions
doc/RTD/source/ParameterFiles/parameter_description.rst
+
8
−
0
View file @
cc7872d5
...
@@ -706,6 +706,14 @@ creation of a compact range of IDs beyond which the new IDs generated by
...
@@ -706,6 +706,14 @@ creation of a compact range of IDs beyond which the new IDs generated by
splitting can be safely drawn from. Note that, when ``remap_ids`` is
splitting can be safely drawn from. Note that, when ``remap_ids`` is
switched on the ICs do not need to contain a ``ParticleIDs`` field.
switched on the ICs do not need to contain a ``ParticleIDs`` field.
Both replication and remapping explicitly overwrite any particle IDs
provided in the initial conditions. This may cause problems for runs
with neutrino particles, as some models assume that that the particle
ID was used as a random seed for the Fermi-Dirac momentum. In this case,
the ``Neutrino:generate_ics`` option can be used to generate new initial
conditions based on the replicated or remapped IDs. See :ref:`Neutrinos`
for details.
* Name of a HDF5 group to copy from the ICs file(s): ``metadata_group_name`` (default: ``ICs_parameters``)
* Name of a HDF5 group to copy from the ICs file(s): ``metadata_group_name`` (default: ``ICs_parameters``)
If the initial conditions generator writes a HDF5 group with the parameters
If the initial conditions generator writes a HDF5 group with the parameters
...
...
This diff is collapsed.
Click to expand it.
src/space.c
+
26
−
14
View file @
cc7872d5
...
@@ -1129,8 +1129,6 @@ void space_init(struct space *s, struct swift_params *params,
...
@@ -1129,8 +1129,6 @@ void space_init(struct space *s, struct swift_params *params,
if
(
replicate
>
1
)
{
if
(
replicate
>
1
)
{
if
(
with_DM_background
)
if
(
with_DM_background
)
error
(
"Can't replicate the space if background DM particles are in use."
);
error
(
"Can't replicate the space if background DM particles are in use."
);
if
(
neutrinos
)
error
(
"Can't replicate the space if neutrino DM particles are in use."
);
space_replicate
(
s
,
replicate
,
verbose
);
space_replicate
(
s
,
replicate
,
verbose
);
parts
=
s
->
parts
;
parts
=
s
->
parts
;
...
@@ -1439,6 +1437,7 @@ void space_replicate(struct space *s, int replicate, int verbose) {
...
@@ -1439,6 +1437,7 @@ void space_replicate(struct space *s, int replicate, int verbose) {
const
size_t
nr_sparts
=
s
->
nr_sparts
;
const
size_t
nr_sparts
=
s
->
nr_sparts
;
const
size_t
nr_bparts
=
s
->
nr_bparts
;
const
size_t
nr_bparts
=
s
->
nr_bparts
;
const
size_t
nr_sinks
=
s
->
nr_sinks
;
const
size_t
nr_sinks
=
s
->
nr_sinks
;
const
size_t
nr_nuparts
=
s
->
nr_nuparts
;
const
size_t
nr_dm
=
nr_gparts
-
nr_parts
-
nr_sparts
-
nr_bparts
;
const
size_t
nr_dm
=
nr_gparts
-
nr_parts
-
nr_sparts
-
nr_bparts
;
s
->
size_parts
=
s
->
nr_parts
=
nr_parts
*
factor
;
s
->
size_parts
=
s
->
nr_parts
=
nr_parts
*
factor
;
...
@@ -1446,6 +1445,7 @@ void space_replicate(struct space *s, int replicate, int verbose) {
...
@@ -1446,6 +1445,7 @@ void space_replicate(struct space *s, int replicate, int verbose) {
s
->
size_sparts
=
s
->
nr_sparts
=
nr_sparts
*
factor
;
s
->
size_sparts
=
s
->
nr_sparts
=
nr_sparts
*
factor
;
s
->
size_bparts
=
s
->
nr_bparts
=
nr_bparts
*
factor
;
s
->
size_bparts
=
s
->
nr_bparts
=
nr_bparts
*
factor
;
s
->
size_sinks
=
s
->
nr_sinks
=
nr_sinks
*
factor
;
s
->
size_sinks
=
s
->
nr_sinks
=
nr_sinks
*
factor
;
s
->
nr_nuparts
=
nr_nuparts
*
factor
;
/* Allocate space for new particles */
/* Allocate space for new particles */
struct
part
*
parts
=
NULL
;
struct
part
*
parts
=
NULL
;
...
@@ -1605,10 +1605,10 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1605,10 +1605,10 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
if
(
verbose
)
message
(
"Remapping all the IDs"
);
if
(
verbose
)
message
(
"Remapping all the IDs"
);
size_t
local_nr_dm_background
=
0
;
size_t
local_nr_dm_background
=
0
;
size_t
local_nr_n
eutrino
=
0
;
size_t
local_nr_n
uparts
=
0
;
for
(
size_t
i
=
0
;
i
<
s
->
nr_gparts
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
s
->
nr_gparts
;
++
i
)
{
if
(
s
->
gparts
[
i
].
type
==
swift_type_neutrino
)
if
(
s
->
gparts
[
i
].
type
==
swift_type_neutrino
)
local_nr_n
eutrino
++
;
local_nr_n
uparts
++
;
else
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter_background
)
else
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter_background
)
local_nr_dm_background
++
;
local_nr_dm_background
++
;
}
}
...
@@ -1621,10 +1621,10 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1621,10 +1621,10 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
const
size_t
local_nr_bparts
=
s
->
nr_bparts
;
const
size_t
local_nr_bparts
=
s
->
nr_bparts
;
const
size_t
local_nr_baryons
=
const
size_t
local_nr_baryons
=
local_nr_parts
+
local_nr_sinks
+
local_nr_sparts
+
local_nr_bparts
;
local_nr_parts
+
local_nr_sinks
+
local_nr_sparts
+
local_nr_bparts
;
const
size_t
local_nr_dm
=
const
size_t
local_nr_dm
=
local_nr_gparts
>
0
local_nr_gparts
>
0
?
local_nr_gparts
-
local_nr_baryons
-
?
local_nr_gparts
-
local_nr_baryons
-
local_nr_n
eutrino
-
local_nr_dm_background
local_nr_n
uparts
-
local_nr_dm_background
:
0
;
:
0
;
/* Get the global offsets */
/* Get the global offsets */
long
long
offset_parts
=
0
;
long
long
offset_parts
=
0
;
...
@@ -1633,6 +1633,7 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1633,6 +1633,7 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
long
long
offset_bparts
=
0
;
long
long
offset_bparts
=
0
;
long
long
offset_dm
=
0
;
long
long
offset_dm
=
0
;
long
long
offset_dm_background
=
0
;
long
long
offset_dm_background
=
0
;
long
long
offset_nuparts
=
0
;
#ifdef WITH_MPI
#ifdef WITH_MPI
MPI_Exscan
(
&
local_nr_parts
,
&
offset_parts
,
1
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_Exscan
(
&
local_nr_parts
,
&
offset_parts
,
1
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_COMM_WORLD
);
...
@@ -1646,6 +1647,8 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1646,6 +1647,8 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
MPI_COMM_WORLD
);
MPI_COMM_WORLD
);
MPI_Exscan
(
&
local_nr_dm_background
,
&
offset_dm_background
,
1
,
MPI_Exscan
(
&
local_nr_dm_background
,
&
offset_dm_background
,
1
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Exscan
(
&
local_nr_nuparts
,
&
offset_nuparts
,
1
,
MPI_LONG_LONG_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
#endif
#endif
/* Total number of particles of each kind */
/* Total number of particles of each kind */
...
@@ -1654,6 +1657,7 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1654,6 +1657,7 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
long
long
total_sinks
=
offset_sinks
+
local_nr_sinks
;
long
long
total_sinks
=
offset_sinks
+
local_nr_sinks
;
long
long
total_sparts
=
offset_sparts
+
local_nr_sparts
;
long
long
total_sparts
=
offset_sparts
+
local_nr_sparts
;
long
long
total_bparts
=
offset_bparts
+
local_nr_bparts
;
long
long
total_bparts
=
offset_bparts
+
local_nr_bparts
;
long
long
total_nuparts
=
offset_nuparts
+
local_nr_nuparts
;
// long long total_dm_backgroud = offset_dm_background +
// long long total_dm_backgroud = offset_dm_background +
// local_nr_dm_background;
// local_nr_dm_background;
...
@@ -1664,22 +1668,26 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1664,22 +1668,26 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
MPI_Bcast
(
&
total_sinks
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_sinks
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_sparts
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_sparts
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_bparts
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_bparts
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
MPI_Bcast
(
&
total_nuparts
,
1
,
MPI_LONG_LONG_INT
,
nr_nodes
-
1
,
MPI_COMM_WORLD
);
// MPI_Bcast(&total_dm_background, 1, MPI_LONG_LONG_INT, nr_nodes - 1,
// MPI_Bcast(&total_dm_background, 1, MPI_LONG_LONG_INT, nr_nodes - 1,
// MPI_COMM_WORLD);
// MPI_COMM_WORLD);
#endif
#endif
/* Let's order the particles
/* Let's order the particles
* IDs will be DM then gas then sinks than stars then BHs then
DM background
* IDs will be DM then gas then sinks than stars then BHs then
nus then
* Note that we leave a large gap (10x the number of particles)
in-between the
*
DM background.
Note that we leave a large gap (10x the number of particles)
* regular particles and the background ones. This allow for
particle
*
in-between the
regular particles and the background ones. This allow for
* splitting to keep a compact set of ids. */
*
particle
splitting to keep a compact set of ids. */
offset_dm
+=
1
;
offset_dm
+=
1
;
offset_parts
+=
1
+
total_dm
;
offset_parts
+=
1
+
total_dm
;
offset_sinks
+=
1
+
total_dm
+
total_parts
;
offset_sinks
+=
1
+
total_dm
+
total_parts
;
offset_sparts
+=
1
+
total_dm
+
total_parts
+
total_sinks
;
offset_sparts
+=
1
+
total_dm
+
total_parts
+
total_sinks
;
offset_bparts
+=
1
+
total_dm
+
total_parts
+
total_sinks
+
total_sparts
;
offset_bparts
+=
1
+
total_dm
+
total_parts
+
total_sinks
+
total_sparts
;
offset_dm_background
+=
1
+
10
*
(
total_dm
*
total_parts
+
total_sinks
+
offset_nuparts
+=
total_sparts
+
total_bparts
);
1
+
total_dm
+
total_parts
+
total_sinks
+
total_sparts
+
total_bparts
;
offset_dm_background
+=
1
+
10
*
(
total_dm
*
total_parts
+
total_sinks
+
total_sparts
+
total_bparts
+
total_nuparts
);
/* We can now remap the IDs in the range [offset offset + local_nr] */
/* We can now remap the IDs in the range [offset offset + local_nr] */
for
(
size_t
i
=
0
;
i
<
local_nr_parts
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
local_nr_parts
;
++
i
)
{
...
@@ -1696,10 +1704,14 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
...
@@ -1696,10 +1704,14 @@ void space_remap_ids(struct space *s, int nr_nodes, int verbose) {
}
}
size_t
count_dm
=
0
;
size_t
count_dm
=
0
;
size_t
count_dm_background
=
0
;
size_t
count_dm_background
=
0
;
size_t
count_nu
=
0
;
for
(
size_t
i
=
0
;
i
<
s
->
nr_gparts
;
++
i
)
{
for
(
size_t
i
=
0
;
i
<
s
->
nr_gparts
;
++
i
)
{
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter
)
{
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter
)
{
s
->
gparts
[
i
].
id_or_neg_offset
=
offset_dm
+
count_dm
;
s
->
gparts
[
i
].
id_or_neg_offset
=
offset_dm
+
count_dm
;
count_dm
++
;
count_dm
++
;
}
else
if
(
s
->
gparts
[
i
].
type
==
swift_type_neutrino
)
{
s
->
gparts
[
i
].
id_or_neg_offset
=
offset_nuparts
+
count_nu
;
count_nu
++
;
}
else
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter_background
)
{
}
else
if
(
s
->
gparts
[
i
].
type
==
swift_type_dark_matter_background
)
{
s
->
gparts
[
i
].
id_or_neg_offset
=
s
->
gparts
[
i
].
id_or_neg_offset
=
offset_dm_background
+
count_dm_background
;
offset_dm_background
+
count_dm_background
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment