atrstm

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

commit 141b7e99d212888aa6e06f2f4a010c8c76daed4e
parent 4089a3c30c2eb68b0e7771196ebe50aa2b014574
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Mon,  9 Jan 2023 10:10:08 +0100

Merge branch 'release_0.0.1'

Diffstat:
MREADME.md | 17+++++++++++++++--
Mcmake/CMakeLists.txt | 9+++++----
Msrc/atrstm.c | 3++-
Msrc/atrstm.h | 3++-
Msrc/atrstm_c.h | 3++-
Msrc/atrstm_cache.c | 3++-
Msrc/atrstm_cache.h | 3++-
Msrc/atrstm_dump_svx_octree.c | 3++-
Msrc/atrstm_log.c | 3++-
Msrc/atrstm_log.h | 3++-
Msrc/atrstm_partition.c | 4+++-
Msrc/atrstm_partition.h | 5+++--
Msrc/atrstm_radcoefs.c | 3++-
Msrc/atrstm_radcoefs.h | 3++-
Msrc/atrstm_radcoefs_simd4.c | 3++-
Msrc/atrstm_radcoefs_simd4.h | 3++-
Msrc/atrstm_rdgfa.c | 3++-
Msrc/atrstm_rdgfa.h | 3++-
Msrc/atrstm_rdgfa_simd4.h | 3++-
Msrc/atrstm_setup_octrees.c | 7++++---
Msrc/atrstm_setup_octrees.h | 3++-
Msrc/atrstm_setup_uvm.c | 69++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Msrc/atrstm_svx.c | 3++-
Msrc/atrstm_svx.h | 7++++---
Msrc/test_atrstm.c | 6+++---
Msrc/test_atrstm_radcoefs.c | 3++-
Msrc/test_atrstm_radcoefs_simd.c | 3++-
27 files changed, 123 insertions(+), 58 deletions(-)

