Skip to content
Snippets Groups Projects
Commit 37de2088 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Update the FOF code for the new function signatures.

parent ba2d16f3
No related branches found
No related tags found
1 merge request!884Support for multiple softening lengths in the gravity solver
...@@ -428,28 +428,31 @@ int main(int argc, char *argv[]) { ...@@ -428,28 +428,31 @@ int main(int argc, char *argv[]) {
/* Get ready to read particles of all kinds */ /* Get ready to read particles of all kinds */
int flag_entropy_ICs = 0; int flag_entropy_ICs = 0;
size_t Ngas = 0, Ngpart = 0, Nspart = 0, Nbpart = 0; size_t Ngas = 0, Ngpart = 0, Ngpart_background = 0, Nspart = 0, Nbpart = 0;
double dim[3] = {0., 0., 0.}; double dim[3] = {0., 0., 0.};
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
#if defined(HAVE_HDF5) #if defined(HAVE_HDF5)
#if defined(WITH_MPI) #if defined(WITH_MPI)
#if defined(HAVE_PARALLEL_HDF5) #if defined(HAVE_PARALLEL_HDF5)
read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts, read_ic_parallel(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts,
&Ngas, &Ngpart, &Nspart, &Nbpart, &flag_entropy_ICs, &Ngas, &Ngpart, &Ngpart_background, &Nspart, &Nbpart,
with_hydro, /*with_grav=*/1, with_stars, with_black_holes, &flag_entropy_ICs, with_hydro, /*with_grav=*/1, with_stars,
cleanup_h, cleanup_sqrt_a, cosmo.h, cosmo.a, myrank, with_black_holes, cleanup_h, cleanup_sqrt_a, cosmo.h,
nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL, nr_threads, cosmo.a, myrank, nr_nodes, MPI_COMM_WORLD, MPI_INFO_NULL,
nr_threads,
/*dry_run=*/0); /*dry_run=*/0);
#else #else
read_ic_serial(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts, &Ngas, read_ic_serial(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts, &Ngas,
&Ngpart, &Nspart, &Nbpart, &flag_entropy_ICs, with_hydro, &Ngpart, &Ngpart_background, &Nspart, &Nbpart,
&flag_entropy_ICs, with_hydro,
/*with_grav=*/1, with_stars, with_black_holes, cleanup_h, /*with_grav=*/1, with_stars, with_black_holes, cleanup_h,
cleanup_sqrt_a, cosmo.h, cosmo.a, myrank, nr_nodes, cleanup_sqrt_a, cosmo.h, cosmo.a, myrank, nr_nodes,
MPI_COMM_WORLD, MPI_INFO_NULL, nr_threads, /*dry_run=*/0); MPI_COMM_WORLD, MPI_INFO_NULL, nr_threads, /*dry_run=*/0);
#endif #endif
#else #else
read_ic_single(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts, &Ngas, read_ic_single(ICfileName, &us, dim, &parts, &gparts, &sparts, &bparts, &Ngas,
&Ngpart, &Nspart, &Nbpart, &flag_entropy_ICs, with_hydro, &Ngpart, &Ngpart_background, &Nspart, &Nbpart,
&flag_entropy_ICs, with_hydro,
/*with_grav=*/1, with_stars, with_black_holes, cleanup_h, /*with_grav=*/1, with_stars, with_black_holes, cleanup_h,
cleanup_sqrt_a, cosmo.h, cosmo.a, nr_threads, /*dry_run=*/0); cleanup_sqrt_a, cosmo.h, cosmo.a, nr_threads, /*dry_run=*/0);
#endif #endif
...@@ -468,30 +471,46 @@ int main(int argc, char *argv[]) { ...@@ -468,30 +471,46 @@ int main(int argc, char *argv[]) {
#endif #endif
/* Get the total number of particles across all nodes. */ /* Get the total number of particles across all nodes. */
long long N_total[4] = {0, 0, 0}; long long N_total[swift_type_count + 1] = {0};
const long long Nbaryons = Ngas + Nspart + Nbpart;
#if defined(WITH_MPI) #if defined(WITH_MPI)
long long N_long[4] = {Ngas, Ngpart, Nspart, Nbpart}; long long N_long[swift_type_count + 1] = {0};
MPI_Allreduce(&N_long, &N_total, 4, MPI_LONG_LONG_INT, MPI_SUM, N_long[swift_type_gas] = Ngas;
MPI_COMM_WORLD); N_long[swift_type_dark_matter] = Ngpart - Ngpart_background - Nbaryons;
N_long[swift_type_dark_matter_background] = Ngpart_background;
N_long[swift_type_stars] = Nspart;
N_long[swift_type_black_hole] = Nbpart;
N_long[swift_type_count] = Ngpart;
MPI_Allreduce(&N_long, &N_total, swift_type_count + 1, MPI_LONG_LONG_INT,
MPI_SUM, MPI_COMM_WORLD);
#else #else
N_total[0] = Ngas; N_total[swift_type_gas] = Ngas;
N_total[1] = Ngpart; N_total[swift_type_dark_matter] = Ngpart - Ngpart_background - Nbaryons;
N_total[2] = Nspart; N_total[swift_type_dark_matter_background] = Ngpart_background;
N_total[3] = Nbpart; N_total[swift_type_stars] = Nspart;
N_total[swift_type_black_hole] = Nbpart;
N_total[swift_type_count] = Ngpart;
#endif #endif
if (myrank == 0) if (myrank == 0)
message( message(
"Read %lld gas particles, %lld stars particles, %lld black hole " "Read %lld gas particles, %lld stars particles, %lld black hole "
"particles and %lld gparts from the ICs.", "particles, %lld DM particles and %lld DM background particles from "
N_total[0], N_total[2], N_total[3], N_total[1]); "the ICs.",
N_total[swift_type_gas], N_total[swift_type_stars],
N_total[swift_type_black_hole], N_total[swift_type_dark_matter],
N_total[swift_type_dark_matter_background]);
/* Do we have background DM particles? */
const int with_DM_background_particles =
N_total[swift_type_dark_matter_background] > 0;
/* Initialize the space with these data. */ /* Initialize the space with these data. */
if (myrank == 0) clocks_gettime(&tic); if (myrank == 0) clocks_gettime(&tic);
space_init(&s, params, &cosmo, dim, parts, gparts, sparts, bparts, Ngas, space_init(&s, params, &cosmo, dim, parts, gparts, sparts, bparts, Ngas,
Ngpart, Nspart, Nbpart, periodic, replicate, Ngpart, Nspart, Nbpart, periodic, replicate,
/*generate_gas_in_ics=*/0, /*hydro=*/N_total[0] > 0, /*gravity=*/1, /*generate_gas_in_ics=*/0, /*hydro=*/N_total[0] > 0, /*gravity=*/1,
/*with_star_formation=*/0, talking, /*with_star_formation=*/0, with_DM_background_particles, talking,
/*dry_run=*/0); /*dry_run=*/0);
if (myrank == 0) { if (myrank == 0) {
......
...@@ -1956,12 +1956,12 @@ void fof_dump_group_data(const struct fof_props *props, ...@@ -1956,12 +1956,12 @@ void fof_dump_group_data(const struct fof_props *props,
: -1; : -1;
#ifdef WITH_MPI #ifdef WITH_MPI
fprintf(file, " %8zu %12zu %12e %12e %18lld %18lld\n", fprintf(file, " %8zu %12zu %12e %12e %18lld %18lld\n",
gparts[group_offset - node_offset].fof_data.group_id, (size_t)gparts[group_offset - node_offset].fof_data.group_id,
group_size[group_offset - node_offset], group_mass[i], group_size[group_offset - node_offset], group_mass[i],
max_part_density[i], max_part_density_index[i], part_id); max_part_density[i], max_part_density_index[i], part_id);
#else #else
fprintf(file, " %8zu %12zu %12e %12e %18lld %18lld\n", fprintf(file, " %8zu %12zu %12e %12e %18lld %18lld\n",
gparts[group_offset].fof_data.group_id, group_size[group_offset], (size_t)gparts[group_offset].fof_data.group_id, group_size[group_offset],
group_mass[i], max_part_density[i], max_part_density_index[i], group_mass[i], max_part_density[i], max_part_density_index[i],
part_id); part_id);
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment