commit f303c51b24d41f7733139ceef32ed02cfaf228b2
parent dfbf43fc51669a2ca706b3acd5ac0322dace7053
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 3 Mar 2021 10:01:10 +0100
Begin the implementation of the combustion mode
Define the htrdr_combustion_args data structure and implement its short
help.
Diffstat:
4 files changed, 334 insertions(+), 0 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -32,6 +32,7 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
add_subdirectory(core)
add_subdirectory(atmosphere)
add_subdirectory(commands)
+add_subdirectory(combustion)
add_subdirectory(doc)
################################################################################
diff --git a/cmake/combustion/CMakeLists.txt b/cmake/combustion/CMakeLists.txt
@@ -0,0 +1,77 @@
+# Copyright (C) 2018, 2019, 2020, 2021 |Meso|Star> (contact@meso-star.com)
+# Copyright (C) 2018, 2019, 2021 CNRS
+# Copyright (C) 2018, 2019 Université Paul Sabatier
+#
+# 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
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+cmake_minimum_required(VERSION 3.1)
+project(htrdr-combustion)
+
+################################################################################
+# Check dependencies
+################################################################################
+find_package(AtrSTM REQUIRED)
+find_package(RCMake 0.3 REQUIRED)
+find_package(RSys 0.11 REQUIRED)
+find_package(Star3D 0.7.1 REQUIRED)
+find_package(StarSF 0.6 REQUIRED)
+find_package(StarSP 0.8 REQUIRED)
+find_package(StarVX 0.1 REQUIRED)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
+include(rcmake)
+include(rcmake_runtime)
+
+include_directories(
+ ${AtrSTM_INCLUDE_DIR}
+ ${RSys_INCLUDE_DIR}
+ ${Star3D_INCLUDE_DIR}
+ ${StarSF_INCLUDE_DIR}
+ ${StarSP_INCLUDE_DIR}
+ ${StarVX_INCLUDE_DIR}
+ ${HTRDR_BUILD_DIR}
+ ${HTRDR_SOURCE_DIR})
+
+################################################################################
+# Configure and define targets
+################################################################################
+set(HTRDR_COMBUSTION_FILES_SRC
+ htrdr_combustion_args.c)
+
+set(HTRDR_COMBUSTION_FILES_INC
+ htrdr_combustion_args.h)
+
+# Prepend each file in the `HTRDR_FILES_<SRC|INC>' list by `HTRDR_SOURCE_DIR'
+rcmake_prepend_path(HTRDR_COMBUSTION_FILES_SRC ${HTRDR_SOURCE_DIR}/combustion)
+rcmake_prepend_path(HTRDR_COMBUSTION_FILES_INC ${HTRDR_SOURCE_DIR}/combustion)
+
+# Atmosphere library
+add_library(htrdr-combustion SHARED
+ ${HTRDR_COMBUSTION_FILES_SRC}
+ ${HTRDR_COMBUSTION_FILES_INC})
+target_link_libraries(htrdr-combustion htrdr-core AtrSTM RSys Star3D StarSF StarSP)
+
+set_target_properties(htrdr-combustion PROPERTIES
+ DEFINE_SYMBOL HTRDR_SHARED_BUILD
+ VERSION ${VERSION}
+ SOVERSION ${VERSION_MAJOR})
+
+################################################################################
+# Define output & install directories
+################################################################################
+install(TARGETS htrdr-core
+ ARCHIVE DESTINATION bin
+ LIBRARY DESTINATION lib
+ RUNTIME DESTINATION bin)
+
diff --git a/src/combustion/htrdr_combustion_args.c b/src/combustion/htrdr_combustion_args.c
@@ -0,0 +1,150 @@
+/* Copyright (C) 2018, 2019, 2020, 2021 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2018, 2019, 2021 CNRS
+ * Copyright (C) 2018, 2019, Université Paul Sabatier
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "combustion/htrdr_combustion_args.h"
+
+#include <getopt.h>
+
+/*******************************************************************************
+ * Helper functions
+ ******************************************************************************/
+static void
+print_help(const char* cmd)
+{
+ ASSERT(cmd);
+ printf(
+"Usage: %s [<options>] -l <laser> -r REFRACT_IDS -m TETRAHEDRA -p THERMOPROPS\n",
+ cmd);
+ printf(
+"Render a monochromatic image within a sooting flame described according\n"
+"to the RDG-FA theory and lightened by a laser source.\n\n");
+
+ printf(
+" -C <camera> define the rendering point of view. Refer to the\n"
+" %s man page for the list of camera options.\n", cmd);
+ printf(
+" -d dump volumetric acceleration structures to OUTPUT\n"
+" and exit.\n");
+ printf(
+" -F FRACTAL_DIM value of the fractal dimension to use in the RDG-FA\n"
+" model. Its default value is %g.\n",
+ HTRDR_COMBUSTION_ARGS_DEFAULT.fractal_dimension);
+ printf(
+" -f overwrite the OUTPUT file if it already exists.\n");
+ printf(
+" -G PREFACTOR value gyration radius prefactor to use in the RDG-FA\n"
+" model. Its default value is %g.\n",
+ HTRDR_COMBUSTION_ARGS_DEFAULT.gyration_radius_prefactor);
+ printf(
+" -g GEOMETRY filename of the combustion chamber.\n");
+ printf(
+" -h display this help and exit.\n");
+ printf(
+" -i <image> define the image to compute. Refer to the %s man\n"
+" page for the list of image options\n", cmd);
+ printf(
+" -l <laser> define the geometry of the laser sheet. Refer to the\n"
+" %s man page for the list of laser options.\n", cmd);
+ printf(
+" -m TETRAHEDRA path toward the volumetric mesh.\n");
+ printf(
+" -N precompute the tetrahedra normals.\n");
+ printf(
+" -O CACHE filename of the cache file used to store/restore the\n"
+" volumetric data. By default do not use any cache.\n");
+ printf(
+" -o OUTPUT file where data are written. If not defined, data are\n"
+" written to standard output.\n");
+ printf(
+" -p THERMOPROPS path toward the thermodynamic properties.\n");
+ printf(
+" -r REFRACT_ID path toward the per wavelength refractive\n"
+" indices.\n");
+ printf(
+" -T THRESHOLD optical thickness used as threshold during the octree\n"
+" building. By default its value is %g.\n",
+ HTRDR_COMBUSTION_ARGS_DEFAULT.optical_thickness);
+ printf(
+" -t NTHREADS hint on the number of threads to use. By default use\n"
+" as many threads as CPU cores.\n");
+ printf(
+" -V <DEFINITION|X,Y,Z>\n"
+" maximum definition of the volumetric acceleration\n"
+" grids along the 3 axis. Its default value is\n"
+" [%u, %u, %u].\n",
+ SPLIT3(HTRDR_COMBUSTION_ARGS_DEFAULT.grid_max_definition));
+ printf(
+" -v make the command verbose.\n");
+ printf(
+" -w WAVELENGTH wavelength definition of the laser in nanometer.\n"
+" By default its value is %g.\n",
+ HTRDR_COMBUSTION_ARGS_DEFAULT.wavelength);
+
+ printf("\n");
+
+ htrdr_fprint_copyright(cmd, stdout);
+ htrdr_fprint_license(cmd, stdout);
+}
+
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
+res_T
+htrdr_combustion_args_init
+ (struct htrdr_combustion_args* args,
+ int argc,
+ char** argv)
+{
+ int opt;
+ res_T res = RES_OK;
+ ASSERT(args && argc && argv);
+
+ *args = HTRDR_COMBUSTION_ARGS_DEFAULT;
+
+ while((opt = getopt(argc, argv, "C:dF:fG:g:hi:l:m:NO:o:p:r:T:t:V:vw:")) != -1) {
+ switch(opt) {
+ /* TODO parse the options */
+ case 'h':
+ print_help(argv[0]);
+ htrdr_combustion_args_release(args);
+ args->quit = 1;
+ goto exit;
+ default: res = RES_BAD_ARG; break;
+ }
+ if(res != RES_OK) {
+ if(optarg) {
+ fprintf(stderr, "%s: invalid option argument '%s' -- '%c'\n",
+ argv[0], optarg, opt);
+ }
+ goto error;
+ }
+ }
+
+exit:
+ return res;
+error:
+ htrdr_combustion_args_release(args);
+ goto exit;
+}
+
+void
+htrdr_combustion_args_release(struct htrdr_combustion_args* args)
+{
+ ASSERT(args);
+ *args = HTRDR_COMBUSTION_ARGS_DEFAULT;
+}
+
diff --git a/src/combustion/htrdr_combustion_args.h b/src/combustion/htrdr_combustion_args.h
@@ -0,0 +1,106 @@
+/* Copyright (C) 2018, 2019, 2020, 2021 |Meso|Star> (contact@meso-star.com)
+ * Copyright (C) 2018, 2019, 2021 CNRS
+ * Copyright (C) 2018, 2019, Université Paul Sabatier
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef HTRDR_COMBUSTION_ARGS_H
+#define HTRDR_COMBUSTION_ARGS_H
+
+#include "core/htrdr_args.h"
+#include <rsys/rsys.h>
+
+#include <limits.h> /* UINT_MAX support */
+
+struct htrdr_combustion_args {
+ const char* filename_geom; /* Obj of the combustion chamber */
+ const char* filename_tetra; /* Volumetric mesh of the medium */
+ const char* filename_therm_props; /* Termodynamic properties of the medium */
+ const char* filename_refract_ids; /* Refractive indices in the medium */
+
+ const char* filename_cache; /* Path of the file to store/restore cached data */
+ const char* filename_output; /* Name of the output file */
+
+ struct htrdr_args_camera camera; /* Pinhole Camera */
+
+ struct htrdr_args_rectangle laser; /* Laser surface emission */
+ double wavelength; /* Wavelength of the laser in nanometer */
+
+ struct htrdr_args_image image; /* Output Image */
+
+ /* RDG-FA parameters */
+ double gyration_radius_prefactor;
+ double fractal_dimension;
+
+ unsigned grid_max_definition[3]; /* Fixed grid definition along the 3 axes */
+ unsigned auto_grid_definition_hint; /* Hint on the grid definition to eval */
+ int auto_grid_definition; /* Switch between auto and fixed grid definition */
+
+ double optical_thickness; /* Threshold used during octree building */
+
+ /* Miscellaneous parameters */
+ unsigned nthreads; /* Hint on the number of threads to use */
+ int precompute_normals; /* Pre-compute the tetrahedra normals */
+ int force_overwriting;
+ int dump_volumetric_acceleration_structure;
+ int verbose; /* Verbosity level */
+ int quit; /* Stop the command */
+};
+
+#define HTRDR_COMBUSTION_ARGS_DEFAULT__ { \
+ NULL, /* Geom filename */ \
+ NULL, /* Tetra filename */ \
+ NULL, /* Therm props filename */ \
+ NULL, /* Refractive ids filename */ \
+ \
+ NULL, /* Cache filename */ \
+ NULL, /* Output filename */ \
+ \
+ HTRDR_ARGS_CAMERA_DEFAULT__, /* Pinhole camera */ \
+ \
+ HTRDR_ARGS_RECTANGLE_DEFAULT__, /* Laser surface emission */ \
+ 532, /* Wavelength in nanometer */ \
+ \
+ HTRDR_ARGS_IMAGE_DEFAULT__, /* Image */ \
+ \
+ 1.30, /* Gyration radius prefactor */ \
+ 1.80, /* Fractal dimension */ \
+ \
+ {256, 256, 256}, /* Acceleration grid max definition */ \
+ 256, /* Hint on grid Definition in 'auto grid definition' mode */ \
+ 1, /* Enable/disable 'auto grid definition' mode */ \
+ \
+ 1, /* Optical thickness */ \
+ \
+ UINT_MAX, /* #threads */ \
+ 0, /* Precompute normals */ \
+ 0, /* Force overwriting */ \
+ 0, /* dump volumetric acceleration structure */ \
+ 0, /* Verbose flag */ \
+ 0 /* Stop the command */ \
+}
+static const struct htrdr_combustion_args HTRDR_COMBUSTION_ARGS_DEFAULT =
+ HTRDR_COMBUSTION_ARGS_DEFAULT__;
+
+extern LOCAL_SYM res_T
+htrdr_combustion_args_init
+ (struct htrdr_combustion_args* args,
+ int argc,
+ char** argv);
+
+extern LOCAL_SYM void
+htrdr_combustion_args_release
+ (struct htrdr_combustion_args* args);
+
+#endif /* HTRDR_COMBUSTION_ARGS_H */