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

Add support for groupID i/o in DM-only runs on single nodes.

parent 21517ba2
No related branches found
No related tags found
2 merge requests!721Velociraptor outputs,!719Velociraptor output strategy
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "stars_io.h" #include "stars_io.h"
#include "tracers_io.h" #include "tracers_io.h"
#include "units.h" #include "units.h"
#include "velociraptor_io.h"
#include "xmf.h" #include "xmf.h"
/** /**
...@@ -646,6 +647,8 @@ void write_output_single(struct engine* e, const char* baseName, ...@@ -646,6 +647,8 @@ void write_output_single(struct engine* e, const char* baseName,
const struct spart* sparts = e->s->sparts; const struct spart* sparts = e->s->sparts;
struct swift_params* params = e->parameter_file; struct swift_params* params = e->parameter_file;
const int with_cosmology = e->policy & engine_policy_cosmology; const int with_cosmology = e->policy & engine_policy_cosmology;
const int with_stf = (e->policy & engine_policy_structure_finding) &&
(e->s->gpart_group_data != NULL);
const int with_cooling = e->policy & engine_policy_cooling; const int with_cooling = e->policy & engine_policy_cooling;
const int with_temperature = e->policy & engine_policy_temperature; const int with_temperature = e->policy & engine_policy_temperature;
...@@ -950,6 +953,11 @@ void write_output_single(struct engine* e, const char* baseName, ...@@ -950,6 +953,11 @@ void write_output_single(struct engine* e, const char* baseName,
/* This is a DM-only run without inhibited particles */ /* This is a DM-only run without inhibited particles */
N = Ntot; N = Ntot;
darkmatter_write_particles(gparts, list, &num_fields); darkmatter_write_particles(gparts, list, &num_fields);
if (with_stf) {
#ifdef HAVE_VELOCIRAPTOR
num_fields += velociraptor_write_gparts(gparts, list + num_fields);
#endif
}
} else { } else {
/* Ok, we need to fish out the particles we want */ /* Ok, we need to fish out the particles we want */
...@@ -965,6 +973,12 @@ void write_output_single(struct engine* e, const char* baseName, ...@@ -965,6 +973,12 @@ void write_output_single(struct engine* e, const char* baseName,
/* Write DM particles */ /* Write DM particles */
darkmatter_write_particles(gparts_written, list, &num_fields); darkmatter_write_particles(gparts_written, list, &num_fields);
if (with_stf) {
#ifdef HAVE_VELOCIRAPTOR
num_fields +=
velociraptor_write_gparts(gparts_written, list + num_fields);
#endif
}
} }
} break; } break;
... ...
......
...@@ -21,7 +21,13 @@ ...@@ -21,7 +21,13 @@
#include "part_type.h" #include "part_type.h"
/* SWIFT/VELOCIraptor particle. */ /**
* @brief SWIFT/VELOCIraptor particle.
*
* This should match the structure Swift::swift_vel_part
* defined in the file NBodylib/src/NBody/SwiftParticle.h
* of the VELOCIraptor code.
*/
struct swift_vel_part { struct swift_vel_part {
/*! Particle ID. */ /*! Particle ID. */
... ...
......
...@@ -532,7 +532,7 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) { ...@@ -532,7 +532,7 @@ void velociraptor_invoke(struct engine *e, const int linked_with_snap) {
struct velociraptor_gpart_data *data = s->gpart_group_data; struct velociraptor_gpart_data *data = s->gpart_group_data;
/* Zero the array (#gpart not in groups have an ID of 0) */ /* Zero the array (gparts not in groups have an ID of 0) */
bzero(data, nr_gparts * sizeof(struct velociraptor_gpart_data)); bzero(data, nr_gparts * sizeof(struct velociraptor_gpart_data));
/* Copy the data at the right place */ /* Copy the data at the right place */
... ...
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (c) 2019 Matthieu Schaller (schaller@strw.leidenuniv.nl)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#ifndef SWIFT_VELOCIRAPTOR_IO_H
#define SWIFT_VELOCIRAPTOR_IO_H
/* Config parameters. */
#include "../config.h"
INLINE static void velociraptor_convert_groupID(const struct engine* e,
const struct gpart* gp,
long long* ret) {
const ptrdiff_t offset = gp - e->s->gparts;
*ret = (e->s->gpart_group_data + offset)->groupID;
}
__attribute__((always_inline)) INLINE static int velociraptor_write_gparts(
const struct gpart* gparts, struct io_props* list) {
list[0] = io_make_output_field_convert_gpart("GroupID", LONGLONG, 1,
UNIT_CONV_NO_UNITS, gparts,
velociraptor_convert_groupID);
return 1;
}
#endif /* SWIFT_VELOCIRAPTOR_IO_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment