mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 15:21:11 +00:00
Possibility to dump/retrieve tree on disk. Dump voids particle positions correctly
This commit is contained in:
parent
3088bb5733
commit
8bf13dfb8b
4 changed files with 168 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
File autogenerated by gengetopt version 2.22
|
File autogenerated by gengetopt version 2.22.2
|
||||||
generated with the following command:
|
generated with the following command:
|
||||||
gengetopt -i buildObservedVoids.ggo -f buildObservedVoids_conf -a buildObservedVoids_info -F buildObservedVoids_conf -C
|
gengetopt -i buildObservedVoids.ggo -f buildObservedVoids_conf -a buildObservedVoids_info -F buildObservedVoids_conf -C
|
||||||
|
|
||||||
|
@ -17,6 +17,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifndef FIX_UNUSED
|
||||||
|
#define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
#include "buildObservedVoids_conf.h"
|
#include "buildObservedVoids_conf.h"
|
||||||
|
@ -40,8 +44,11 @@ const char *buildObservedVoids_info_help[] = {
|
||||||
" -g, --gridOutput=STRING 3d grid output of voids \n (default=`all_voids.nc')",
|
" -g, --gridOutput=STRING 3d grid output of voids \n (default=`all_voids.nc')",
|
||||||
" -q, --quiet Quiet output (default=off)",
|
" -q, --quiet Quiet output (default=off)",
|
||||||
" --dumpVoids=STRING Dump the particles in void in a file",
|
" --dumpVoids=STRING Dump the particles in void in a file",
|
||||||
|
" --dumpIds Dump particle ids (default=off)",
|
||||||
" --ramsesBase=STRING Base directory for ramses",
|
" --ramsesBase=STRING Base directory for ramses",
|
||||||
" --ramsesId=INT Ramses snapshot id",
|
" --ramsesId=INT Ramses snapshot id",
|
||||||
|
" --dumpTree Dump the void tree (default=off)",
|
||||||
|
" --getTree Restore tree from file (default=off)",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,13 +113,17 @@ void clear_given (struct buildObservedVoids_info *args_info)
|
||||||
args_info->gridOutput_given = 0 ;
|
args_info->gridOutput_given = 0 ;
|
||||||
args_info->quiet_given = 0 ;
|
args_info->quiet_given = 0 ;
|
||||||
args_info->dumpVoids_given = 0 ;
|
args_info->dumpVoids_given = 0 ;
|
||||||
|
args_info->dumpIds_given = 0 ;
|
||||||
args_info->ramsesBase_given = 0 ;
|
args_info->ramsesBase_given = 0 ;
|
||||||
args_info->ramsesId_given = 0 ;
|
args_info->ramsesId_given = 0 ;
|
||||||
|
args_info->dumpTree_given = 0 ;
|
||||||
|
args_info->getTree_given = 0 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void clear_args (struct buildObservedVoids_info *args_info)
|
void clear_args (struct buildObservedVoids_info *args_info)
|
||||||
{
|
{
|
||||||
|
FIX_UNUSED (args_info);
|
||||||
args_info->desc_arg = NULL;
|
args_info->desc_arg = NULL;
|
||||||
args_info->desc_orig = NULL;
|
args_info->desc_orig = NULL;
|
||||||
args_info->partzone_arg = NULL;
|
args_info->partzone_arg = NULL;
|
||||||
|
@ -132,9 +143,12 @@ void clear_args (struct buildObservedVoids_info *args_info)
|
||||||
args_info->quiet_flag = 0;
|
args_info->quiet_flag = 0;
|
||||||
args_info->dumpVoids_arg = NULL;
|
args_info->dumpVoids_arg = NULL;
|
||||||
args_info->dumpVoids_orig = NULL;
|
args_info->dumpVoids_orig = NULL;
|
||||||
|
args_info->dumpIds_flag = 0;
|
||||||
args_info->ramsesBase_arg = NULL;
|
args_info->ramsesBase_arg = NULL;
|
||||||
args_info->ramsesBase_orig = NULL;
|
args_info->ramsesBase_orig = NULL;
|
||||||
args_info->ramsesId_orig = NULL;
|
args_info->ramsesId_orig = NULL;
|
||||||
|
args_info->dumpTree_flag = 0;
|
||||||
|
args_info->getTree_flag = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,15 +169,20 @@ void init_args_info(struct buildObservedVoids_info *args_info)
|
||||||
args_info->gridOutput_help = buildObservedVoids_info_help[9] ;
|
args_info->gridOutput_help = buildObservedVoids_info_help[9] ;
|
||||||
args_info->quiet_help = buildObservedVoids_info_help[10] ;
|
args_info->quiet_help = buildObservedVoids_info_help[10] ;
|
||||||
args_info->dumpVoids_help = buildObservedVoids_info_help[11] ;
|
args_info->dumpVoids_help = buildObservedVoids_info_help[11] ;
|
||||||
args_info->ramsesBase_help = buildObservedVoids_info_help[12] ;
|
args_info->dumpIds_help = buildObservedVoids_info_help[12] ;
|
||||||
args_info->ramsesId_help = buildObservedVoids_info_help[13] ;
|
args_info->ramsesBase_help = buildObservedVoids_info_help[13] ;
|
||||||
|
args_info->ramsesId_help = buildObservedVoids_info_help[14] ;
|
||||||
|
args_info->dumpTree_help = buildObservedVoids_info_help[15] ;
|
||||||
|
args_info->getTree_help = buildObservedVoids_info_help[16] ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
buildObservedVoids_conf_print_version (void)
|
buildObservedVoids_conf_print_version (void)
|
||||||
{
|
{
|
||||||
printf ("%s %s\n", BUILDOBSERVEDVOIDS_CONF_PACKAGE, BUILDOBSERVEDVOIDS_CONF_VERSION);
|
printf ("%s %s\n",
|
||||||
|
(strlen(BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME) ? BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME : BUILDOBSERVEDVOIDS_CONF_PACKAGE),
|
||||||
|
BUILDOBSERVEDVOIDS_CONF_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_help_common(void) {
|
static void print_help_common(void) {
|
||||||
|
@ -178,7 +197,7 @@ static void print_help_common(void) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (strlen(buildObservedVoids_info_description) > 0)
|
if (strlen(buildObservedVoids_info_description) > 0)
|
||||||
printf("%s\n", buildObservedVoids_info_description);
|
printf("%s\n\n", buildObservedVoids_info_description);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -262,8 +281,9 @@ buildObservedVoids_conf_release (struct buildObservedVoids_info *args_info)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
|
write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
|
||||||
{
|
{
|
||||||
|
FIX_UNUSED (values);
|
||||||
if (arg) {
|
if (arg) {
|
||||||
fprintf(outfile, "%s=\"%s\"\n", opt, arg);
|
fprintf(outfile, "%s=\"%s\"\n", opt, arg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -307,10 +327,16 @@ buildObservedVoids_conf_dump(FILE *outfile, struct buildObservedVoids_info *args
|
||||||
write_into_file(outfile, "quiet", 0, 0 );
|
write_into_file(outfile, "quiet", 0, 0 );
|
||||||
if (args_info->dumpVoids_given)
|
if (args_info->dumpVoids_given)
|
||||||
write_into_file(outfile, "dumpVoids", args_info->dumpVoids_orig, 0);
|
write_into_file(outfile, "dumpVoids", args_info->dumpVoids_orig, 0);
|
||||||
|
if (args_info->dumpIds_given)
|
||||||
|
write_into_file(outfile, "dumpIds", 0, 0 );
|
||||||
if (args_info->ramsesBase_given)
|
if (args_info->ramsesBase_given)
|
||||||
write_into_file(outfile, "ramsesBase", args_info->ramsesBase_orig, 0);
|
write_into_file(outfile, "ramsesBase", args_info->ramsesBase_orig, 0);
|
||||||
if (args_info->ramsesId_given)
|
if (args_info->ramsesId_given)
|
||||||
write_into_file(outfile, "ramsesId", args_info->ramsesId_orig, 0);
|
write_into_file(outfile, "ramsesId", args_info->ramsesId_orig, 0);
|
||||||
|
if (args_info->dumpTree_given)
|
||||||
|
write_into_file(outfile, "dumpTree", 0, 0 );
|
||||||
|
if (args_info->getTree_given)
|
||||||
|
write_into_file(outfile, "getTree", 0, 0 );
|
||||||
|
|
||||||
|
|
||||||
i = EXIT_SUCCESS;
|
i = EXIT_SUCCESS;
|
||||||
|
@ -347,7 +373,7 @@ buildObservedVoids_conf_free (struct buildObservedVoids_info *args_info)
|
||||||
char *
|
char *
|
||||||
gengetopt_strdup (const char *s)
|
gengetopt_strdup (const char *s)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = 0;
|
||||||
if (!s)
|
if (!s)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -369,7 +395,7 @@ buildObservedVoids_conf_ext (int argc, char * const *argv, struct buildObservedV
|
||||||
struct buildObservedVoids_conf_params *params)
|
struct buildObservedVoids_conf_params *params)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
result = buildObservedVoids_conf_internal (argc, argv, args_info, params, NULL);
|
result = buildObservedVoids_conf_internal (argc, argv, args_info, params, 0);
|
||||||
|
|
||||||
if (result == EXIT_FAILURE)
|
if (result == EXIT_FAILURE)
|
||||||
{
|
{
|
||||||
|
@ -392,7 +418,7 @@ buildObservedVoids_conf2 (int argc, char * const *argv, struct buildObservedVoid
|
||||||
params.check_ambiguity = 0;
|
params.check_ambiguity = 0;
|
||||||
params.print_errors = 1;
|
params.print_errors = 1;
|
||||||
|
|
||||||
result = buildObservedVoids_conf_internal (argc, argv, args_info, ¶ms, NULL);
|
result = buildObservedVoids_conf_internal (argc, argv, args_info, ¶ms, 0);
|
||||||
|
|
||||||
if (result == EXIT_FAILURE)
|
if (result == EXIT_FAILURE)
|
||||||
{
|
{
|
||||||
|
@ -408,7 +434,7 @@ buildObservedVoids_conf_required (struct buildObservedVoids_info *args_info, con
|
||||||
{
|
{
|
||||||
int result = EXIT_SUCCESS;
|
int result = EXIT_SUCCESS;
|
||||||
|
|
||||||
if (buildObservedVoids_conf_required2(args_info, prog_name, NULL) > 0)
|
if (buildObservedVoids_conf_required2(args_info, prog_name, 0) > 0)
|
||||||
result = EXIT_FAILURE;
|
result = EXIT_FAILURE;
|
||||||
|
|
||||||
if (result == EXIT_FAILURE)
|
if (result == EXIT_FAILURE)
|
||||||
|
@ -423,6 +449,7 @@ buildObservedVoids_conf_required (struct buildObservedVoids_info *args_info, con
|
||||||
int
|
int
|
||||||
buildObservedVoids_conf_required2 (struct buildObservedVoids_info *args_info, const char *prog_name, const char *additional_error)
|
buildObservedVoids_conf_required2 (struct buildObservedVoids_info *args_info, const char *prog_name, const char *additional_error)
|
||||||
{
|
{
|
||||||
|
FIX_UNUSED (additional_error);
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
/* checks for required options */
|
/* checks for required options */
|
||||||
|
@ -474,13 +501,15 @@ static char *package_name = 0;
|
||||||
static
|
static
|
||||||
int update_arg(void *field, char **orig_field,
|
int update_arg(void *field, char **orig_field,
|
||||||
unsigned int *field_given, unsigned int *prev_given,
|
unsigned int *field_given, unsigned int *prev_given,
|
||||||
char *value, char *possible_values[], const char *default_value,
|
char *value, const char *possible_values[],
|
||||||
|
const char *default_value,
|
||||||
buildObservedVoids_conf_arg_type arg_type,
|
buildObservedVoids_conf_arg_type arg_type,
|
||||||
int check_ambiguity, int override,
|
int check_ambiguity, int override,
|
||||||
int no_free, int multiple_option,
|
int no_free, int multiple_option,
|
||||||
const char *long_opt, char short_opt,
|
const char *long_opt, char short_opt,
|
||||||
const char *additional_error)
|
const char *additional_error)
|
||||||
{
|
{
|
||||||
|
FIX_UNUSED (field);
|
||||||
char *stop_char = 0;
|
char *stop_char = 0;
|
||||||
const char *val = value;
|
const char *val = value;
|
||||||
int found;
|
int found;
|
||||||
|
@ -502,6 +531,7 @@ int update_arg(void *field, char **orig_field,
|
||||||
return 1; /* failure */
|
return 1; /* failure */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FIX_UNUSED (default_value);
|
||||||
|
|
||||||
if (field_given && *field_given && ! override)
|
if (field_given && *field_given && ! override)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -569,7 +599,8 @@ int update_arg(void *field, char **orig_field,
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObservedVoids_info *args_info,
|
buildObservedVoids_conf_internal (
|
||||||
|
int argc, char * const *argv, struct buildObservedVoids_info *args_info,
|
||||||
struct buildObservedVoids_conf_params *params, const char *additional_error)
|
struct buildObservedVoids_conf_params *params, const char *additional_error)
|
||||||
{
|
{
|
||||||
int c; /* Character of the parsed option. */
|
int c; /* Character of the parsed option. */
|
||||||
|
@ -616,9 +647,12 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
|
||||||
{ "gridOutput", 1, NULL, 'g' },
|
{ "gridOutput", 1, NULL, 'g' },
|
||||||
{ "quiet", 0, NULL, 'q' },
|
{ "quiet", 0, NULL, 'q' },
|
||||||
{ "dumpVoids", 1, NULL, 0 },
|
{ "dumpVoids", 1, NULL, 0 },
|
||||||
|
{ "dumpIds", 0, NULL, 0 },
|
||||||
{ "ramsesBase", 1, NULL, 0 },
|
{ "ramsesBase", 1, NULL, 0 },
|
||||||
{ "ramsesId", 1, NULL, 0 },
|
{ "ramsesId", 1, NULL, 0 },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ "dumpTree", 0, NULL, 0 },
|
||||||
|
{ "getTree", 0, NULL, 0 },
|
||||||
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
c = getopt_long (argc, argv, "hVd:p:v:m:f:o:g:q", long_options, &option_index);
|
c = getopt_long (argc, argv, "hVd:p:v:m:f:o:g:q", long_options, &option_index);
|
||||||
|
@ -760,6 +794,18 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
|
||||||
additional_error))
|
additional_error))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Dump particle ids. */
|
||||||
|
else if (strcmp (long_options[option_index].name, "dumpIds") == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (update_arg((void *)&(args_info->dumpIds_flag), 0, &(args_info->dumpIds_given),
|
||||||
|
&(local_args_info.dumpIds_given), optarg, 0, 0, ARG_FLAG,
|
||||||
|
check_ambiguity, override, 1, 0, "dumpIds", '-',
|
||||||
|
additional_error))
|
||||||
|
goto failure;
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Base directory for ramses. */
|
/* Base directory for ramses. */
|
||||||
else if (strcmp (long_options[option_index].name, "ramsesBase") == 0)
|
else if (strcmp (long_options[option_index].name, "ramsesBase") == 0)
|
||||||
|
@ -788,6 +834,30 @@ buildObservedVoids_conf_internal (int argc, char * const *argv, struct buildObse
|
||||||
additional_error))
|
additional_error))
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Dump the void tree. */
|
||||||
|
else if (strcmp (long_options[option_index].name, "dumpTree") == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (update_arg((void *)&(args_info->dumpTree_flag), 0, &(args_info->dumpTree_given),
|
||||||
|
&(local_args_info.dumpTree_given), optarg, 0, 0, ARG_FLAG,
|
||||||
|
check_ambiguity, override, 1, 0, "dumpTree", '-',
|
||||||
|
additional_error))
|
||||||
|
goto failure;
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Restore tree from file. */
|
||||||
|
else if (strcmp (long_options[option_index].name, "getTree") == 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (update_arg((void *)&(args_info->getTree_flag), 0, &(args_info->getTree_given),
|
||||||
|
&(local_args_info.getTree_given), optarg, 0, 0, ARG_FLAG,
|
||||||
|
check_ambiguity, override, 1, 0, "getTree", '-',
|
||||||
|
additional_error))
|
||||||
|
goto failure;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -830,7 +900,7 @@ failure:
|
||||||
/* 3 is for "--" and "=" */
|
/* 3 is for "--" and "=" */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
|
_buildObservedVoids_conf_configfile (const char *filename, int *my_argc)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
|
char my_argv[CONFIG_FILE_LINE_BUFFER_SIZE+1];
|
||||||
|
@ -842,14 +912,14 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
|
||||||
size_t len, next_token;
|
size_t len, next_token;
|
||||||
char delimiter;
|
char delimiter;
|
||||||
|
|
||||||
if ((file = fopen(filename, "r")) == NULL)
|
if ((file = fopen(filename, "r")) == 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s: Error opening configuration file '%s'\n",
|
fprintf (stderr, "%s: Error opening configuration file '%s'\n",
|
||||||
BUILDOBSERVEDVOIDS_CONF_PACKAGE, filename);
|
BUILDOBSERVEDVOIDS_CONF_PACKAGE, filename);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != NULL)
|
while ((fgets(linebuf, CONFIG_FILE_LINE_SIZE, file)) != 0)
|
||||||
{
|
{
|
||||||
++line_num;
|
++line_num;
|
||||||
my_argv[0] = '\0';
|
my_argv[0] = '\0';
|
||||||
|
@ -876,7 +946,7 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
|
||||||
|
|
||||||
if (fopt[next_token] == '\0') /* the line is over */
|
if (fopt[next_token] == '\0') /* the line is over */
|
||||||
{
|
{
|
||||||
farg = NULL;
|
farg = 0;
|
||||||
equal = 0;
|
equal = 0;
|
||||||
goto noarg;
|
goto noarg;
|
||||||
}
|
}
|
||||||
|
@ -967,7 +1037,8 @@ _buildObservedVoids_conf_configfile (char * const filename, int *my_argc)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
buildObservedVoids_conf_configfile (char * const filename,
|
buildObservedVoids_conf_configfile (
|
||||||
|
const char *filename,
|
||||||
struct buildObservedVoids_info *args_info,
|
struct buildObservedVoids_info *args_info,
|
||||||
int override, int initialize, int check_required)
|
int override, int initialize, int check_required)
|
||||||
{
|
{
|
||||||
|
@ -983,7 +1054,7 @@ buildObservedVoids_conf_configfile (char * const filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
buildObservedVoids_conf_config_file (char * const filename,
|
buildObservedVoids_conf_config_file (const char *filename,
|
||||||
struct buildObservedVoids_info *args_info,
|
struct buildObservedVoids_info *args_info,
|
||||||
struct buildObservedVoids_conf_params *params)
|
struct buildObservedVoids_conf_params *params)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/** @file buildObservedVoids_conf.h
|
/** @file buildObservedVoids_conf.h
|
||||||
* @brief The header file for the command line option parser
|
* @brief The header file for the command line option parser
|
||||||
* generated by GNU Gengetopt version 2.22
|
* generated by GNU Gengetopt version 2.22.2
|
||||||
* http://www.gnu.org/software/gengetopt.
|
* http://www.gnu.org/software/gengetopt.
|
||||||
* DO NOT modify this file, since it can be overwritten
|
* DO NOT modify this file, since it can be overwritten
|
||||||
* @author GNU Gengetopt by Lorenzo Bettini */
|
* @author GNU Gengetopt by Lorenzo Bettini */
|
||||||
|
@ -20,10 +20,15 @@ extern "C" {
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#ifndef BUILDOBSERVEDVOIDS_CONF_PACKAGE
|
#ifndef BUILDOBSERVEDVOIDS_CONF_PACKAGE
|
||||||
/** @brief the program name */
|
/** @brief the program name (used for printing errors) */
|
||||||
#define BUILDOBSERVEDVOIDS_CONF_PACKAGE "buildObservedVoids"
|
#define BUILDOBSERVEDVOIDS_CONF_PACKAGE "buildObservedVoids"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME
|
||||||
|
/** @brief the complete program name (used for help and version) */
|
||||||
|
#define BUILDOBSERVEDVOIDS_CONF_PACKAGE_NAME "buildObservedVoids"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef BUILDOBSERVEDVOIDS_CONF_VERSION
|
#ifndef BUILDOBSERVEDVOIDS_CONF_VERSION
|
||||||
/** @brief the program version */
|
/** @brief the program version */
|
||||||
#define BUILDOBSERVEDVOIDS_CONF_VERSION "0"
|
#define BUILDOBSERVEDVOIDS_CONF_VERSION "0"
|
||||||
|
@ -63,12 +68,18 @@ struct buildObservedVoids_info
|
||||||
char * dumpVoids_arg; /**< @brief Dump the particles in void in a file. */
|
char * dumpVoids_arg; /**< @brief Dump the particles in void in a file. */
|
||||||
char * dumpVoids_orig; /**< @brief Dump the particles in void in a file original value given at command line. */
|
char * dumpVoids_orig; /**< @brief Dump the particles in void in a file original value given at command line. */
|
||||||
const char *dumpVoids_help; /**< @brief Dump the particles in void in a file help description. */
|
const char *dumpVoids_help; /**< @brief Dump the particles in void in a file help description. */
|
||||||
|
int dumpIds_flag; /**< @brief Dump particle ids (default=off). */
|
||||||
|
const char *dumpIds_help; /**< @brief Dump particle ids help description. */
|
||||||
char * ramsesBase_arg; /**< @brief Base directory for ramses. */
|
char * ramsesBase_arg; /**< @brief Base directory for ramses. */
|
||||||
char * ramsesBase_orig; /**< @brief Base directory for ramses original value given at command line. */
|
char * ramsesBase_orig; /**< @brief Base directory for ramses original value given at command line. */
|
||||||
const char *ramsesBase_help; /**< @brief Base directory for ramses help description. */
|
const char *ramsesBase_help; /**< @brief Base directory for ramses help description. */
|
||||||
int ramsesId_arg; /**< @brief Ramses snapshot id. */
|
int ramsesId_arg; /**< @brief Ramses snapshot id. */
|
||||||
char * ramsesId_orig; /**< @brief Ramses snapshot id original value given at command line. */
|
char * ramsesId_orig; /**< @brief Ramses snapshot id original value given at command line. */
|
||||||
const char *ramsesId_help; /**< @brief Ramses snapshot id help description. */
|
const char *ramsesId_help; /**< @brief Ramses snapshot id help description. */
|
||||||
|
int dumpTree_flag; /**< @brief Dump the void tree (default=off). */
|
||||||
|
const char *dumpTree_help; /**< @brief Dump the void tree help description. */
|
||||||
|
int getTree_flag; /**< @brief Restore tree from file (default=off). */
|
||||||
|
const char *getTree_help; /**< @brief Restore tree from file help description. */
|
||||||
|
|
||||||
unsigned int help_given ; /**< @brief Whether help was given. */
|
unsigned int help_given ; /**< @brief Whether help was given. */
|
||||||
unsigned int version_given ; /**< @brief Whether version was given. */
|
unsigned int version_given ; /**< @brief Whether version was given. */
|
||||||
|
@ -82,8 +93,11 @@ struct buildObservedVoids_info
|
||||||
unsigned int gridOutput_given ; /**< @brief Whether gridOutput was given. */
|
unsigned int gridOutput_given ; /**< @brief Whether gridOutput was given. */
|
||||||
unsigned int quiet_given ; /**< @brief Whether quiet was given. */
|
unsigned int quiet_given ; /**< @brief Whether quiet was given. */
|
||||||
unsigned int dumpVoids_given ; /**< @brief Whether dumpVoids was given. */
|
unsigned int dumpVoids_given ; /**< @brief Whether dumpVoids was given. */
|
||||||
|
unsigned int dumpIds_given ; /**< @brief Whether dumpIds was given. */
|
||||||
unsigned int ramsesBase_given ; /**< @brief Whether ramsesBase was given. */
|
unsigned int ramsesBase_given ; /**< @brief Whether ramsesBase was given. */
|
||||||
unsigned int ramsesId_given ; /**< @brief Whether ramsesId was given. */
|
unsigned int ramsesId_given ; /**< @brief Whether ramsesId was given. */
|
||||||
|
unsigned int dumpTree_given ; /**< @brief Whether dumpTree was given. */
|
||||||
|
unsigned int getTree_given ; /**< @brief Whether getTree was given. */
|
||||||
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
@ -206,7 +220,7 @@ void buildObservedVoids_conf_free (struct buildObservedVoids_info *args_info);
|
||||||
* @return 0 if everything went fine, NON 0 if an error took place
|
* @return 0 if everything went fine, NON 0 if an error took place
|
||||||
* @deprecated use buildObservedVoids_conf_config_file() instead
|
* @deprecated use buildObservedVoids_conf_config_file() instead
|
||||||
*/
|
*/
|
||||||
int buildObservedVoids_conf_configfile (char * const filename,
|
int buildObservedVoids_conf_configfile (const char *filename,
|
||||||
struct buildObservedVoids_info *args_info,
|
struct buildObservedVoids_info *args_info,
|
||||||
int override, int initialize, int check_required);
|
int override, int initialize, int check_required);
|
||||||
|
|
||||||
|
@ -217,7 +231,7 @@ int buildObservedVoids_conf_configfile (char * const filename,
|
||||||
* @param params additional parameters for the parser
|
* @param params additional parameters for the parser
|
||||||
* @return 0 if everything went fine, NON 0 if an error took place
|
* @return 0 if everything went fine, NON 0 if an error took place
|
||||||
*/
|
*/
|
||||||
int buildObservedVoids_conf_config_file (char * const filename,
|
int buildObservedVoids_conf_config_file (const char *filename,
|
||||||
struct buildObservedVoids_info *args_info,
|
struct buildObservedVoids_info *args_info,
|
||||||
struct buildObservedVoids_conf_params *params);
|
struct buildObservedVoids_conf_params *params);
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@ CC= gcc
|
||||||
CXX= g++
|
CXX= g++
|
||||||
CPPFLAGS=
|
CPPFLAGS=
|
||||||
LDFLAGS= -L/usr/local/lib -lCosmoTool -lgsl -lgslcblas
|
LDFLAGS= -L/usr/local/lib -lCosmoTool -lgsl -lgslcblas
|
||||||
CXXFLAGS= $(CPPFLAGS) -ggdb -O3 -ffast-math
|
CXXFLAGS= $(CPPFLAGS) -ggdb -O0 -ftree-vectorize -ftree-vectorizer-verbose=2 -ffast-math
|
||||||
CFLAGS= $(CPPFLAGS) -ggdb -O3 -ffast-math
|
CFLAGS= $(CPPFLAGS) -ggdb -O0 -ftree-vectorize -ftree-vectorizer-verbose=2 -ffast-math
|
||||||
|
|
|
@ -15,16 +15,39 @@ struct VoidNode
|
||||||
std::list<VoidNode *> children;
|
std::list<VoidNode *> children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct VoidNodeOnDisk
|
||||||
|
{
|
||||||
|
int vid;
|
||||||
|
int parent;
|
||||||
|
};
|
||||||
|
|
||||||
class VoidTree
|
class VoidTree
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
uint32_t totalNumNodes;
|
uint32_t totalNumNodes, activeNodes;
|
||||||
VoidNode *nodes;
|
VoidNode *nodes;
|
||||||
VoidNode *rootNode;
|
VoidNode *rootNode;
|
||||||
ZobovRep& zobov;
|
ZobovRep& zobov;
|
||||||
public:
|
public:
|
||||||
typedef std::list<VoidNode *> VoidList;
|
typedef std::list<VoidNode *> VoidList;
|
||||||
|
|
||||||
|
void dumpTree(std::ostream& o)
|
||||||
|
{
|
||||||
|
VoidNodeOnDisk data;
|
||||||
|
|
||||||
|
o.write((char*)&activeNodes, sizeof(uint32_t));
|
||||||
|
for (uint32_t i = 0; i < activeNodes; i++)
|
||||||
|
{
|
||||||
|
data.vid = nodes[i].vid;
|
||||||
|
if (nodes[i].parent == 0)
|
||||||
|
data.parent = -1;
|
||||||
|
else
|
||||||
|
data.parent = nodes[i].parent - nodes;
|
||||||
|
o.write((char *)&data, sizeof(VoidNodeOnDisk));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int lookupParent(int voidId, const std::vector<std::list<int> >& voids_for_zones)
|
int lookupParent(int voidId, const std::vector<std::list<int> >& voids_for_zones)
|
||||||
{
|
{
|
||||||
int lastSize = 0x7fffffff;
|
int lastSize = 0x7fffffff;
|
||||||
|
@ -33,7 +56,7 @@ public:
|
||||||
const std::list<int>& candidateList = voids_for_zones[ref_void.zId.front()];
|
const std::list<int>& candidateList = voids_for_zones[ref_void.zId.front()];
|
||||||
std::list<int>::const_iterator iter_candidate = candidateList.begin();
|
std::list<int>::const_iterator iter_candidate = candidateList.begin();
|
||||||
|
|
||||||
//std::cout << "candidate list size is " << candidateList.size() << std::endl;
|
// std::cout << "candidate list size is " << candidateList.size() << std::endl;
|
||||||
|
|
||||||
while (iter_candidate != candidateList.end())
|
while (iter_candidate != candidateList.end())
|
||||||
{
|
{
|
||||||
|
@ -91,6 +114,38 @@ public:
|
||||||
std::cout << "Failure to lookup parent (2)" << std::endl;
|
std::cout << "Failure to lookup parent (2)" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VoidTree(ZobovRep& rep, std::istream& disk)
|
||||||
|
: zobov(rep)
|
||||||
|
{
|
||||||
|
totalNumNodes = rep.allVoids.size();
|
||||||
|
|
||||||
|
disk.read((char *)&activeNodes, sizeof(uint32_t));
|
||||||
|
nodes = new VoidNode[activeNodes];
|
||||||
|
rootNode = 0;
|
||||||
|
for (uint32_t i = 0; i < activeNodes; i++)
|
||||||
|
{
|
||||||
|
VoidNodeOnDisk data;
|
||||||
|
|
||||||
|
disk.read((char *)&data, sizeof(data));
|
||||||
|
nodes[i].vid = data.vid;
|
||||||
|
if (data.parent < 0)
|
||||||
|
{
|
||||||
|
if (rootNode != 0)
|
||||||
|
{
|
||||||
|
std::cerr << "Multiple root to the tree !!!" << std::endl;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
nodes[i].parent = 0;
|
||||||
|
rootNode = &nodes[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nodes[i].parent = nodes + data.parent;
|
||||||
|
nodes[i].parent->children.push_back(&nodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VoidTree(ZobovRep& rep)
|
VoidTree(ZobovRep& rep)
|
||||||
: zobov(rep)
|
: zobov(rep)
|
||||||
|
@ -113,7 +168,6 @@ public:
|
||||||
{
|
{
|
||||||
nodes[i].vid = i;
|
nodes[i].vid = i;
|
||||||
nodes[i].parent = 0;
|
nodes[i].parent = 0;
|
||||||
nodes[i].children.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Linking voids together..." << std::endl;
|
std::cout << "Linking voids together..." << std::endl;
|
||||||
|
@ -149,6 +203,7 @@ public:
|
||||||
}
|
}
|
||||||
rootNode = &nodes[i];
|
rootNode = &nodes[i];
|
||||||
}
|
}
|
||||||
|
activeNodes = inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
~VoidTree()
|
~VoidTree()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue