atrstm

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

commit d3c1d9fe5acc1f26afa7c7a8c4067ae485d29c2d
parent 9576e3fb96c4b600ff0953ed11e13e7d55e85f15
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Thu, 14 Jan 2021 18:21:51 +0100

Fix the voxelization process

Diffstat:
Msrc/atrstm_build_octrees.c | 21++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/atrstm_build_octrees.c b/src/atrstm_build_octrees.c @@ -167,10 +167,16 @@ voxelize_partition uint32_t ivxl_low[3]; uint32_t ivxl_upp[3]; uint32_t ivxl[3]; + size_t prim_id; + + prim_id = darray_size_t_cdata_get(prims)[iprim]; /* Retrieve the primitive data and setup its polyhedron */ - SUVM(volume_get_primitive(atrstm->volume, iprim, &prim)); + SUVM(volume_get_primitive(atrstm->volume, prim_id, &prim)); SUVM(primitive_setup_polyhedron(&prim, &poly)); + ASSERT(poly.lower[0] <= part_upp[0] && poly.upper[0] >= part_low[0]); + ASSERT(poly.lower[1] <= part_upp[1] && poly.upper[1] >= part_low[1]); + ASSERT(poly.lower[2] <= part_upp[2] && poly.upper[2] >= part_low[2]); /* Clamp the poly AABB to the partition boundaries */ poly_low[0] = MMAX(poly.lower[0], part_low[0]); @@ -362,12 +368,12 @@ voxel_get(const size_t xyz[3], const uint64_t mcode, void* dst, void* context) * morton order and thus the partition morton ID is encoded in the MSB of the * morton code while the voxels morton ID is stored in its LSB. */ ipart = (mcode >> (LOG2_PARTITION_DEFINITION*3)); - ivox = (mcode & BIT_U64(LOG2_PARTITION_DEFINITION*3)); + ivox = (mcode & (BIT_U64(LOG2_PARTITION_DEFINITION*3)-1)); /* Compute the pool index containing the partition. Partitions are * alternatively stored into the per thread pool. Consequentlu the i^th * partition is stored in the (i % #thread)^th pool. */ - ipool = ipart / ctx->atrstm->nthreads; + ipool = ipart % ctx->atrstm->nthreads; /* Fetch the pool storing the partition */ pool = ctx->pools + ipool; @@ -574,7 +580,12 @@ build_octrees(struct atrstm* atrstm, const struct build_octrees_args* args) if(!pools) { res = RES_MEM_ERR; goto error; } FOR_EACH(i, 0, atrstm->nthreads) { res = pool_init(atrstm->allocator, pools+i); - if(res != RES_OK) goto error; + if(res != RES_OK) { + log_err(atrstm, + "Error initializing the pool of voxel partitions -- %s.\n", + res_to_cstr((res_T)res)); + goto error; + } } omp_set_nested(1); /* Enable nested threads for voxelize_volumetric_mesh */ @@ -600,7 +611,7 @@ build_octrees(struct atrstm* atrstm, const struct build_octrees_args* args) const res_T res_local = build_octree(atrstm, args, pools); if(res_local != RES_OK) { size_t ipool; - log_err(atrstm, "Error buildin the octree -- %s\n", + log_err(atrstm, "Error building the octree -- %s\n", res_to_cstr(res_local)); FOR_EACH(ipool, 0, atrstm->nthreads) { pool_invalidate(pools+ipool);