commit 27d618557562f0b7953aff5325940420e70ca116
parent 8877e4ab8351f7df07d0f32fcf0d8118e0de1ce1
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Thu, 25 Nov 2021 11:52:30 +0100
Add and check the sdis_get_info function
It retrieves informations on the Stardis-Solver library. Currently,
it returns whether the library is compiled with the support of MPI or
not.
Diffstat:
4 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -70,6 +70,7 @@ set(VERSION_PATCH 3)
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(SDIS_FILES_SRC
+ sdis.c
sdis_camera.c
sdis_data.c
sdis_device.c
@@ -192,6 +193,7 @@ if(NOT NO_TEST)
register_test(${_name} ${_name})
endfunction()
+ new_test(test_sdis)
new_test(test_sdis_camera)
new_test(test_sdis_compute_power)
new_test(test_sdis_conducto_radiative)
@@ -242,6 +244,11 @@ if(NOT NO_TEST)
target_link_libraries(test_sdis_solve_probe3_2d ${MATH_LIB})
target_link_libraries(test_sdis_solve_camera Star3DUT)
+ if(USE_MPI)
+ set_target_properties(test_sdis PROPERTIES
+ COMPILE_DEFINITIONS "SDIS_USE_MPI")
+ endif()
+
rcmake_copy_runtime_libraries(test_sdis_solid_random_walk_robustness)
endif()
diff --git a/src/sdis.c b/src/sdis.c
@@ -0,0 +1,32 @@
+/* Copyright (C) 2016-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * 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 "sdis.h"
+
+/*******************************************************************************
+ * Exported function
+ ******************************************************************************/
+res_T
+sdis_get_info(struct sdis_info* info)
+{
+ if(!info) return RES_BAD_ARG;
+ *info = SDIS_INFO_NULL;
+#ifdef SDIS_USE_MPI
+ info->mpi_enable = 1;
+#else
+ info->mpi_enable = 0;
+#endif
+ return RES_OK;
+}
diff --git a/src/sdis.h b/src/sdis.h
@@ -130,6 +130,13 @@ struct sdis_mc {
#define SDIS_MC_NULL__ {0, 0, 0}
static const struct sdis_mc SDIS_MC_NULL = SDIS_MC_NULL__;
+/* Informations on the Stardis-Solver library */
+struct sdis_info {
+ int mpi_enable; /* Define if Stardis-Solver was built with MPI support */
+};
+#define SDIS_INFO_NULL__ {0}
+static const struct sdis_info SDIS_INFO_NULL = SDIS_INFO_NULL__;
+
/*******************************************************************************
* Data type used to describe physical properties
******************************************************************************/
@@ -1308,6 +1315,13 @@ sdis_solve_medium_green_function
const struct sdis_solve_medium_args* args,
struct sdis_green_function** green);
+/*******************************************************************************
+ * Retrieve infos from the Stardis-Solver library
+ ******************************************************************************/
+SDIS_API res_T
+sdis_get_info
+ (struct sdis_info* info);
+
END_DECLS
#endif /* SDIS_H */
diff --git a/src/test_sdis.c b/src/test_sdis.c
@@ -0,0 +1,34 @@
+/* Copyright (C) 2016-2021 |Meso|Star> (contact@meso-star.com)
+ *
+ * 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 "sdis.h"
+#include "test_sdis_utils.h"
+
+int
+main(int argc, char** argv)
+{
+ struct sdis_info info = SDIS_INFO_NULL;
+ (void)argc, (void)argv;
+
+ BA(sdis_get_info(NULL));
+ OK(sdis_get_info(&info));
+#ifdef SDIS_USE_MPI
+ CHK(info.mpi_enable);
+#else
+ CHK(!info.mpi_enable);
+#endif
+ return 0;
+}
+