Skip to content
Snippets Groups Projects
Commit 53b89471 authored by James Willis's avatar James Willis
Browse files

Pass the hydro particles to VELOCIraptor to set the PID of gas particles....

Pass the hydro particles to VELOCIraptor to set the PID of gas particles. Calculate the internal energies of hydro particles and pass them to VELOCIraptor.
parent d76a00ab
No related branches found
No related tags found
1 merge request!578Swift velociraptor
...@@ -151,10 +151,12 @@ void velociraptor_invoke(struct engine *e) { ...@@ -151,10 +151,12 @@ void velociraptor_invoke(struct engine *e) {
struct space *s = e->s; struct space *s = e->s;
struct gpart *gparts = s->gparts; struct gpart *gparts = s->gparts;
struct part *parts = s->parts;
const size_t nr_gparts = s->nr_gparts; const size_t nr_gparts = s->nr_gparts;
const size_t nr_hydro_parts = s->nr_parts; const size_t nr_hydro_parts = s->nr_parts;
const int nr_cells = s->nr_cells; const int nr_cells = s->nr_cells;
int *cell_node_ids; int *cell_node_ids;
float *internal_energies;
/* Allow thread to run on any core for the duration of the call to VELOCIraptor so that /* Allow thread to run on any core for the duration of the call to VELOCIraptor so that
* when OpenMP threads are spawned they can run on any core on the processor. */ * when OpenMP threads are spawned they can run on any core on the processor. */
...@@ -172,14 +174,20 @@ void velociraptor_invoke(struct engine *e) { ...@@ -172,14 +174,20 @@ void velociraptor_invoke(struct engine *e) {
ticks tic = getticks(); ticks tic = getticks();
/* Allocate and populate array of cell node IDs. */ /* Allocate and populate array of cell node IDs. */
/* JSW TODO: Remember to free at the end of the simulation. */
if (posix_memalign((void **)&cell_node_ids, 32, if (posix_memalign((void **)&cell_node_ids, 32,
nr_cells * sizeof(int)) != 0) nr_cells * sizeof(int)) != 0)
error("Failed to allocate list of cells node IDs for VELOCIraptor."); error("Failed to allocate list of cells node IDs for VELOCIraptor.");
for(int i=0; i<nr_cells; i++) cell_node_ids[i] = s->cells_top[i].nodeID; for(int i=0; i<nr_cells; i++) cell_node_ids[i] = s->cells_top[i].nodeID;
message("MPI rank %d sending %d gparts to VELOCIraptor.", e->nodeID, nr_gparts); /* Calculate and store the internal energies of gas particles and pass them to VELOCIraptor. */
if (posix_memalign((void **)&internal_energies, 32,
nr_hydro_parts * sizeof(float)) != 0)
error("Failed to allocate array of internal energies for VELOCIraptor.");
for(int i=0; i<nr_hydro_parts; i++) internal_energies[i] = hydro_get_physical_internal_energy(&parts[i], e->cosmology);
message("MPI rank %d sending %lld gparts to VELOCIraptor.", e->nodeID, nr_gparts);
//for(int i=0; i<nr_gparts; i++) message("Potential: %f", gparts[i].potential); //for(int i=0; i<nr_gparts; i++) message("Potential: %f", gparts[i].potential);
...@@ -194,7 +202,7 @@ void velociraptor_invoke(struct engine *e) { ...@@ -194,7 +202,7 @@ void velociraptor_invoke(struct engine *e) {
e->time); e->time);
} }
if(!InvokeVelociraptor(nr_gparts, nr_hydro_parts, gparts, cell_node_ids, outputFileName)) error("Exiting. Call to VELOCIraptor failed."); if(!InvokeVelociraptor(nr_gparts, nr_hydro_parts, gparts, parts, internal_energies, cell_node_ids, outputFileName)) error("Exiting. Call to VELOCIraptor failed.");
/* Reset the pthread affinity mask after VELOCIraptor returns. */ /* Reset the pthread affinity mask after VELOCIraptor returns. */
pthread_setaffinity_np(thread, sizeof(cpu_set_t), engine_entry_affinity()); pthread_setaffinity_np(thread, sizeof(cpu_set_t), engine_entry_affinity());
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
/* Includes. */ /* Includes. */
#include "engine.h" #include "engine.h"
#include "hydro.h"
/* Structure for passing cosmological information to VELOCIraptor. */ /* Structure for passing cosmological information to VELOCIraptor. */
struct cosmoinfo { struct cosmoinfo {
...@@ -69,7 +70,7 @@ struct siminfo { ...@@ -69,7 +70,7 @@ struct siminfo {
/* VELOCIraptor interface. */ /* VELOCIraptor interface. */
int InitVelociraptor(char* config_name, char* output_name, struct cosmoinfo cosmo_info, struct unitinfo unit_info, struct siminfo sim_info); int InitVelociraptor(char* config_name, char* output_name, struct cosmoinfo cosmo_info, struct unitinfo unit_info, struct siminfo sim_info);
int InvokeVelociraptor(const size_t num_gravity_parts, const size_t num_hydro_parts, struct gpart *gravity_parts, const int *cell_node_ids, char* output_name); int InvokeVelociraptor(const size_t num_gravity_parts, const size_t num_hydro_parts, struct gpart *gravity_parts, struct part *hydro_parts, const float *internal_energies, const int *cell_node_ids, char* output_name);
/* VELOCIraptor wrapper functions. */ /* VELOCIraptor wrapper functions. */
void velociraptor_init(struct engine *e); void velociraptor_init(struct engine *e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment