htrdr

Solving radiative transfer in heterogeneous media
git clone git://git.meso-star.fr/htrdr.git
Log | Files | Refs | README | LICENSE

commit 4890f4897eff37a037c0f9eb3a4c8757083cd859
parent 6cd713b5c9edabbbcce77d0ddf8e57b622a55bc6
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed,  3 Mar 2021 16:11:20 +0100

Add the htrdr-combustion command

Diffstat:
Mcmake/combustion/CMakeLists.txt | 4+++-
Mcmake/commands/CMakeLists.txt | 8+++++++-
Asrc/combustion/htrdr_combustion.h | 33+++++++++++++++++++++++++++++++++
Asrc/combustion/htrdr_combustion_main.c | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/commands/htrdr_cmd.c | 4+++-
Asrc/commands/htrdr_combustion_cmd.c | 24++++++++++++++++++++++++
6 files changed, 128 insertions(+), 3 deletions(-)

diff --git a/cmake/combustion/CMakeLists.txt b/cmake/combustion/CMakeLists.txt @@ -47,9 +47,11 @@ include_directories( # Configure and define targets ################################################################################ set(HTRDR_COMBUSTION_FILES_SRC - htrdr_combustion_args.c) + htrdr_combustion_args.c + htrdr_combustion_main.c) set(HTRDR_COMBUSTION_FILES_INC + htrdr_combustion.h htrdr_combustion_args.h) # Prepend each file in the `HTRDR_FILES_<SRC|INC>' list by `HTRDR_SOURCE_DIR' diff --git a/cmake/commands/CMakeLists.txt b/cmake/commands/CMakeLists.txt @@ -30,7 +30,7 @@ include_directories(${RSys_INCLUDE_DIR}) # Configure and define targets ################################################################################ add_executable(htrdr_cmd ${HTRDR_SOURCE_DIR}/commands/htrdr_cmd.c) -target_link_libraries(htrdr_cmd htrdr-atmosphere) +target_link_libraries(htrdr_cmd htrdr-atmosphere htrdr-combustion) set_target_properties(htrdr_cmd PROPERTIES OUTPUT_NAME htrdr) @@ -40,6 +40,12 @@ target_link_libraries(htrdr_atmosphere_cmd htrdr-atmosphere) set_target_properties(htrdr_atmosphere_cmd PROPERTIES OUTPUT_NAME htrdr-atmosphere) +add_executable(htrdr_combustion_cmd + ${HTRDR_SOURCE_DIR}/commands/htrdr_combustion_cmd.c) +target_link_libraries(htrdr_combustion_cmd htrdr-combustion) +set_target_properties(htrdr_combustion_cmd PROPERTIES + OUTPUT_NAME htrdr-combustion) + ################################################################################ # Define output & install directories ################################################################################ diff --git a/src/combustion/htrdr_combustion.h b/src/combustion/htrdr_combustion.h @@ -0,0 +1,33 @@ +/* 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_H +#define HTRDR_COMBUSTION_H + +#include "core/htrdr.h" +#include <rsys/rsys.h> + +BEGIN_DECLS + +HTRDR_API int +htrdr_combustion_main + (int argc, + char** argv); + +END_DECLS + +#endif /* HTRDR_COMBUSTION_H */ diff --git a/src/combustion/htrdr_combustion_main.c b/src/combustion/htrdr_combustion_main.c @@ -0,0 +1,58 @@ +/* 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.h" +#include "combustion/htrdr_combustion_args.h" + +#include "core/htrdr_log.h" + +#include <rsys/mem_allocator.h> + +int +htrdr_combustion_main(int argc, char** argv) +{ + char cmd_name[] = "htrdr-combustion"; + struct htrdr_combustion_args cmd_args = HTRDR_COMBUSTION_ARGS_DEFAULT; + const size_t memsz_begin = MEM_ALLOCATED_SIZE(&mem_default_allocator); + size_t memsz_end; + res_T res = RES_OK; + int err = 0; + + /* Overwrite command name */ + argv[0] = cmd_name; + + res = htrdr_combustion_args_init(&cmd_args, argc, argv); + if(res != RES_OK) goto error; + if(cmd_args.quit) goto exit; + +exit: + htrdr_combustion_args_release(&cmd_args); + + /* Check memory leaks */ + memsz_end = MEM_ALLOCATED_SIZE(&mem_default_allocator); + if(memsz_begin != memsz_end) { + ASSERT(memsz_end >= memsz_begin); + fprintf(stderr, HTRDR_LOG_WARNING_PREFIX"Memory leaks: %lu Bytes\n", + (unsigned long)(memsz_end - memsz_begin)); + err = -1; + } + return err; +error: + err = -1; + goto exit; +} + diff --git a/src/commands/htrdr_cmd.c b/src/commands/htrdr_cmd.c @@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "atmosphere/htrdr_atmosphere.h" +#include "combustion/htrdr_combustion.h" #include "core/htrdr_version.h" #include <string.h> @@ -76,7 +77,8 @@ main(int argc, char** argv) /* Combustion mode */ } else if(!strcmp(argv[1], "combustion")) { - /* TODO */ + err = htrdr_combustion_main(argc-1, argv+1); + if(err) goto error; /* Version */ } else if(!strcmp(argv[1], "--version")) { diff --git a/src/commands/htrdr_combustion_cmd.c b/src/commands/htrdr_combustion_cmd.c @@ -0,0 +1,24 @@ +/* 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.h" + +int +main(int argc, char** argv) +{ + return htrdr_combustion_main(argc, argv); +}