Merge branch 'master' of /home/lavaux/Dropbox/gitRoot/zobovPerso

This commit is contained in:
Guilhem Lavaux 2011-06-06 09:36:54 -05:00
commit ed5c99b5d5
2 changed files with 24 additions and 6 deletions

View file

@ -6,6 +6,7 @@
#include <CosmoTool/loadSimu.hpp>
#include <CosmoTool/loadRamses.hpp>
#include <CosmoTool/loadGadget.hpp>
#include <CosmoTool/loadFlash.hpp>
#include <CosmoTool/interpolate.hpp>
#include <CosmoTool/fortran.hpp>
#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;

View file

@ -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"