rnatm

Load and structure data describing an atmosphere
git clone git://git.meso-star.fr/rnatm.git
Log | Files | Refs | README | LICENSE

commit e72deb14e89f35cf26ae04dbf1f31cae3ebead98
parent 185312a43b7666353e43fb14f8e13c49b3c38122
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 24 Aug 2022 11:22:38 +0200

Update the way the status message is printed

Previously, there were as many status messages as atmospheric mesh
voxelization. We now print a single status message for the entire
voxelization

Diffstat:
Msrc/rnatm_octree.c | 47+++++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/src/rnatm_octree.c b/src/rnatm_octree.c @@ -40,6 +40,8 @@ #include <math.h> /* lround */ #include <omp.h> +#define VOXELIZE_MSG "voxelize atmosphere: %3d%%\r" + /* Structure used to synchronise the voxelization and the build threads */ struct build_sync { struct mutex* mutex; @@ -86,6 +88,8 @@ struct voxelize_batch_args { size_t part_def; /* Partition definition */ size_t nparts[3]; /* #partitions required to cover the entire grid */ size_t nparts_adjusted; /* #partitions allowing their indexing by morton id */ + size_t nparts_overall; /* Total number of partitions to voxelize */ + size_t nparts_voxelized; /* #partitions already voxelized */ /* AABB of the atmosphere */ double atm_low[3]; @@ -104,6 +108,8 @@ struct voxelize_batch_args { 0, /* Partition definition */ \ {0,0,0}, /* #partitions to cover the entire grid */ \ 0, /* #partitions adjusted wrt morton indexing */ \ + 0, /* Total number of partitions to voxelize */ \ + 0, /* #partitions already voxelized */ \ \ /* AABB of the atmosphere */ \ { DBL_MAX, DBL_MAX, DBL_MAX}, \ @@ -599,15 +605,14 @@ voxelize_batch(struct rnatm* atm, const struct voxelize_batch_args* args) { int64_t i; int progress = 0; - ATOMIC nparts_voxelized = 0; + ATOMIC nparts_voxelized; ATOMIC res = RES_OK; ASSERT(atm && check_voxelize_batch_args(atm, args) == RES_OK); - pool_reset(args->pool); + pool_reset(args->pool); /* Reset the next partition id to 0 */ - /* Print status message */ - #define LOG_MSG "voxelize atmosphere: %3d%%\r" - log_info(atm, LOG_MSG, 0); + /* #partitions already voxelized */ + nparts_voxelized = (ATOMIC)args->nparts_voxelized; /* Iterates over the partitions of the grid according to their Morton order * and voxelizes the tetrahedrons that overlap them */ @@ -682,19 +687,15 @@ voxelize_batch(struct rnatm* atm, const struct voxelize_batch_args* args) /* Update progress bar */ n = (size_t)ATOMIC_INCR(&nparts_voxelized); - pcent = (int)((n * 100) / (args->nparts[0]*args->nparts[1]*args->nparts[2])); + pcent = (int)((n * 100) / args->nparts_overall); #pragma omp critical if(pcent > progress) { progress = pcent; - log_info(atm, LOG_MSG, pcent); + log_info(atm, VOXELIZE_MSG, pcent); } } if(res != RES_OK) goto error; - /* Print final status message */ - log_info(atm, LOG_MSG"\n", 100); - #undef LOG_MSG - exit: return (res_T)res; error: @@ -722,7 +723,8 @@ voxelize_atmosphere double atm_upp[3]; double vxsz[3]; size_t nparts[3]; /* #partitions along the 3 axis */ - size_t nparts_adjusted; + size_t nparts_adjusted; /* #partitions allowing their indexing by morton id */ + size_t nparts_overall; /* Total number of voxelized partitions */ size_t part_def; /* Definition of a partition */ /* Miscellaneous variables */ @@ -779,6 +781,10 @@ voxelize_atmosphere naccel_structs = darray_accel_struct_size_get(&atm->accel_structs); nbatches = (naccel_structs + (batch_size - 1)/*ceil*/) / batch_size; + /* Calculate the total number of partitions to voxelize. Note that the same + * partition can be voxelized several times, once per batch */ + nparts_overall = nparts[0] * nparts[1] * nparts[2] * nbatches; + /* Print the size of a voxel */ log_info(atm, "voxel size = {%g, %g, %g}\n", SPLIT3(vxsz)); @@ -791,10 +797,15 @@ voxelize_atmosphere batch_args.nparts[1] = nparts[1]; batch_args.nparts[2] = nparts[2]; batch_args.nparts_adjusted = nparts_adjusted; + batch_args.nparts_overall = nparts_overall; + batch_args.nparts_voxelized = 0; d3_set(batch_args.atm_low, atm_low); d3_set(batch_args.atm_upp, atm_upp); d3_set(batch_args.vxsz, vxsz); + /* Print voxelization status */ + log_info(atm, VOXELIZE_MSG, 0); + /* Voxelize the batches */ FOR_EACH(ibatch, 0, nbatches) { size_t item_range[2]; @@ -818,8 +829,13 @@ voxelize_atmosphere /* Generate the voxels of the current batch */ res = voxelize_batch(atm, &batch_args); if(res != RES_OK) goto error; + + batch_args.nparts_voxelized += nparts[0]*nparts[1]*nparts[2]; } + /* Print final status message */ + log_info(atm, VOXELIZE_MSG"\n", 100); + exit: FOR_EACH(i, 0, darray_radcoef_list_size_get(&per_thread_radcoef_list)) { MEM_RM(atm->allocator, @@ -1104,8 +1120,11 @@ create_octrees(struct rnatm* atm, const struct rnatm_create_args* args) res = build_sync_init(&sync); if(res != RES_OK) goto error; - log_info(atm, "partitionning of radiative properties (grid definition: %ux%ux%u)\n", - SPLIT3(atm->grid_definition)); + log_info(atm, + "partitionning of radiative properties " + "(grid definition = %ux%ux%u; #octrees = %lu)\n", + SPLIT3(atm->grid_definition), + (unsigned long)darray_accel_struct_size_get(&atm->accel_structs)); /* Enable nested threads to allow multi-threading when voxelizing tetrahedra * and building octrees */