Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Bioelectrics/Monodomain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# OpenCMISS (Open Continuum Mechanics, Imaging, Signal processing and System identification)
# is a mathematical modelling environment that enables the application of finite element
# analysis techniques to a variety of complex bioengineering problems.
#
# The OpenCMISS project website can be found at http://www.opencmiss.org
# For more information see http://www.opencmiss.org/documentation

# Include the OpenCMISS initalisation & macro definition file.
include(./OpenCMISS.cmake)
message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}")

set(CMAKE_C_COMPILER mpiicc)
set(CMAKE_Fortran_COMPILER mpiifort)

# Project setup
# -------------
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

option(USE_MPI "Use MPI" ON)

project(OpenCMISS-Example VERSION 1.0 LANGUAGES C Fortran)
enable_testing()

message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}")
message(STATUS "MPI: ${MPI}")
message(STATUS "Instrumentation: ${OC_INSTRUMENTATION}")


# Find OpenCMISS
# --------------
#
# This call tries to find a matching OpenCMISS (SDK) installation for your (default) Toolchain and MPI choice.
# Currently available OpenCMISS package components: Iron Zinc
# Requiring Iron will also include the iron_c bindings target if available.
#
# This function creates a link target 'opencmiss' that contains references to the requested OpenCMISS components.
# For Iron, it also adds the necessary MPI information - no further find_package(MPI ..) and setting of extra include
# paths needed!
#find_package(OpenCMISS 1.1 REQUIRED COMPONENTS Iron CONFIG)
#find_package(MPI REQUIRED)

# CMake application code
# ----------------------
if (CMAKE_Fortran_COMPILER)
add_subdirectory(Fortran)
endif()
53 changes: 53 additions & 0 deletions Bioelectrics/Monodomain/Fortran/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Add example executable
link_directories(/data/OpenCMISS/install/x86_64_linux/intel-C17.0-intel-F17.0/intel_release/lib)
add_executable(MonodomainFortran src/FortranExample.f90)

# Turn on Fortran preprocessing (#include directives)
if (MSVC)
set(PROC_OPT "/fpp")
else()
set(PROC_OPT "-cpp")
endif()
target_compile_options(MonodomainFortran PRIVATE ${PROC_OPT})

# Link to opencmiss
# -----------------
#
# This simply uses the opencmiss target created by OC_INIT() above.
#
# Alternatively, you can also directly invoke 'find_package(Iron <IRON_VERSION>)' to explicitly
# require that version. But then you have to deal with setting up the correct MPI include directives and library paths.
#
# If required, add any other required link libraries (cellml, petsc ..) here, too.
# For example, if you needed PetSC functionality, issue
#
# find_package(PETSC <PETSC_VERSION> REQUIRED)
# target_link_libraries(${EXAMPLE_BINARY} PRIVATE petsc)
#
# All the OpenCMISS dependencies provide a target you can link against corresponding to the (lowercase) component name.
target_link_libraries(MonodomainFortran PRIVATE libirond.so)
target_include_directories(MonodomainFortran
PRIVATE /data/OpenCMISS/install/x86_64_linux/intel-C17.0-intel-F17.0/intel_release/include/opencmiss)
target_include_directories(MonodomainFortran PRIVATE /opt/intel/compilers_and_libraries_2017.1.132/linux/mpi/intel64/include)
# Add a simple test that runs the executable
add_test(NAME MonodomainFortranTest COMMAND MonodomainFortran)
#add_opencmiss_environment(MonodomainFortranTest)

###################
# Developer notice!
#
# If you write Fortran code and use MPI, you need to use the following MPI directives:
#
# #ifndef NOMPIMOD
# USE MPI
# #endif
# [...]
# IMPLICIT NONE
# [...]
# #ifdef NOMPIMOD
# #include "mpif.h"
# #endif
#
# Reasoning: In some cases like Windows/MPICH2 there sometimes is no mpi.mod file. In order to yet make
# the example work the build system adds the definition 'NOMPIMOD', which can be checked and acted to accordingly.
#
2 changes: 1 addition & 1 deletion Bioelectrics/Monodomain/Fortran/src/FortranExample.f90
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ PROGRAM MONODOMAINEXAMPLE

REAL(CMISSRP) :: X,Y,DISTANCE,gNa_VALUE

