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

Changed VELOCIraptor interface to pass output file name at invoke time instead...

Changed VELOCIraptor interface to pass output file name at invoke time instead of at initialisation.
parent 31846b13
Branches
Tags
1 merge request!578Swift velociraptor
......@@ -6,6 +6,14 @@ InternalUnitSystem:
UnitCurrent_in_cgs: 1 # Amperes
UnitTemp_in_cgs: 1 # Kelvin
# Structure finding on the fly options
StructureFinding:
config_file_name: stf_input.cfg
output_file_name: stf_output.out
output_time_format: 0
output_times: 100
# Define the system of units to use int VELOCIraptor.
VelociraptorUnitSystem:
UnitMass_in_cgs: 1.989e33 # M_sun in grams
......
......@@ -25,6 +25,10 @@
/* Config parameters. */
#include "../config.h"
#include <errno.h>
#include <libgen.h>
#include <unistd.h>
/* This object's header. */
#include "velociraptor_interface.h"
......@@ -106,44 +110,16 @@ void velociraptor_init(struct engine *e) {
s->nr_cells * sizeof(struct cell_loc)) != 0)
error("Failed to allocate top-level cell locations for VELOCIraptor.");
//double cell_loc_min[3] = {sim_info.spacedimension[0] - sim_info.cellwidth[0],
// sim_info.spacedimension[1] - sim_info.cellwidth[1],
// sim_info.spacedimension[2] - sim_info.cellwidth[2]};
//double cell_loc_max[3] = {0.0, 0.0, 0.0};
for(int i=0; i<s->nr_cells; i++) {
sim_info.cellloc[i].loc[0] = unit_info.lengthtokpc * s->cells_top[i].loc[0];
sim_info.cellloc[i].loc[1] = unit_info.lengthtokpc * s->cells_top[i].loc[1];
sim_info.cellloc[i].loc[2] = unit_info.lengthtokpc * s->cells_top[i].loc[2];
//for(int k=0; k<3; k++) {
// cell_loc_min[k] = min(cell_loc_min[k], sim_info.cellloc[i].loc[k]);
// cell_loc_max[k] = max(cell_loc_max[k], sim_info.cellloc[i].loc[k] + sim_info.cellwidth[k]);
//}
}
//FILE *file = NULL;
///* Name of output file. */
//char fname[200];
//sprintf(fname, "cell_locs_rank_%d.dat", e->nodeID);
//file = fopen(fname, "w");
///* Header. */
//fprintf(file, "# %6s %6s %6s %6s %6s %6s %6s\n", "x", "y", "z", "xw", "yw",
// "zw", "rank");
///* Output */
//for (int i = 0; i < s->nr_cells; i++) {
// struct cell *c = &s->cells_top[i];
// fprintf(file, " %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6d\n", sim_info.cellloc[i].loc[0] / unit_info.lengthtokpc,
// sim_info.cellloc[i].loc[1]/ unit_info.lengthtokpc, sim_info.cellloc[i].loc[2]/ unit_info.lengthtokpc, sim_info.cellwidth[0]/ unit_info.lengthtokpc, sim_info.cellwidth[1]/ unit_info.lengthtokpc, sim_info.cellwidth[2]/ unit_info.lengthtokpc,
// c->nodeID);
//}
//fclose(file);
char configfilename[PARSER_MAX_LINE_SIZE];
parser_get_param_string(e->parameter_file, "StructureFinding:config_file_name", configfilename);
message("Config file name: %s", configfilename);
message("Period: %e", sim_info.period);
message("Zoom high res mass: %e", sim_info.zoomhigresolutionmass);
message("Inter-particle spacing: %e", sim_info.interparticlespacing);
......@@ -153,7 +129,7 @@ void velociraptor_init(struct engine *e) {
//message("Local top-level cell locations range: (%e,%e,%e) -> (%e,%e,%e)", cell_loc_min[0], cell_loc_min[1], cell_loc_min[2], cell_loc_max[0], cell_loc_max[1], cell_loc_max[2]);
message("Top-level cell locations range: (%e,%e,%e) -> (%e,%e,%e)", sim_info.cellloc[0].loc[0], sim_info.cellloc[0].loc[1], sim_info.cellloc[0].loc[2], sim_info.cellloc[sim_info.numcells - 1].loc[0], sim_info.cellloc[sim_info.numcells - 1].loc[1], sim_info.cellloc[sim_info.numcells - 1].loc[2]);
InitVelociraptor("stf_input.cfg", "stf_output.out", cosmo_info, unit_info, sim_info);
InitVelociraptor(configfilename, cosmo_info, unit_info, sim_info);
/* Free cell locations after VELOCIraptor has copied them. */
//free(sim_info.cellloc);
......@@ -185,8 +161,19 @@ void velociraptor_invoke(struct engine *e) {
//for(int i=0; i<nr_gparts; i++) message("Potential: %f", gparts[i].potential);
InvokeVelociraptor(nr_gparts, gparts, cell_node_ids);
/* Check that we can write the snapshots by testing if the output
* directory exists and is searchable and writable. */
char outputfilename[PARSER_MAX_LINE_SIZE];
parser_get_param_string(e->parameter_file, "StructureFinding:output_file_name", outputfilename);
const char *dirp = dirname(outputfilename);
if (access(dirp, W_OK | X_OK) != 0) {
error("Cannot write snapshots in directory %s (%s)", dirp, strerror(errno));
}
message("Output file name: %s", outputfilename);
InvokeVelociraptor(nr_gparts, gparts, cell_node_ids, outputfilename);
/* Free cell node ids after VELOCIraptor has copied them. */
//free(cell_node_ids);
free(cell_node_ids);
}
......@@ -68,8 +68,8 @@ struct siminfo {
};
/* VELOCIraptor interface. */
void InitVelociraptor(char* config_name, char* output_name, struct cosmoinfo cosmo_info, struct unitinfo unit_info, struct siminfo sim_info);
void InvokeVelociraptor(const int num_gravity_parts, struct gpart *gravity_parts, const int *cell_node_ids);
void InitVelociraptor(char* config_name, struct cosmoinfo cosmo_info, struct unitinfo unit_info, struct siminfo sim_info);
void InvokeVelociraptor(const int num_gravity_parts, struct gpart *gravity_parts, const int *cell_node_ids, char* output_name);
/* VELOCIraptor wrapper functions. */
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