Skip to content

Commit

Permalink
Merging Sachetto changes --> update_monodomain_library has been added!
Browse files Browse the repository at this point in the history
  • Loading branch information
bergolho committed Mar 14, 2019
2 parents 20872fb + d209f26 commit 6240b68
Show file tree
Hide file tree
Showing 130 changed files with 36,713 additions and 33,875 deletions.
2 changes: 1 addition & 1 deletion .idea/MonoAlg3D.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 37 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ IF(EXISTS "/etc/manjaro-release")
set(CMAKE_CXX_COMPILER "/opt/cuda/bin/g++")
ENDIF(EXISTS "/etc/manjaro-release")

IF(EXISTS "/etc/debconf.conf")
set(CMAKE_C_COMPILER "/usr/bin/gcc-6")
set(CMAKE_CXX_COMPILER "/usr/bin/g++-6")
ENDIF(EXISTS "/etc/debconf.conf")
#IF(EXISTS "/etc/debconf.conf")
# set(CMAKE_C_COMPILER "/usr/bin/gcc-6")
# set(CMAKE_CXX_COMPILER "/usr/bin/g++-6")
#ENDIF(EXISTS "/etc/debconf.conf")


cmake_minimum_required(VERSION 3.0.1)
Expand Down Expand Up @@ -41,11 +41,11 @@ SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared_libs )

IF(MSVC)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w" )
ADD_SUBDIRECTORY(src/getopt)
ADD_SUBDIRECTORY(src/dlfcn-win32)
SET(OPT_DEPS getopt)
ELSE()
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -Wall -Wno-unused-function")
IF(CMAKE_BUILD_TYPE MATCHES DEBUG)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer" )
ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG)
ENDIF()

FIND_PACKAGE(OpenMP)
Expand Down Expand Up @@ -78,42 +78,43 @@ IF (CUDA_FOUND)
ENDIF()
ENDIF()

ADD_SUBDIRECTORY(src/gpu_utils)
SET(OPT_DEPS gpu_utils)

ENDIF(CUDA_FOUND)

SET(OpenGL_GL_PREFERENCE "GLVND")

FIND_PACKAGE(OpenGL)

IF(OPENGL_FOUND AND OPENMP_FOUND)
IF(MSVC)
#SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I \"${GLUT_INCLUDE_DIR}\" -DCOMPILE_OPENGL")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOMPILE_OPENGL")
ELSE()
#SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I \"${OPENGL_INCLUDE_DIR}\" -I \"${GLUT_INCLUDE_DIR}\" -DCOMPILE_OPENGL")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOMPILE_OPENGL")
ENDIF()

set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games

# # build raylib
ADD_SUBDIRECTORY(src/raylib/src)

ADD_SUBDIRECTORY(src/draw)

SET(OPT_DEPS ${OPT_DEPS} draw raylib)
IF(NOT MSVC AND OPENGL_FOUND AND OPENMP_FOUND)
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCOMPILE_OPENGL")
ENDIF()

ADD_SUBDIRECTORY(src/utils)
ADD_SUBDIRECTORY(src/alg)
ADD_SUBDIRECTORY(src/monodomain)
ADD_SUBDIRECTORY(src/hash)
ADD_SUBDIRECTORY(src/ini_parser)
ADD_SUBDIRECTORY(src/string)
ADD_SUBDIRECTORY(src/config)
ADD_SUBDIRECTORY(src/graph)
ADD_SUBDIRECTORY(src/vtk_utils)

IF(NOT MSVC AND OPENGL_FOUND AND OPENMP_FOUND)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
ADD_SUBDIRECTORY(src/raylib/src)
ADD_SUBDIRECTORY(src/draw)
SET(OPT_DEPS ${OPT_DEPS} draw raylib)
ENDIF()

IF(MSVC)
ADD_SUBDIRECTORY(src/getopt)
ADD_SUBDIRECTORY(src/dlfcn-win32)
SET(OPT_DEPS ${OPT_DEPS} getopt)
ENDIF()