diff --git a/README.md b/README.md @@ -12,7 +12,7 @@ It also depends on the [Astoria: Thermodynamic Properties](https://gitlab.com/meso-star/atrtp/), [RSys](https://gitlab.com/vaplv/rsys/), [Star-UnstructuredVolumetricMesh](https://gitlab.com/meso-star/star-uvm/), -[Star-TetraHedra](https://gitlab.com/meso-star/star-tetrahedra/) libraries, +[Star-Mesh](https://gitlab.com/meso-star/star-mesh/) libraries, and on [OpenMP](https://www.openmp.org) 1.2 the parallelize its computations. First ensure that CMake is installed on your system. Then install the RCMake @@ -23,9 +23,22 @@ resulting project can be edited, built, tested and installed as any CMake project. Refer to the [CMake documentation](https://cmake.org/documentation) for further informations on CMake. +## Release notes + +### Version 0.0.1 + +- Relies on the Star-Mesh library rather than the obsolete Star-Tetrahedra + library. +- Fix a possible memory leak. +- Fix a wrong assertion. + +## Copyright + +Copyright (C) 2022, 2023 [|Méso|Star](http://www.meso-star.com) (<contact@meso-star.com>) +Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique (CNRS) + ## License -Copyright (C) 2020, 2021 Centre National de la Recherche Scientifique (CNRS). AtrSTM is free software released under the GPL v3+ license: GNU GPL version 3 or later. You are welcome to redistribute it under certain conditions; refer to the COPYING file for details. diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt @@ -1,3 +1,4 @@ +# Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) # Copyright (C) 2020, 2021 CNRS # # This program is free software: you can redistribute it and/or modify @@ -28,7 +29,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 +51,7 @@ include_directories( ${AtrRI_INCLUDE_DIR} ${AtrTP_INCLUDE_DIR} ${RSys_INCLUDE_DIR} - ${StarTetraHedra_INCLUDE_DIR} + ${StarMesh_INCLUDE_DIR} ${StarUVM_INCLUDE_DIR} ${StarVX_INCLUDE_DIR}) @@ -59,7 +60,7 @@ include_directories( ################################################################################ set(VERSION_MAJOR 0) set(VERSION_MINOR 0) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) set(ATRSTM_FILES_SRC @@ -106,7 +107,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.c b/src/atrstm.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm.h b/src/atrstm.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_c.h b/src/atrstm_c.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_cache.c b/src/atrstm_cache.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_cache.h b/src/atrstm_cache.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_dump_svx_octree.c b/src/atrstm_dump_svx_octree.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_log.c b/src/atrstm_log.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_log.h b/src/atrstm_log.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_partition.c b/src/atrstm_partition.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -88,6 +89,7 @@ pool_release(struct pool* pool) LIST_FOR_EACH_SAFE(node, tmp_node, &pool->parts_full) { struct part* part = CONTAINER_OF(node, struct part, node); list_del(node); + part_release(part); MEM_RM(pool->allocator, part); } ASSERT(is_list_empty(&pool->parts_full)); diff --git a/src/atrstm_partition.h b/src/atrstm_partition.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +21,7 @@ #include <rsys/list.h> #include <string.h> -/* Definition of a partition along the 4 axis */ +/* Definition of a partition along the 3 axis */ #define LOG2_PARTITION_DEFINITION 5 #define PARTITION_DEFINITION BIT(LOG2_PARTITION_DEFINITION) /*32*/ #define PARTITION_NVOXELS \ diff --git a/src/atrstm_radcoefs.c b/src/atrstm_radcoefs.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs.h b/src/atrstm_radcoefs.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs_simd4.c b/src/atrstm_radcoefs_simd4.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_radcoefs_simd4.h b/src/atrstm_radcoefs_simd4.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa.c b/src/atrstm_rdgfa.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa.h b/src/atrstm_rdgfa.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_rdgfa_simd4.h b/src/atrstm_rdgfa_simd4.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_setup_octrees.c b/src/atrstm_setup_octrees.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -200,8 +201,8 @@ voxelize_partition ivxl_upp[1] = (uint32_t)ceil((poly_upp[1] - part_low[1]) / vxsz[1]); ivxl_upp[2] = (uint32_t)ceil((poly_upp[2] - part_low[2]) / vxsz[2]); ASSERT(ivxl_upp[0] <= PARTITION_DEFINITION); - ASSERT(ivxl_upp[0] <= PARTITION_DEFINITION); - ASSERT(ivxl_upp[0] <= PARTITION_DEFINITION); + ASSERT(ivxl_upp[1] <= PARTITION_DEFINITION); + ASSERT(ivxl_upp[2] <= PARTITION_DEFINITION); /* Iterate over the partition voxels intersected by the primitive AABB */ FOR_EACH(ivxl[2], ivxl_low[2], ivxl_upp[2]) { diff --git a/src/atrstm_setup_octrees.h b/src/atrstm_setup_octrees.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_setup_uvm.c b/src/atrstm_setup_uvm.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,7 +17,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 +25,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 +62,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 +78,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 +128,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 +137,3 @@ error: } goto exit; } - diff --git a/src/atrstm_svx.c b/src/atrstm_svx.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/atrstm_svx.h b/src/atrstm_svx.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +24,7 @@ * * For each SVX voxel, the data of the optical property are stored * linearly as N single precision floating point data, with N computed as - * bellow: + * below: * * N = ATRSTM_RADCOEFS_COUNT__ #optical properties per voxel * * ATRSTM_SVX_OPS_COUNT__ #supported operations on each properties @@ -34,7 +35,7 @@ * C' according to the operation `enum atrstm_svx_op O' is * then computed as bellow: * - * id = C * NFLOATS_PER_CPNT + P * HTSKY_SVX_OPS_COUNT__ + O; + * id = C * NFLOATS_PER_CPNT + P * ATRSTM_SVX_OPS_COUNT__ + O; * NFLOATS_PER_CPNT = ATRSTM_SVX_OPS_COUNT__ * ATRSTM_RADCOEFS_COUNT__; */ diff --git a/src/test_atrstm.c b/src/test_atrstm.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,14 +83,13 @@ print_help(const char* cmd) " along the 3 axis. Its default value is [%u, %u, %u].\n", SPLIT3(ATRSTM_ARGS_DEFAULT.grid_max_definition)); printf( -" -v make the program verobse.\n"); +" -v make the program verbose.\n"); printf( " -w WAVELENGTH shortwave wavelength to use, in nanometer.\n" " By default it is set to %g nm\n", ATRSTM_ARGS_DEFAULT.wlen_range[0]); printf("\n"); printf( -"Copyright (C) 2020, 2021 CNRS.\n" "This is free software released under the GNU GPL license, version 3 or\n" "later. You are free to change or redistribute it under certain\n" "conditions <http://gnu.org.licenses/gpl.html>\n"); diff --git a/src/test_atrstm_radcoefs.c b/src/test_atrstm_radcoefs.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/test_atrstm_radcoefs_simd.c b/src/test_atrstm_radcoefs_simd.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2020, 2021 CNRS +/* Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) + * Copyright (C) 2020, 2021 CNRS * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by