INTEGER(CMISSIntg), PARAMETER :: NUMBER_OF_ELEMENTS=25
INTEGER(CMISSIntg), PARAMETER :: NUMBER_OF_ELEMENTS=10
INTEGER(CMISSIntg) :: OUTPUT_FREQUENCY = 1
REAL(CMISSRP), PARAMETER :: STIM_VALUE = 100.0_CMISSRP
REAL(CMISSRP), PARAMETER :: STIM_STOP = 0.10_CMISSRP
Expand Down
51 changes: 51 additions & 0 deletions Bioelectrics/Monodomain/Fortran/visualise.cmgui
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
gfx read node MonodomainExample.part0.exnode;
gfx read element MonodomainExample.part0.exelem;
gfx read node Time_2_1.part0.exnode
#gfx read node Time_2_2.part0.exnode time 2
#gfx read node Time_2_3.part0.exnode time 3
#gfx read node Time_2_4.part0.exnode time 4
#gfx read node Time_2_5.part0.exnode time 5
#gfx read node Time_2_6.part0.exnode time 6
#gfx read node Time_2_7.part0.exnode time 7
#gfx read node Time_2_8.part0.exnode time 8
#gfx read node Time_2_9.part0.exnode time 9
#gfx read node Time_2_10.part0.exnode time 10
#gfx read node Time_2_11.part0.exnode time 11
#gfx read node Time_2_12.part0.exnode time 12
#gfx read node Time_2_13.part0.exnode time 13
#gfx read node Time_2_14.part0.exnode time 14
#gfx read node Time_2_15.part0.exnode time 15
#gfx read node Time_2_16.part0.exnode time 16
#gfx read node Time_2_17.part0.exnode time 17
#gfx read node Time_2_18.part0.exnode time 18
#gfx read node Time_2_19.part0.exnode time 19
#gfx read node Time_2_20.part0.exnode time 20
#gfx read node Time_2_21.part0.exnode time 21
#gfx read node Time_2_22.part0.exnode time 22
#gfx read node Time_2_23.part0.exnode time 23
#gfx read node Time_2_24.part0.exnode time 24
#gfx read node Time_2_25.part0.exnode time 25
#gfx read node Time_2_26.part0.exnode time 26
#gfx read node Time_2_27.part0.exnode time 27
#gfx read node Time_2_28.part0.exnode time 28
#gfx read node Time_2_29.part0.exnode time 29
#gfx read node Time_2_30.part0.exnode time 30

#@exnodes=<./Time_*.part*.exnode>;
#$time_index=1;
#foreach $filename (@exnodes) {
# print "Reading $filename\n";
# gfx read node "$filename" time $time_index;
# $time_index++;
#}
gfx define faces egroup Region;
gfx create window 1;
gfx modify window 1 background colour 1.0 1.0 1.0;
gfx modify window 1 view interest_point 0.5,0.5,0.0 eye_point 0.5,0.5,3.0 up_vector 0.0,1.0,0.0;
gfx modify spectrum default clear overwrite_colour;
gfx modify spectrum default linear reverse range -95.0 50.0 extend_above extend_below rainbow colour_range 0 1 component 1;
gfx modify spectrum default linear reverse range -95.0 50.0 banded number_of_bands 10 band_ratio 0.05 component 1;
gfx modify g_element Region lines material black;
gfx modify g_element Region surfaces select_on coordinate Coordinate material default data Vm spectrum default selected_material default_selected render_shaded;
gfx print jpg window 1 file gNa.jpg;
gfx print postscript window 1 file gNa.ps;
97 changes: 97 additions & 0 deletions Bioelectrics/Monodomain/OpenCMISS.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
###########################
# *DO NOT CHANGE THIS FILE*
###########################
#
# Prepares the use of OpenCMISS by scanning at various path locations for OpenCMISS (SDK) installations.
#
# Search order:
# - OPENCMISS_INSTALL_DIR variable
# - OPENCMISS_INSTALL_DIR environment variable
# - OPENCMISS_SDK_DIR variable
# - OPENCMISS_SDK_DIR environment variable
# - [Windows only] The Registry is searched additionally for installed SDKs.
#
# If found
# - Includes the toolchain config script of the found opencmiss installation to enable toolchain selection logic (non-windows)

