diff --git a/configure.ac b/configure.ac index 746270fbf2dd5dd950b4109290faccc3a5606e41..73e71b8855d549f1219e39ee28cd007f91a26e85 100644 --- a/configure.ac +++ b/configure.ac @@ -1220,6 +1220,17 @@ fi AC_SUBST([VELOCIRAPTOR_LIBS]) AM_CONDITIONAL([HAVEVELOCIRAPTOR],[test -n "$VELOCIRAPTOR_LIBS"]) +# Now that we found VELOCIraptor, let's check how it was compiled. +if test "$have_velociraptor" == "yes"; then + AC_CHECK_LIB( + [velociraptor], + [VR_NOMASS], + [AC_DEFINE([HAVE_VELOCIRAPTOR_WITH_NOMASS],1,[The VELOCIraptor library has been compiled with the NOMASS option. Only useful if running a uniform box.])], + [AC_MSG_RESULT(VELOCIraptor not compiled to so as to *not* store masses per particle.)], + [$VELOCIRAPTOR_LIBS $HDF5_LDFLAGS $HDF5_LIBS $GSL_LIBS] + ) +fi + # Check for dummy VELOCIraptor. AC_ARG_ENABLE([dummy-velociraptor], [AS_HELP_STRING([--enable-dummy-velociraptor], diff --git a/src/swift_velociraptor_part.h b/src/swift_velociraptor_part.h index 700842ac5a13e5bee4af15cc0d8726fc668ce421..d499cedebf98b06df14e259882b286b859bd7d04 100644 --- a/src/swift_velociraptor_part.h +++ b/src/swift_velociraptor_part.h @@ -39,8 +39,10 @@ struct swift_vel_part { /*! Particle velocity. */ float v[3]; +#ifndef HAVE_VELOCIRAPTOR_WITH_NOMASS /*! Particle mass. */ float mass; +#endif /*! Gravitational potential */ float potential; diff --git a/src/velociraptor_interface.c b/src/velociraptor_interface.c index 1d6b8c95d5202cf00931b23617bf7e442ffc7e40..653b437df534032be46f0bbab135cb87c1c5cea5 100644 --- a/src/velociraptor_interface.c +++ b/src/velociraptor_interface.c @@ -42,6 +42,9 @@ /** * @brief Structure for passing cosmological information to VELOCIraptor. + * + * This should match the structure cosmoinfo in the file src/swiftinterface.h + * in the VELOCIraptor code. */ struct cosmoinfo { @@ -78,6 +81,9 @@ struct cosmoinfo { /** * @brief Structure for passing unit information to VELOCIraptor. + * + * This should match the structure unitinfo in the file src/swiftinterface.h + * in the VELOCIraptor code. */ struct unitinfo { @@ -112,6 +118,9 @@ struct cell_loc { /** * @brief Structure for passing simulation information to VELOCIraptor for a * given call. + * + * This should match the structure siminfo in the file src/swiftinterface.h + * in the VELOCIraptor code. */ struct siminfo { @@ -130,6 +139,9 @@ struct siminfo { /*! Number of top-level cells. */ int numcells; + /*! Number of top-level cells. */ + int numcellsperdim; + /*! Locations of top-level cells. */ struct cell_loc *cell_loc; @@ -162,6 +174,11 @@ struct siminfo { /*! Do we have other particles? */ int iother; + +#ifdef HAVE_VELOCIRAPTOR_WITH_NOMASS + /*! Mass of the DM particles */ + double mass_uniform_box; +#endif }; /** @@ -248,7 +265,10 @@ void velociraptor_convert_particles_mapper(void *map_data, int nr_gparts, swift_parts[i].v[1] = gparts[i].v_full[1] * a_inv; swift_parts[i].v[2] = gparts[i].v_full[2] * a_inv; +#ifndef HAVE_VELOCIRAPTOR_WITH_NOMASS swift_parts[i].mass = gravity_get_mass(&gparts[i]); +#endif + swift_parts[i].potential = gravity_get_comoving_potential(&gparts[i]); swift_parts[i].type = gparts[i].type; @@ -516,6 +536,20 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) { sim_info.interparticlespacing = -1.; } +#ifdef HAVE_VELOCIRAPTOR_WITH_NOMASS + /* Assume all particles have the same mass */ + double DM_mass = 0.; + for (size_t i = 0; i < e->s->nr_gparts; ++i) { + const struct gpart *gp = &e->s->gparts[i]; + if (gp->time_bin != time_bin_inhibited && + gp->time_bin != time_bin_not_created) { + DM_mass = gp->mass; + break; + } + } + sim_info.mass_uniform_box = DM_mass; +#endif + /* Set the spatial extent of the simulation volume */ sim_info.spacedimension[0] = s->dim[0]; sim_info.spacedimension[1] = s->dim[1]; @@ -523,6 +557,9 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) { /* Store number of top-level cells */ sim_info.numcells = s->nr_cells; + sim_info.numcells = s->cdim[0]; /* We assume a cubic box! */ + if (s->cdim[0] != s->cdim[1] || s->cdim[0] != s->cdim[2]) + error("Trying to run VR on a non-cubic number of top-level cells"); /* Size and inverse size of the top-level cells in VELOCIraptor units */ sim_info.cellwidth[0] = s->cells_top[0].width[0];