diff --git a/README b/README index ee7abd5a5709c81ecef1a89c1a651a925ce2f4a9..8d722a66da5083889e0adfb5af51206509bef53d 100644 --- a/README +++ b/README @@ -71,6 +71,8 @@ Parameters: from all ranks. -y, --task-dumps=<int> Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps=<int> Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps=<int> Time-step frequency at which threadpool tasks are dumped. diff --git a/README.md b/README.md index efffc9b4c43ff8f0821c4d7d49721ff7ff5949d0..f91b03d3f6a9656e33adc3216a15ed41e7b971de 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,8 @@ Parameters: from all ranks. -y, --task-dumps=<int> Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps=<int> Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps=<int> Time-step frequency at which threadpool tasks are dumped. diff --git a/doc/RTD/source/AnalysisTools/index.rst b/doc/RTD/source/AnalysisTools/index.rst index f7f2f979666270ce371b532b6eab7bad3a23c9bd..8b4467f5f36a5e07f0b5446f4f590b2643990731 100644 --- a/doc/RTD/source/AnalysisTools/index.rst +++ b/doc/RTD/source/AnalysisTools/index.rst @@ -21,11 +21,13 @@ Cell graph ---------- An interactive graph of the cells is available with the configuration option ``--enable-cell-graph``. -During a run, SWIFT will generate a ``cell_hierarchy_*.csv`` file per MPI rank. -The command ``tools/make_cell_hierarchy.sh cell_hierarchy_*.csv`` merges the files together and generates the file ``cell_hierarchy.html`` +During a run, SWIFT will generate a ``cell_hierarchy_*.csv`` file per MPI rank at the frequency given by the parameter ``--cell-dumps=n``. +The command ``tools/make_cell_hierarchy.sh cell_hierarchy_0000_*.csv`` merges the files at time step 0 together and generates the file ``cell_hierarchy.html`` that contains the graph and can be read with your favorite web browser. -With chrome, you cannot access the files directly, you will need to either access them through an existing server (e.g. public http provided by your university) +With most web browsers, you cannot access the files directly. +If it is the case, the cells will never appear (but everything else should be fine). +To solve this problem, you will need to either access them through an existing server (e.g. public http provided by your university) or install ``npm`` and then run the following commands .. code-block:: bash @@ -34,6 +36,14 @@ or install ``npm`` and then run the following commands http-server . Now you can open the web page ``http://localhost:8080/cell_hierarchy.html``. +When running a large simulation, the data loading may take a while (a few seconds for EAGLE_6). +Your browser should not be hanging, but will seems to be idle. + +If you wish to add some information to the graph, you can do it by modifying the files ``src/space.c`` and ``tools/data/cell_hierarchy.html``. +In the first one, you will need to modify the calls to ``fprintf`` in the functions ``space_write_cell_hierarchy`` and ``space_write_cell``. +Here the code is simply writing CSV files containing all the required information about the cells. +In the second one, you will need to find the function ``mouseover`` and add the field that you have created. +You can also increase the size of the bubble through the style parameter ``height``. Memory usage reports -------------------- diff --git a/doc/RTD/source/CommandLineOptions/index.rst b/doc/RTD/source/CommandLineOptions/index.rst index 1144477548062bb61e47a88d3a1ee062b89b97cf..6212093515c939aa79ad4057df6a30def26f183c 100644 --- a/doc/RTD/source/CommandLineOptions/index.rst +++ b/doc/RTD/source/CommandLineOptions/index.rst @@ -65,5 +65,7 @@ can be found by typing ``./swift -h``:: from all ranks. -y, --task-dumps=<int> Time-step frequency at which task analysis files and/or tasks are dumped. + --cell-dumps=<int> Time-step frequency at which cell graphs + are dumped. -Y, --threadpool-dumps=<int> Time-step frequency at which threadpool tasks are dumped. diff --git a/examples/main.c b/examples/main.c index 27af0897a4bdd12287fd0460579a4eb9ea3f08c1..1d7aa8777f97627615bd23568c66d7bc4e7ecb88 100644 --- a/examples/main.c +++ b/examples/main.c @@ -148,6 +148,7 @@ int main(int argc, char *argv[]) { int with_aff = 0; int dry_run = 0; int dump_tasks = 0; + int dump_cells = 0; int dump_threadpool = 0; int nsteps = -2; int restart = 0; @@ -263,6 +264,9 @@ int main(int argc, char *argv[]) { OPT_INTEGER('y', "task-dumps", &dump_tasks, "Time-step frequency at which task graphs are dumped.", NULL, 0, 0), + OPT_INTEGER(0, "cell-dumps", &dump_cells, + "Time-step frequency at which cell graphs are dumped.", NULL, + 0, 0), OPT_INTEGER('Y', "threadpool-dumps", &dump_threadpool, "Time-step frequency at which threadpool tasks are dumped.", NULL, 0, 0), @@ -323,6 +327,16 @@ int main(int argc, char *argv[]) { } #endif +#ifndef SWIFT_CELL_GRAPH + if (dump_cells) { + if (myrank == 0) { + error( + "complete cell dumps are only created when " + "configured with --enable-cell-graph."); + } + } +#endif + #ifndef SWIFT_DEBUG_THREADPOOL if (dump_threadpool) { printf( @@ -1261,6 +1275,13 @@ int main(int argc, char *argv[]) { task_dump_stats(dumpfile, &e, /* header = */ 0, /* allranks = */ 1); } +#ifdef SWIFT_CELL_GRAPH + /* Dump the cell data using the given frequency. */ + if (dump_cells && (dump_cells == 1 || j % dump_cells == 1)) { + space_write_cell_hierarchy(e.s, j + 1); + } +#endif + /* Dump memory use report if collected. */ #ifdef SWIFT_MEMUSE_REPORTS { diff --git a/src/engine.c b/src/engine.c index 462f38ba4b95b7b6322964d91e19285eb618d48f..35b203f3ecec0629e4fbd28502245074acc17720 100644 --- a/src/engine.c +++ b/src/engine.c @@ -3557,7 +3557,6 @@ void engine_init_particles(struct engine *e, int flag_entropy_ICs, #endif scheduler_write_dependencies(&e->sched, e->verbose); - space_write_cell_hierarchy(e->s); if (e->nodeID == 0) scheduler_write_task_level(&e->sched); /* Run the 0th time-step */ diff --git a/src/space.c b/src/space.c index a417117f6e3fa92e1a491efbc11f70c7c9e9ef97..eb498035d7c912f331870cfb0bb8bf84ad1559c4 100644 --- a/src/space.c +++ b/src/space.c @@ -5670,14 +5670,15 @@ void space_write_cell(const struct space *s, FILE *f, const struct cell *c) { * @brief Write a csv file containing the cell hierarchy * * @param s The #space. + * @param j The file number. */ -void space_write_cell_hierarchy(const struct space *s) { +void space_write_cell_hierarchy(const struct space *s, int j) { #ifdef SWIFT_CELL_GRAPH /* Open file */ char filename[200]; - sprintf(filename, "cell_hierarchy_%04i.csv", engine_rank); + sprintf(filename, "cell_hierarchy_%04i_%04i.csv", j, engine_rank); FILE *f = fopen(filename, "w"); if (f == NULL) error("Error opening task level file."); diff --git a/src/space.h b/src/space.h index 0b332716645e733636b7ab0da57a0a31b28e3d31..ad20641e4dc11559d33f512794fddf1b7453317a 100644 --- a/src/space.h +++ b/src/space.h @@ -374,6 +374,6 @@ void space_free_foreign_parts(struct space *s); void space_struct_dump(struct space *s, FILE *stream); void space_struct_restore(struct space *s, FILE *stream); -void space_write_cell_hierarchy(const struct space *s); +void space_write_cell_hierarchy(const struct space *s, int j); #endif /* SWIFT_SPACE_H */ diff --git a/tools/make_cell_hierarchy.sh b/tools/make_cell_hierarchy.sh old mode 100644 new mode 100755 index 87fbe4c97f4aadcbb9be5867a62e8acb56415820..9d1d3caf7c4e2f0514c3d6ad5b2db48efa8958d5 --- a/tools/make_cell_hierarchy.sh +++ b/tools/make_cell_hierarchy.sh @@ -9,7 +9,7 @@ then rm $csv_output fi -for filename in ./cell_hierarchy_*.csv; +for filename in $@; do cat $filename >> cell_hierarchy.csv done