# Convenience: The OPENCMISS_INSTALL_DIR may also be defined in the environment and various other places
if (DEFINED OPENCMISS_INSTALL_DIR)
get_filename_component(OPENCMISS_INSTALL_DIR "${OPENCMISS_INSTALL_DIR}" ABSOLUTE)
if (EXISTS "${OPENCMISS_INSTALL_DIR}")
message(STATUS "Using specified installation directory '${OPENCMISS_INSTALL_DIR}'")
else()
message(WARNING "The specified OPENCMISS_INSTALL_DIR '${OPENCMISS_INSTALL_DIR}' does not exist. Skipping.")
unset(OPENCMISS_INSTALL_DIR)
endif()
endif()
if(NOT OPENCMISS_INSTALL_DIR AND NOT "$ENV{OPENCMISS_INSTALL_DIR}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{OPENCMISS_INSTALL_DIR}" OPENCMISS_INSTALL_DIR)
get_filename_component(OPENCMISS_INSTALL_DIR "${OPENCMISS_INSTALL_DIR}" ABSOLUTE)
if (EXISTS "${OPENCMISS_INSTALL_DIR}")
message(STATUS "Using environment installation directory '${OPENCMISS_INSTALL_DIR}'")
else()
message(WARNING "The environment variable OPENCMISS_INSTALL_DIR='${OPENCMISS_INSTALL_DIR}' contains an invalid path. Skipping.")
unset(OPENCMISS_INSTALL_DIR)
endif()
endif()
if (NOT OPENCMISS_INSTALL_DIR AND DEFINED OPENCMISS_SDK_DIR)
get_filename_component(OPENCMISS_SDK_DIR "${OPENCMISS_SDK_DIR}" ABSOLUTE)
if (EXISTS "${OPENCMISS_SDK_DIR}")
message(STATUS "Using SDK installation directory: ${OPENCMISS_SDK_DIR}")
set(OPENCMISS_INSTALL_DIR "${OPENCMISS_SDK_DIR}")
else()
message(WARNING "The specified OPENCMISS_SDK_DIR '${OPENCMISS_SDK_DIR}' does not exist. Skipping.")
endif()
endif()
if(NOT OPENCMISS_INSTALL_DIR AND NOT "$ENV{OPENCMISS_SDK_DIR}" STREQUAL "")
file(TO_CMAKE_PATH "$ENV{OPENCMISS_SDK_DIR}" OPENCMISS_SDK_DIR)
get_filename_component(OPENCMISS_SDK_DIR "${OPENCMISS_SDK_DIR}" ABSOLUTE)
if (EXISTS "${OPENCMISS_SDK_DIR}")
message(STATUS "Using environment SDK installation directory: ${OPENCMISS_SDK_DIR}")
set(OPENCMISS_INSTALL_DIR "${OPENCMISS_SDK_DIR}")
else()
message(WARNING "The environment variable OPENCMISS_SDK_DIR='${OPENCMISS_SDK_DIR}' contains an invalid path. Skipping.")
unset(OPENCMISS_SDK_DIR)
endif()
endif()
# On windows: check the registry for installed OpenCMISS SDKs
if(NOT OPENCMISS_INSTALL_DIR AND WIN32)
foreach(ROOT HKEY_CURRENT_USER HKEY_LOCAL_MACHINE)
foreach(PACKAGE OpenCMISSUserSDK OpenCMISSDeveloperSDK)
set(_REG_KEY "[${ROOT}\\Software\\Auckland Bioengineering Institute\\${PACKAGE}]")
get_filename_component(OPENCMISS_INSTALL_DIR "${_REG_KEY}" ABSOLUTE)
#message(STATUS "Trying registry key ${_REG_KEY}: ${OPENCMISS_INSTALL_DIR}")
if (EXISTS "${OPENCMISS_INSTALL_DIR}")
message(STATUS "Found ${PACKAGE} in Windows registry key ${_REG_KEY}: ${OPENCMISS_INSTALL_DIR}")
break()
else()
unset(OPENCMISS_INSTALL_DIR)
endif()
endforeach()
if (EXISTS "${OPENCMISS_INSTALL_DIR}")
break()
endif()
endforeach()
endif()

if(OPENCMISS_INSTALL_DIR)
message(STATUS "OPENCMISS_INSTALL_DIR=${OPENCMISS_INSTALL_DIR}")
# Use the OpenCMISS scripts to also allow choosing a separate toolchain
# This file is located at the opencmiss installation rather than the local example
# as it avoids file replication and makes maintenance much easier
if (TOOLCHAIN)
set(_OCTC ${OPENCMISS_INSTALL_DIR}/share/cmake/Modules/OpenCMISS/OCToolchainCompilers.cmake)
if (EXISTS "${_OCTC}")
include(${_OCTC})
else()
message(WARNING "TOOLCHAIN specified but OpenCMISS config script could not be found at ${_OCTC}. Trying CMake defaults.")
endif()
unset(_OCTC)
endif()
set(OpenCMISS_DIR "${OPENCMISS_INSTALL_DIR}" CACHE PATH "Path to the found OpenCMISS (SDK) installation")
else()
message(WARNING "No OpenCMISS (SDK) installation directory detected. Using default system environment.")
endif()