IF (CUDA_FOUND)
ADD_SUBDIRECTORY(src/gpu_utils)
SET(OPT_DEPS ${OPT_DEPS} gpu_utils)
ENDIF()

#SET(COMPILE_GUI FALSE)
#
Expand All @@ -131,21 +132,21 @@ ADD_SUBDIRECTORY(src/graph)
#ENDIF()

ADD_EXECUTABLE(MonoAlg3D src/main.c)
ADD_DEPENDENCIES(MonoAlg3D utils alg solvers hashes ini_parser string graph config ${OPT_DEPS})
ADD_DEPENDENCIES(MonoAlg3D utils alg solvers ini_parser string graph config ${OPT_DEPS})

FIND_PACKAGE(MPI)
IF(MPI_C_FOUND)
INCLUDE_DIRECTORIES(${MPI_C_INCLUDE_PATH})
ADD_EXECUTABLE(MonoAlg3D_batch src/main_batch.c)
ADD_DEPENDENCIES(MonoAlg3D_batch utils alg solvers hashes ini_parser string graph config ${OPT_DEPS})
TARGET_LINK_LIBRARIES(MonoAlg3D_batch alg solvers utils hashes ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} ${MPI_C_LIBRARIES} dl m)
ADD_DEPENDENCIES(MonoAlg3D_batch utils alg solvers ini_parser string graph config ${OPT_DEPS})
TARGET_LINK_LIBRARIES(MonoAlg3D_batch alg solvers utils ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} ${MPI_C_LIBRARIES} dl m)
ENDIF(MPI_C_FOUND)

IF(MSVC)
TARGET_LINK_LIBRARIES(MonoAlg3D alg solvers utils hashes ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} dl)
TARGET_LINK_LIBRARIES(MonoAlg3D alg solvers utils ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} dl)
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/shared_libs )
ELSE()
TARGET_LINK_LIBRARIES(MonoAlg3D alg solvers utils hashes ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} dl m)
TARGET_LINK_LIBRARIES(MonoAlg3D alg solvers utils ini_parser string graph config ${OPT_DEPS} ${CUDA_LIBRARIES} dl m)
ENDIF()

ADD_SUBDIRECTORY(src/models_library)
Expand All @@ -161,7 +162,9 @@ ADD_SUBDIRECTORY(src/linear_system_solver_library)
ADD_SUBDIRECTORY(src/save_mesh_library)
ADD_SUBDIRECTORY(src/save_state_library)
ADD_SUBDIRECTORY(src/restore_state_library)
ADD_SUBDIRECTORY(src/update_monodomain_library)

SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests_bin )

