Skip to content

Commit

Permalink
Merge pull request #70 from rsachetto/eikonal
Browse files Browse the repository at this point in the history
Eikonal
  • Loading branch information
rsachetto authored Jun 6, 2024
2 parents bdbd969 + bb767a2 commit 708f28a
Show file tree
Hide file tree
Showing 21 changed files with 1,551 additions and 40 deletions.
12 changes: 10 additions & 2 deletions bsbash/find_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ FIND_CUDA () {
NVCC=""
CUDA_FOUND=""

LD_CONFIG=ldconfig

if [ "$OS" == "openSUSE Tumbleweed" ]; then
LD_CONFIG=/sbin/ldconfig
fi

if [ -z "$CUDA_LIBRARY_PATH" ]; then
CUDA_LIBRARY_PATH=$(dirname "$(ldconfig -p | grep libcudart | awk '{print $4}' | head -n 1 | head -c -5)" 2> /dev/null)
CUDA_LIBRARY_PATH=$(dirname "$($LD_CONFIG -p | grep libcudart | awk '{print $4}' | head -n 1 | head -c -5)" 2> /dev/null)
fi

if [ -z "$CUDA_INCLUDE_PATH" ]; then
Expand All @@ -19,6 +25,8 @@ FIND_CUDA () {
elif [ "$OS" == "Fedora" ]; then
CUDA_INCLUDE_PATH="/usr/local/cuda/include"
CUDA_LIBRARY_PATH="/usr/local/cuda/lib64"
elif [ "$OS" == "openSUSE Tumbleweed" ]; then
CUDA_INCLUDE_PATH="/usr/local/cuda/include"
else
if [ "$CI" = true ]; then
CUDA_INCLUDE_PATH='/usr/local/cuda/include'
Expand Down Expand Up @@ -120,7 +128,7 @@ FIND_MPI () {
}

FIND_AMGX() {
AMGX_LIBRARIES=""
AMGX_LIBRARIES="amgxsh"
AMGX_LIBRARY_PATH=""
AMGX_INCLUDE_PATH=""
AMGX_FOUND=""
Expand Down
8 changes: 7 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ for i in "${BUILD_ARGS[@]}"; do
COMPILE_POSTPROCESSOR='y'
COMPILE_EXPAND='y'
COMPILE_CLIP='y'
COMPILE_EIKONAL='y'
;;
simulator)
COMPILE_SIMULATOR='y'
Expand Down Expand Up @@ -184,6 +185,7 @@ ADD_SUBDIRECTORY "src/3dparty/tinyexpr"
ADD_SUBDIRECTORY "src/3dparty/miniz"
ADD_SUBDIRECTORY "src/vtk_utils"
ADD_SUBDIRECTORY "src/ensight_utils"
ADD_SUBDIRECTORY "src/eikonal/"


#DINAMIC DEPS
Expand Down Expand Up @@ -264,7 +266,6 @@ if [ -n "$COMPILE_MPI" ]; then
COMPILE_EXECUTABLE "MonoAlg3D_batch" "$SRC_FILES" "$HDR_FILES" "$STATIC_DEPS" "$DYNAMIC_DEPS" "$EXECUTABLES_LIBRARY_PATH $EXTRA_LIB_PATH" "$INCLUDE_P -I$MPI_INCLUDE_PATH"
fi


fi

fi
Expand Down Expand Up @@ -294,6 +295,11 @@ if [ -n "$COMPILE_CLIP" ]; then
COMPILE_EXECUTABLE "MonoAlg3D_clip_mesh" "src/main_clip_mesh.c" "" "$STATIC_DEPS" "$DYNAMIC_DEPS" "$EXECUTABLES_LIBRARY_PATH $EXTRA_LIB_PATH"
fi

if [ -n "$COMPILE_EIKONAL" ]; then
COMPILE_EXECUTABLE "MonoAlg3D_eikonal_solver" "src/main_eikonal.c" "" "$STATIC_DEPS" "$DYNAMIC_DEPS eikonal_solver" "$EXECUTABLES_LIBRARY_PATH $EXTRA_LIB_PATH"
fi


FIND_CRITERION

if [ -n "$CRITERION_FOUND" ]; then
Expand Down
10 changes: 6 additions & 4 deletions example_configs/plain_mesh_no_fibrosis_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ file_prefix=V
[assembly_matrix]
init_function=set_initial_conditions_fvm
sigma_x=0.0000176
sigma_y=0.0001334
sigma_y=0.0000176
sigma_z=0.0000176
library_file=shared_libs/libdefault_matrix_assembly.so
main_function=homogeneous_sigma_assembly_matrix
Expand Down Expand Up @@ -65,7 +65,9 @@ start = 0.0
duration = 2.0
period = 250.0
current = -50.0
x_limit = 100.0
main_function=stim_if_x_less_than
min_x = 0.0
max_x = 400.0
min_y = 0.0
max_y = 400.0
main_function=stim_x_y_limits
;////////////////////////////////////////////////

42 changes: 39 additions & 3 deletions src/common_types/common_types.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef MONOALG3D_COMMON_TYPES_H
#define MONOALG3D_COMMON_TYPES_H

#include "../3dparty/sds/sds.h"
#include <stdbool.h>
#include <stdint.h>
#include "../3dparty/sds/sds.h"

#define Pragma(x) _Pragma(#x)
#define OMP(directive) Pragma(omp directive)
Expand All @@ -17,6 +17,42 @@ typedef double real;
typedef float real;
#endif

#define EPS (real)1e-16

#define ALLOCATE_3D_ARRAY(array, type, size_x, size_y, size_z) \
do { \
array = (type ***)malloc(size_x * sizeof(type **)); \
\
if(array == NULL) { \
log_error_and_exit("Memory allocation failed for first dimension\n"); \
} \
\
for(int i = 0; i < size_x; ++i) { \
array[i] = (type **)malloc(size_y * sizeof(type *)); \
if(array[i] == NULL) { \
log_error_and_exit("Memory allocation failed for second dimension\n"); \
} \
\
for(int j = 0; j < size_y; ++j) { \
array[i][j] = (type *)calloc(size_z, sizeof(type)); \
if(array[i][j] == NULL) { \
log_error_and_exit("Memory allocation failed for third dimension\n"); \
} \
} \
} \
} while(0)

#define FREE_3D_ARRAY(array, size_x, size_y) \
do { \
for(int i = 0; i < size_x; ++i) { \
for(int j = 0; j < size_y; ++j) { \
free(array[i][j]); \
} \
free(array[i]); \
} \
free(array); \
} while(0)

#define MALLOC_BYTES(type, bytes) (type *)malloc(bytes)
#define MALLOC_ONE_TYPE(type) (type *)malloc(sizeof(type))
#define MALLOC_ARRAY_OF_TYPE(type, n) (type *)malloc(sizeof(type) * (n))
Expand Down Expand Up @@ -142,8 +178,8 @@ struct simulation_files {
#define STRING_HASH_PRINT_KEY_VALUE_LOG(tag, d) \
do { \
for(int64_t __i = 0; __i < shlen(d); __i++) { \
struct string_hash_entry __e = (d)[__i]; \
log_info("%s %s = %s\n", tag, __e.key, __e.value); \
struct string_hash_entry __e = (d)[__i]; \
log_info("%s %s = %s\n", tag, __e.key, __e.value); \
} \
} while(0)

Expand Down
34 changes: 17 additions & 17 deletions src/config/config_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ void init_config_functions(struct config *config, char *default_lib, char *confi
do { \
if((s) == NULL) { \
log_info(tag " no configuration.\n"); \
return; \
} else { \
log_info(tag " configuration:\n"); \
log_info(tag " library = %s\n", (s)->library_file_path); \
log_info(tag " main function = %s\n", (s)->main_function_name); \
\
if((s)->init_function_name) { \
log_info(tag " init function = %s\n", (s)->init_function_name); \
} \
\
if((s)->end_function_name) { \
log_info(tag " end function = %s\n", (s)->end_function_name); \
} \
\
for(int __i = 0; __i < arrlen((s)->extra_function_names); __i++) { \
log_info(tag " extra function %d = %s\n", __i+1, (s)->extra_function_names[__i]); \
} \
STRING_HASH_PRINT_KEY_VALUE_LOG(tag, (s)->config_data); \
} \
log_info(tag " configuration:\n"); \
log_info(tag " library = %s\n", (s)->library_file_path); \
log_info(tag " main function = %s\n", (s)->main_function_name); \
\
if((s)->init_function_name) { \
log_info(tag " init function = %s\n", (s)->init_function_name); \
} \
\
if((s)->end_function_name) { \
log_info(tag " end function = %s\n", (s)->end_function_name); \
} \
\
for(int __i = 0; __i < arrlen((s)->extra_function_names); __i++) { \
log_info(tag " extra function %d = %s\n", __i+1, (s)->extra_function_names[__i]); \
} \
STRING_HASH_PRINT_KEY_VALUE_LOG(tag, (s)->config_data); \
} while(0)

#define CALL_EXTRA_FUNCTIONS(fn, ...) \
Expand Down
Loading

0 comments on commit 708f28a

Please sign in to comment.