diff --git a/mytools/generateMock.cpp b/mytools/generateMock.cpp index 61796c3..453be5a 100644 --- a/mytools/generateMock.cpp +++ b/mytools/generateMock.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include "generateMock_conf.h" @@ -62,19 +63,24 @@ SimuData *doLoadRamses(const char *basename, int baseid, int velAxis, bool goRed return outd; } -SimuData *doLoadGadget(const char *gadgetname, int velAxis, bool goRedshift) +SimuData *myLoadGadget(const char *fname, int id, int flags) +{ + return loadGadgetMulti(fname, id, flags); +} + +SimuData *doLoadSimulation(const char *gadgetname, int velAxis, bool goRedshift, SimuData *(*loadFunction)(const char *fname, int id, int flags)) { SimuData *d, *outd; try { - d = loadGadgetMulti(gadgetname, -1, 0); + d = loadFunction(gadgetname, -1, 0); } catch (const NoSuchFileException& e) { try { - d = loadGadgetMulti(gadgetname, 0, 0); + d = loadFunction(gadgetname, 0, 0); } catch(const NoSuchFileException& e) { @@ -102,7 +108,7 @@ SimuData *doLoadGadget(const char *gadgetname, int velAxis, bool goRedshift) { while (1) { - d = loadGadgetMulti(gadgetname, curCpu, NEED_POSITION|NEED_VELOCITY|NEED_GADGET_ID); + d = loadFunction(gadgetname, curCpu, NEED_POSITION|NEED_VELOCITY|NEED_GADGET_ID); for (int k = 0; k < 3; k++) for (int i = 0; i < d->NumPart; i++) { @@ -128,6 +134,8 @@ SimuData *doLoadGadget(const char *gadgetname, int velAxis, bool goRedshift) return outd; } + + static double cubic(double a) { return a*a*a; @@ -420,9 +428,18 @@ int main(int argc, char **argv) return 1; } } - else if (args_info.gadget_given) + else if (args_info.gadget_given || args_info.flash_given) { - simu = doLoadGadget(args_info.gadget_arg, args_info.axis_arg, false); + if (args_info.gadget_given && args_info.flash_given) + { + cerr << "Do not know which file to use: Gadget or Flash ?" << endl; + return 1; + } + + if (args_info.gadget_given) + simu = doLoadSimulation(args_info.gadget_arg, args_info.axis_arg, false, myLoadGadget); + else + simu = doLoadSimulation(args_info.flash_arg, args_info.axis_arg, false, loadFlashMulti); if (simu == 0) { cerr << "Error while loading " << endl; diff --git a/mytools/generateMock.ggo b/mytools/generateMock.ggo index b455f70..d87abc0 100644 --- a/mytools/generateMock.ggo +++ b/mytools/generateMock.ggo @@ -8,6 +8,7 @@ option "ramsesBase" - "Base directory for ramses" string optional option "ramsesId" - "Ramses snapshot id" int optional option "gadget" - "Base name of gadget snapshot (without parallel writing extension)" string optional +option "flash" - "Base name for FLASH snapshot" string optional option "axis" - "Redshift axis (X=0, Y=1, Z=2)" int optional default="2"