atrstm

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

commit a8f4133718dd4af21f015eaf46589f08c088482a
parent 4ed1537049f52255225cd47c50215fe3eae6a69d
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Tue, 18 Oct 2022 16:56:24 +0200

Replace the Star-Tetrahedra library with Star-Mesh

Star-Tetrahedra is actually deprecated.

Diffstat:
Mcmake/CMakeLists.txt | 6+++---
Msrc/atrstm_setup_uvm.c | 66++++++++++++++++++++++++++++++++++++++++++++++--------------------
2 files changed, 49 insertions(+), 23 deletions(-)

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -28,7 +28,7 @@ find_package(AtrTP 0.0 REQUIRED) find_package(OpenMP 1.2 REQUIRED) find_package(RCMake 0.4 REQUIRED) find_package(RSys 0.12 REQUIRED) -find_package(StarTetraHedra 0.0 REQUIRED) +find_package(StarMesh REQUIRED) find_package(StarUVM 0.0 REQUIRED) find_package(StarVX 0.2 REQUIRED) find_package(RSIMD 0.3) @@ -50,7 +50,7 @@ include_directories( ${AtrRI_INCLUDE_DIR} ${AtrTP_INCLUDE_DIR} ${RSys_INCLUDE_DIR} - ${StarTetraHedra_INCLUDE_DIR} + ${StarMesh_INCLUDE_DIR} ${StarUVM_INCLUDE_DIR} ${StarVX_INCLUDE_DIR}) @@ -106,7 +106,7 @@ add_library(atrstm SHARED ${ATRSTM_FILES_SRC} ${ATRSTM_FILES_INC} ${ATRSTM_FILES_INC_API}) -target_link_libraries(atrstm AtrRI AtrTP RSys StarTetraHedra StarUVM StarVX m) +target_link_libraries(atrstm AtrRI AtrTP RSys StarMesh StarUVM StarVX m) # Setup SIMD support on the target if(USE_SIMD) diff --git a/src/atrstm_setup_uvm.c b/src/atrstm_setup_uvm.c @@ -16,7 +16,7 @@ #include "atrstm_c.h" #include "atrstm_log.h" -#include <star/sth.h> +#include <star/smsh.h> #include <star/suvm.h> #include <rsys/clock_time.h> @@ -24,13 +24,34 @@ /******************************************************************************* * Helper functions ******************************************************************************/ +static res_T +check_smsh_desc(struct atrstm* atrstm, const struct smsh_desc* desc) +{ + res_T res = RES_OK; + ASSERT(atrstm && desc); + + if(desc->dnode != 3 || desc->dcell != 4) { + log_err(atrstm, + "The mesh of a semi-transparent material must be a 3D tetrahedral mesh " + "(dimension of the mesh: %u; dimension of the vertices: %u)\n", + desc->dnode, desc->dcell); + res = RES_BAD_ARG; + goto error; + } + +exit: + return res; +error: + goto exit; +} + static INLINE void tetrahedron_get_indices(const size_t itetra, size_t ids[4], void* ctx) { - const struct sth_desc* sth_desc = ctx; + const struct smsh_desc* smsh_desc = ctx; const uint64_t* indices = NULL; - ASSERT(ctx && ids && itetra < sth_desc->ntetrahedra); - indices = sth_desc_get_tetrahedron_indices(sth_desc, itetra); + ASSERT(ctx && ids && itetra < smsh_desc->ncells && smsh_desc->dcell == 4); + indices = smsh_desc_get_cell(smsh_desc, itetra); ids[0] = (size_t)indices[0]; ids[1] = (size_t)indices[1]; ids[2] = (size_t)indices[2]; @@ -40,10 +61,10 @@ tetrahedron_get_indices(const size_t itetra, size_t ids[4], void* ctx) static INLINE void vertex_get_position(const size_t ivert, double pos[3], void* ctx) { - struct sth_desc* sth_desc = ctx; + struct smsh_desc* smsh_desc = ctx; const double* position = NULL; - ASSERT(ctx && pos && ivert < sth_desc->nvertices); - position = sth_desc_get_vertex_position(sth_desc, ivert); + ASSERT(ctx && pos && ivert < smsh_desc->nnodes && smsh_desc->dnode == 3); + position = smsh_desc_get_node(smsh_desc, ivert); pos[0] = position[0]; pos[1] = position[1]; pos[2] = position[2]; @@ -56,40 +77,46 @@ res_T setup_unstructured_volumetric_mesh (struct atrstm* atrstm, const int precompute_normals, - const char* sth_filename, + const char* smsh_filename, struct suvm_volume** out_volume) { struct suvm_tetrahedral_mesh_args mesh_args = SUVM_TETRAHEDRAL_MESH_ARGS_NULL; - struct sth_desc sth_desc = STH_DESC_NULL; - struct sth* sth = NULL; + struct smsh_create_args args = SMSH_CREATE_ARGS_DEFAULT; + struct smsh_desc smsh_desc = SMSH_DESC_NULL; + struct smsh* smsh = NULL; struct suvm_volume* volume = NULL; struct time t0, t1; char buf[128]; res_T res = RES_OK; - ASSERT(atrstm && sth_filename && out_volume); + ASSERT(atrstm && smsh_filename && out_volume); log_info(atrstm, "Load and structure the volumetric mesh '%s'.\n", - sth_filename); + smsh_filename); time_current(&t0); /* Load the volumetric mesh */ - res = sth_create(atrstm->logger, atrstm->allocator, atrstm->verbose, &sth); + args.logger = atrstm->logger; + args.allocator = atrstm->allocator; + args.verbose = atrstm->verbose; + res = smsh_create(&args, &smsh); + if(res != RES_OK) goto error; + res = smsh_load(smsh, smsh_filename); if(res != RES_OK) goto error; - res = sth_load(sth, sth_filename); + res = smsh_get_desc(smsh, &smsh_desc); if(res != RES_OK) goto error; - res = sth_get_desc(sth, &sth_desc); + res = check_smsh_desc(atrstm, &smsh_desc); if(res != RES_OK) goto error; /* Partition the unstructured volumetric mesh */ - mesh_args.ntetrahedra = sth_desc.ntetrahedra; - mesh_args.nvertices = sth_desc.nvertices; + mesh_args.ntetrahedra = smsh_desc.ncells; + mesh_args.nvertices = smsh_desc.nnodes; mesh_args.get_indices = tetrahedron_get_indices; mesh_args.get_position = vertex_get_position; mesh_args.tetrahedron_data = SUVM_DATA_NULL; /* Tetra data are not in SUVM */ mesh_args.vertex_data = SUVM_DATA_NULL; /* Vertex data are not in SUVM */ mesh_args.precompute_normals = precompute_normals; - mesh_args.context = &sth_desc; + mesh_args.context = &smsh_desc; res = suvm_tetrahedral_mesh_create(atrstm->suvm, &mesh_args, &volume); if(res != RES_OK) goto error; @@ -100,7 +127,7 @@ setup_unstructured_volumetric_mesh exit: *out_volume = volume; - if(sth) STH(ref_put(sth)); + if(smsh) SMSH(ref_put(smsh)); return res; error: if(volume) { @@ -109,4 +136,3 @@ error: } goto exit; } -