message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}")
6 changes: 3 additions & 3 deletions Bioelectrics/Monodomain/Python/Monodomain2DSquare.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
sys.path.insert(1, os.path.join((os.environ['OPENCMISS_ROOT'],'cm','bindings','python')))

# Intialise OpenCMISS
from opencmiss import iron
from opencmiss.iron import iron
#DOC-END imports

# Set problem parameters
Expand All @@ -25,10 +25,10 @@
# Simulation parameters
stimValue = 100.0
stimStop = 0.1
timeStop = 1.5
timeStop = 4.0
odeTimeStep = 0.00001
pdeTimeStep = 0.001
outputFrequency = 1
outputFrequency = 10
#DOC-END parameters

#Setup field number handles
Expand Down
25 changes: 25 additions & 0 deletions ClassicalField/Laplace/Laplace/C/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add example executable
add_executable(laplace_c src/CExample.c)

#
# Link to opencmiss
# -----------------
#
# This simply uses the opencmiss target created by OC_INIT() above.
#
# Alternatively, you can also directly invoke 'find_package(Iron <IRON_VERSION>)' to explicitly
# require that version. But then you have to deal with setting up the correct MPI include directives and library paths.
#
# If required, add any other required link libraries (cellml, petsc ..) here, too.
# For example, if you needed PetSC functionality, issue
#
# find_package(PETSC <PETSC_VERSION> REQUIRED)
# target_link_libraries(${EXAMPLE_BINARY} PRIVATE petsc)
#
# All the OpenCMISS dependencies provide a target you can link against corresponding to the (lowercase) component name.
target_link_libraries(laplace_c PRIVATE opencmiss)
target_link_libraries(laplace_c PUBLIC $<BUILD_INTERFACE:mpi>)

# Add a simple test that runs the executable
add_test(NAME Laplace_C COMMAND laplace_c)
add_opencmiss_environment(Laplace_C)
55 changes: 55 additions & 0 deletions ClassicalField/Laplace/Laplace/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# OpenCMISS (Open Continuum Mechanics, Imaging, Signal processing and System identification)
# is a mathematical modelling environment that enables the application of finite element
# analysis techniques to a variety of complex bioengineering problems.
#
# The OpenCMISS project website can be found at http://www.opencmiss.org
# For more information see http://www.opencmiss.org/documentation

# Include the OpenCMISS initalisation & macro definition file.
include(./OpenCMISS.cmake)

# Project setup
# -------------
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)

option(USE_MPI "Use MPI" ON)

if (USE_MPI)
message(STATUS "Setting compiler to MPIC")
if(OC_INSTRUMENTATION STREQUAL scorep)
set(CMAKE_Fortran_COMPILER scorep-mpif90)
set(CMAKE_C_COMPILER scorep-mpicc)
else()
set(CMAKE_Fortran_COMPILER mpif90)
set(CMAKE_C_COMPILER mpicc)
endif()
endif()

project(OpenCMISS-Example VERSION 1.0 LANGUAGES C Fortran)
enable_testing()

message(STATUS "C Compiler: ${CMAKE_C_COMPILER}")
message(STATUS "Fortran Compiler: ${CMAKE_Fortran_COMPILER}")
message(STATUS "MPI: ${MPI}")
message(STATUS "Instrumentation: ${OC_INSTRUMENTATION}")


# Find OpenCMISS
# --------------
#
# This call tries to find a matching OpenCMISS (SDK) installation for your (default) Toolchain and MPI choice.
# Currently available OpenCMISS package components: Iron Zinc
# Requiring Iron will also include the iron_c bindings target if available.
#
# This function creates a link target 'opencmiss' that contains references to the requested OpenCMISS components.
# For Iron, it also adds the necessary MPI information - no further find_package(MPI ..) and setting of extra include
# paths needed!
find_package(OpenCMISS 1.1 REQUIRED COMPONENTS Iron CONFIG)
#find_package(MPI REQUIRED)

# CMake application code
# ----------------------
if (CMAKE_Fortran_COMPILER)
add_subdirectory(Fortran)
add_subdirectory(C)
endif()
Loading