diff --git a/raster/r.sim/CMakeLists.txt b/raster/r.sim/CMakeLists.txt index 13e0fdf3211..f273f7a37c2 100644 --- a/raster/r.sim/CMakeLists.txt +++ b/raster/r.sim/CMakeLists.txt @@ -6,6 +6,7 @@ build_library_in_subdir( grass_datetime grass_gis grass_gmath + grass_parson grass_raster grass_vector OPTIONAL_DEPENDS OpenMP::OpenMP_C diff --git a/raster/r.sim/r.sim.sediment/main.c b/raster/r.sim/r.sim.sediment/main.c index b7987e5f3f3..0481606bb50 100644 --- a/raster/r.sim/r.sim.sediment/main.c +++ b/raster/r.sim/r.sim.sediment/main.c @@ -59,6 +59,7 @@ /********************************/ #include #include +#include #include #include @@ -303,10 +304,24 @@ int main(int argc, char *argv[]) _("Number of threads which will be used for parallel computation."); parm.threads->guisection = _("Parameters"); + flag.print = G_define_flag(); + flag.print->key = 'p'; + flag.print->description = _("Print run summary to standard output"); + flag.print->guisection = _("Print"); + + parm.format = G_define_standard_option(G_OPT_F_FORMAT); + parm.format->guisection = _("Print"); + G_option_collective(parm.dxin, parm.dyin, NULL); if (G_parser(argc, argv)) exit(EXIT_FAILURE); + SummaryFormat summary_format = SUMMARY_NONE; + if (flag.print->answer) + summary_format = strcmp(parm.format->answer, "json") == 0 + ? SUMMARY_JSON + : SUMMARY_PLAIN; + if (flag.generateSeed->answer) { seed_value = G_srand48_auto(); G_verbose_message(_("Generated random seed (-s): %ld"), seed_value); @@ -334,6 +349,7 @@ int main(int argc, char *argv[]) Inputs inputs = {0}; Outputs outputs = {0}; Grids grids = {0}; + Summary summary = {0}; geometry.conv = G_database_units_to_meters_factor(); @@ -385,6 +401,7 @@ int main(int argc, char *argv[]) threads = 1; #endif G_message(_("Number of threads: %d"), threads); + summary.threads = threads; /* sscanf(parm.nwalk->answer, "%d", &wp.maxwa); */ sscanf(parm.niter->answer, "%d", &settings.timesec); @@ -435,7 +452,10 @@ int main(int argc, char *argv[]) init_grids_sediment(&setup, &geometry, &outputs, &grids); /* treba dat output pre topoerdep */ main_loop(&setup, &geometry, &settings, &sim, &points, &inputs, &outputs, - &grids); + &grids, &summary); + print_summary(summary_format, &setup, &settings, &sim, &inputs, &outputs, + &summary); + free_summary(&summary); free_walkers(&sim, outputs.outwalk); /* Exit with Success */ diff --git a/raster/r.sim/r.sim.sediment/r.sim.sediment.html b/raster/r.sim/r.sim.sediment/r.sim.sediment.html index e3caec941d5..850895455d1 100644 --- a/raster/r.sim/r.sim.sediment/r.sim.sediment.html +++ b/raster/r.sim/r.sim.sediment/r.sim.sediment.html @@ -45,6 +45,76 @@

DESCRIPTION

Increasing the number of threads with nprocs does not really speed up the simulation. +

NOTES

+ +

Run summary

+ +With the -p flag, a summary of the run is printed to standard output +after the maps are written. The format option selects plain text +(one key: value pair per line) or JSON. Without -p, nothing is +printed to standard output regardless of format. The values are also +stored in the history of the sediment_flux raster map under the same +keys (see r.info). + +

+The keys are the same as for r.sim.water with these +differences: + + + + + + + + + + +
KeyMeaningUnit
time_step_sedimentTime step limit derived from the sediment transport parameters, null when no cell exceeds the critical shear stresss
velocity_maxMaximum flow velocity over the defined cellsm/s
sigma_maxMaximum first order reaction coefficient (detachment to transport capacity ratio) over the defined cells1/m
mean_source_rateMean sediment source (detachment) ratekg/m^2s
mean_infiltrationNot reported
transport_capacity, tlimit_erosion_depositionNames of these maps, which are written once before the simulation starts, or null when not requested
outputsA single entry with the simulated_time (s), timestamp and walkers_remaining at the time of writing, and the names of the sediment_concentration, sediment_flux, erosion_deposition and walkers maps, or null for maps which were not requested
+ +

+Summary of a run in JSON: + +

+r.sim.sediment elevation=elevation water_depth=water_depth detachment_coeff=detachment \
+    transport_coeff=transport shear_stress=shear_stress man_value=1 \
+    sediment_flux=flux erosion_deposition=erdep transport_capacity=tc \
+    duration=1 random_seed=1 -p format=json
+
+ +
+{
+    "walkers_requested": 60,
+    "walkers_generated": 78,
+    "walkers_remaining": 43,
+    "duration": 60,
+    "simulated_time": 54.891343113611583,
+    "time_step": 5.4891343113611581,
+    "time_step_sediment": 70.517234241515013,
+    "iterations_planned": 10,
+    "iterations_completed": 10,
+    "stopped_early": false,
+    "mean_velocity": 0.1821780891624834,
+    "velocity_max": 0.21544346900318839,
+    "sigma_max": 0.052657639041437901,
+    "mean_mannings_n": 1,
+    "mean_source_rate": 0.56025284041612944,
+    "threads": 1,
+    "transport_capacity": "tc",
+    "tlimit_erosion_deposition": null,
+    "outputs": [
+        {
+            "simulated_time": 54.891343113611583,
+            "timestamp": "1 minutes",
+            "walkers_remaining": 43,
+            "sediment_concentration": null,
+            "sediment_flux": "flux",
+            "erosion_deposition": "erdep",
+            "walkers": null
+        }
+    ]
+}
+
+