atrstm

Load and structure a combustion gas mixture
git clone git://git.meso-star.fr/atrstm.git
Log | Files | Refs | README | LICENSE

commit bfd9f35c045995007128c3ac8fcc627978f05ff7
parent 9e9fdb4b85e9e1e81f5d9b2bf18b9ac03ff9bf31
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 27 Jan 2021 12:11:39 +0100

Fix the octree building with non-pow2 definitions

Diffstat:
Msrc/atrstm_setup_octrees.c | 26++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/atrstm_setup_octrees.c b/src/atrstm_setup_octrees.c @@ -39,11 +39,12 @@ struct build_octree_context { struct atrstm* atrstm; struct pool* pool; /* Pool of voxel partitions */ + struct part* part; /* Current partition */ /* Optical thickness threshold criteria for the merge process */ double tau_threshold; }; -#define BUILD_OCTREE_CONTEXT_NULL__ { NULL, NULL, 0 } +#define BUILD_OCTREE_CONTEXT_NULL__ { NULL, NULL, NULL, 0 } static const struct build_octree_context BUILD_OCTREE_CONTEXT_NULL = BUILD_OCTREE_CONTEXT_NULL__; @@ -382,8 +383,7 @@ error: static void voxel_get(const size_t xyz[3], const uint64_t mcode, void* dst, void* context) { - const struct build_octree_context* ctx = context; - struct part* part = NULL; + struct build_octree_context* ctx = context; float* vox = NULL; uint64_t ivox, ipart; ASSERT(xyz && dst && ctx); @@ -396,14 +396,19 @@ voxel_get(const size_t xyz[3], const uint64_t mcode, void* dst, void* context) ipart = (mcode >> (LOG2_PARTITION_DEFINITION*3)); ivox = (mcode & (BIT_U64(LOG2_PARTITION_DEFINITION*3)-1)); - /* Fetch the partition storing the voxel */ - part = pool_fetch_partition(ctx->pool, ipart); + if(!ctx->part || ctx->part->id != ipart) { + if(ctx->part) { /* Free the previous partition */ + pool_free_partition(ctx->pool, ctx->part); + } + /* Fetch the partition storing the voxel */ + ctx->part = pool_fetch_partition(ctx->pool, ipart); + } - if(!part) { /* An error occurs */ + if(!ctx->part) { /* An error occurs */ memset(dst, 0, NFLOATS_PER_VOXEL * sizeof(float)); } else { int cpnt; - vox = part_get_voxel(part, ivox); /* Fetch the voxel data */ + vox = part_get_voxel(ctx->part, ivox); /* Fetch the voxel data */ /* Setup destination data */ FOR_EACH(cpnt, 0, ATRSTM_CPNTS_COUNT__) { @@ -424,11 +429,6 @@ voxel_get(const size_t xyz[3], const uint64_t mcode, void* dst, void* context) } } } - - /* Free the partition if the fetch voxel was its last one */ - if(ivox == PARTITION_NVOXELS - 1) { - pool_free_partition(ctx->pool, part); - } } } @@ -619,6 +619,8 @@ build_octrees(struct atrstm* atrstm) log_info(atrstm, "Evaluate and partition the field of optical properties.\n"); + log_info(atrstm, + "Grid definition: %ux%ux%u.\n", SPLIT3(atrstm->grid_max_definition)); omp_set_nested(1); /* Enable nested threads for voxelize_volumetric_mesh */ #pragma omp parallel sections num_threads(2)