ADD_SUBDIRECTORY(src/tests)

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ $ bin/MonoAlg3D -c example_configs/cuboid_ohara.ini
The output will be saved in the VTK format. In order to see the results you can use Paraview (https://www.paraview.org/). You can also set the output to plain text, by changing the option ```vtk_output``` to false in the configuration file. The text format is defined as following:

- Each line represents a Volume
- Each volume is represented by its center point (X, Y, and Z), the value of halt of its side length and the calculated V
- Each volume is represented by its center point (X, Y, and Z), the value of half of its side length and the calculated V

Example file:

Expand Down
2 changes: 1 addition & 1 deletion ToDo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Sachetto
- Rewrite the GUI using raygui https://github.com/raysan5/raygui
- Rewrite the flags parsing using: https://github.com/kgabis/kgflags/blob/master/examples/full_api.c
- Correct the domain version that sets the two scars and the fibrosis from file (maybe the error is on extra-data)
- Compare the mesh with the mesh from the scientific reports paper
- Use a sparse matrix format and take the matrix out of the alg mesh (http://people.sc.fsu.edu/~jburkardt/c_src/csparse/csparse.html)
Expand Down
16 changes: 14 additions & 2 deletions clean_project.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
#!/bin/bash
cd build; rm -r *; cd ..
cd bin; rm *

BUILD_DIR="build"

if [[ "$#" -eq 1 ]]; then
BUILD_DIR=$1
fi

if [[ ! -d "${BUILD_DIR}" ]]; then
echo "Directory ${BUILD_DIR} does not exist"
exit
fi

rm -fr ${BUILD_DIR}/*
rm -fr bin/*
4 changes: 2 additions & 2 deletions example_configs/gold_simulation_no_adapt.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use_adaptivity=false
[save_result]
;/////mandatory/////////
print_rate=50
output_dir=./tests_bin/gold_simulation_no_adapt_gpu
output_dir=./outputs/gold_simulation_no_adapt_gpu
function=save_as_text_or_binary
;function=save_as_vtu
;binary=false
Expand Down Expand Up @@ -49,4 +49,4 @@ start = 10.0
duration = 2.0
current = -38.0
x_limit = 500.0
function=stim_if_x_less_than
function=stim_if_x_less_than
2 changes: 1 addition & 1 deletion example_configs/mouse_mesh_config_example.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
num_threads=4
dt_pde=0.02
simulation_time=0.3
simulation_time=100.0
abort_on_no_activity=false
use_adaptivity=true
start_adapting_at=1.2
Expand Down
2 changes: 2 additions & 0 deletions example_configs/plain_mesh_ddm_2d.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ save_pvd=true
;//////////////////
file_prefix=V

[update_monodomain]
function=update_monodomain_ddm

[assembly_matrix]
sigma_x=0.00176
Expand Down
4 changes: 2 additions & 2 deletions example_configs/plain_mesh_no_fibrosis_example.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
num_threads=2
num_threads=4
dt_pde=0.02
simulation_time=100.0
simulation_time=200.0
abort_on_no_activity=false
use_adaptivity=false

Expand Down
14 changes: 8 additions & 6 deletions example_configs/plain_mesh_with_fibrosis.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use_adaptivity=false
;/////mandatory/////////
print_rate=50
output_dir=./outputs/atpi_2_Ko_8_acidosis_single_cell
function=save_as_text_or_binary
;function=save_as_text_or_binary
function=save_as_vtu
save_pvd=true
;//////////////////
file_prefix=V

Expand All @@ -32,7 +34,7 @@ start_dx=100.0
start_dy=100.0
start_dz=100.0
side_length=10000.0
;seed=1505958974
seed=1505958974
phi=0.36
function=initialize_grid_with_plain_fibrotic_mesh

Expand All @@ -50,10 +52,10 @@ x_limit = 500.0
function=stim_if_x_less_than

[extra_data]
atpi=2.0
Ko=8.0
atpi=4.0
;Ko=8.0
;These paremeters below are for acidosis
;Ki_multiplicator=1.0
Ki_multiplicator=0.863259669
Ki_multiplicator=1.0
;Ki_multiplicator=0.863259669
acidosis=true
function=set_extra_data_for_fibrosis_plain
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use_adaptivity=false
/////mandatory/////////
print_rate=50
output_dir=./outputs/plain_and_circle
function=save_as_vtu
save_pvd=true
function=save_as_vtk
;save_pvd=true
//////////////////
file_prefix=V

Expand All @@ -36,8 +36,8 @@ function=initialize_grid_with_plain_and_sphere_fibrotic_mesh
;this are optional
num_layers=1
side_length=40000
seed=1508201274
phi=0.62
;seed=1508201274
phi=0.55
plain_center=20050.0
sphere_radius=14000.0
border_zone_radius=16000.0
Expand Down
2 changes: 1 addition & 1 deletion example_configs/valgring_run.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[main]
num_threads=1
dt_pde=0.02
simulation_time=3.0
simulation_time=2.0
abort_on_no_activity=false
vm_threshold=-86.0
use_adaptivity=true
Expand Down
Binary file added misc/Roboto-Black.ttf
Binary file not shown.
21 changes: 20 additions & 1 deletion recompile_project.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
#!/bin/bash
cd build; cmake ..; make

BUILD_DIR="build"
BUILD_TYPE="Release"

if [[ "$#" -eq 1 ]]; then
BUILD_DIR=$1
fi

if [[ "$#" -eq 2 ]]; then
BUILD_DIR=$1
BUILD_TYPE=$2
fi


if [[ ! -d "${BUILD_DIR}" ]]; then
echo "Directory ${BUILD_DIR} does not exist. Creating."
mkdir ${BUILD_DIR}
fi

cd ${BUILD_DIR}; cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ..; make
2 changes: 1 addition & 1 deletion scripts/animations/convert_png_to_mp4.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ OUTPUT_VIDEO_FILENAME="video/ddm_3d"
RESOLUTION="1020x720"

# Execute the converting command using FFMPEG
ffmpeg -r $FRAME_RATE -f image2 -s $RESOLUTION -start_number 1 -i $FILENAME.%04d.png -vframes $END_FRAME -vcodec libx264 -crf 25 -pix_fmt yuv420p $OUTPUT_VIDEO_FILENAME.mp4
ffmpeg -r ${FRAME_RATE} -f image2 -s ${RESOLUTION} -start_number 1 -i ${FILENAME}.%04d.png -vframes ${END_FRAME} -vcodec libx264 -crf 25 -pix_fmt yuv420p ${OUTPUT_VIDEO_FILENAME}.mp4
13 changes: 8 additions & 5 deletions scripts/calc_APD.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from sys import argv


def forwarddiff(y, h):
n = len(y)
res = []
i = 1

for i in range(1,n):
res.append((y[i] - y[i-1]) / h);
for i in range(1, n):
res.append((y[i] - y[i-1]) / h)

return res


def slope_start(data, start=0, epsilon=0.0001, h=1.0):

d = data[start:]
Expand All @@ -19,6 +20,7 @@ def slope_start(data, start=0, epsilon=0.0001, h=1.0):
if abs(d[i] - d[i-1]/h) > epsilon:
return i+start


def slope_end(data, start=0, epsilon=0.0001, h=1.0):

d = data[start:]
Expand All @@ -29,7 +31,6 @@ def slope_end(data, start=0, epsilon=0.0001, h=1.0):
return i+start



def max_index(data, start, end):

d = data[start:(start+end)]
Expand All @@ -40,13 +41,15 @@ def max_index(data, start, end):

return max_index


def index_activation(data, start=0):
d = data[start:]

for i, v in enumerate(d):
if d[i+start] < 0.0 and d[i+start+1] > 0.0:
if d[i + start] < 0.0 < d[i + start + 1]:
return i+start


ap_file_name = argv[1]
num_aps = int(argv[2])
ms_each_step = float(argv[3])
Expand Down
5 changes: 3 additions & 2 deletions scripts/getAps.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
AP_DIR=$1
AP_PREFIX=$2
AP_LINE=$3
AP_OUT=$4
CELL_ID=$5

if [ "$#" -ne 5 ]; then
if [[ "$#" -ne 5 ]]; then
echo "-------------------------------------------------------------------"
echo "Usage:> $0 <AP_DIR> <AP_PREFIX> <AP_LINE> <AP_OUT> <CELL_ID>"
echo "-------------------------------------------------------------------"
Expand All @@ -24,5 +25,5 @@ if [ "$#" -ne 5 ]; then
exit 1
fi

for i in `ls -1v ${AP_DIR}/${AP_PREFIX}*`; do sed -n "${AP_LINE}p" $i | awk -v "col=${CELL_ID}" -F ' ' '{print $col}' ; done > output/${AP_OUT}.txt
for i in `ls -1v ${AP_DIR}/${AP_PREFIX}*`; do sed -n "${AP_LINE}p" ${i} | awk -v "col=${CELL_ID}" -F ' ' '{print $col}' ; done > output/${AP_OUT}.txt

Loading

0 comments on commit 6240b68

Please sign in to comment.