Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OMSI] Add OMSIBase library with solvers
Going to be used by OMSIC and OMSICPP libraries. - Created build structure with Makefiles and CMake - Added OMSI to omc target in top Makefile - Added OMSI/omsi-clean target to Makefiles - Added Makefile.omsi.common with build rules for all OMSI stuff - Use CMake build for SimulationRuntime/OMSI - Added OMSI in Simulation Runtime - OMSIBase library contains base functions for - data handling - event handling - solving loops - handling xml and json files - initialiazing/ freeing stuff - utility functions - OMSISolver library contains solver and interface - general solver API - KINSOL solver - LAPCAK solver - Data types - omsi.h contains most important definitions - omsi_solver.h - Documentation with Doxygen - Doxyfile not included Belonging to [master]: - OpenModelica/OMCompiler#2986 Co-authored-by: niklwors <niiklas.worschech@boschrexroth.de> Co-authored-by: wibraun <wbraun@fh-bielefeld.de> Belonging to [master]: - OpenModelica/OMCompiler#2986
- Loading branch information
1 parent
f881685
commit e3fab53
Showing
48 changed files
with
11,895 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Makefile for build omsi base libraries | ||
|
||
# Specify a list of target platforms, including dynamic, static | ||
PLATFORMS=static dynamic | ||
|
||
|
||
CMAKE_FLAGS=-DCMAKE_BUILD_TYPE=$(BUILDTYPE) | ||
|
||
CMAKE_CALL=cmake -G $(CMAKE_TARGET) --build . -DPLATFORM=$(PLATFORM) $(CMAKE_FLAGS) $(IS_MINGW32) $(IS_MINGW64) -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" -DLIB_OMC=$(LIB_OMC) .. | ||
|
||
.PHONY: OMSIBaseClean | ||
|
||
|
||
############################# | ||
# Rules for OMSI | ||
############################# | ||
|
||
OMSI: OMSIBaseInstall | ||
|
||
|
||
|
||
OMSI-clean: OMSIBaseClean | ||
cd $(OMBUILDDIR); \ | ||
rm -rf include/omc/omsi; \ | ||
rm -rf $(LIB_OMC)/omsi; | ||
|
||
|
||
############################# | ||
# Rules for OMSIBase library | ||
############################# | ||
|
||
OMSIBase: sundials | ||
cd SimulationRuntime/OMSI; \ | ||
$(foreach PLATFORM, $(PLATFORMS), \ | ||
mkdir -p Build_$(PLATFORM); \ | ||
(cd ./Build_$(PLATFORM); echo "change to Build_$(PLATFORM)"; \ | ||
$(CMAKE_CALL); \ | ||
$(MAKE) );) | ||
|
||
OMSIBaseMSVC: getMSVCversion | ||
test -f """${VSCOMNTOOLS}/../../VC/vcvarsall.bat""" | ||
echo 'Build the cppRuntime with MSVC' buildtype: $(BUILDTYPE) | ||
#rm -rf Build_MSVC | ||
mkdir -p Build_MSVC | ||
echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_MSVC/build.bat | ||
|
||
echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' >> Build_MSVC/build.bat | ||
echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="dynamic" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC/build.bat | ||
|
||
# for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! | ||
echo set MAKEFLAGS="" >> Build_MSVC/build.bat | ||
echo echo Running NMake JOM >> Build_MSVC/build.bat | ||
echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC/build.bat | ||
cd ./Build_MSVC; echo "change to Build_MSVC";\ | ||
cmd /c build.bat | ||
|
||
echo 'Build cppRuntime (static) with MSVC' | ||
#rm -rf Build_MSVC_static | ||
mkdir -p Build_MSVC_static | ||
echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_MSVC_static/build.bat | ||
|
||
echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' >> Build_MSVC_static/build.bat | ||
echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="static" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC_static/build.bat | ||
|
||
# for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! | ||
echo set MAKEFLAGS="" >> Build_MSVC_static/build.bat | ||
echo echo Running NMake JOM >> Build_MSVC_static/build.bat | ||
echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC_static/build.bat | ||
cd ./Build_MSVC_static; echo "change to Build_MSVC_static";\ | ||
cmd /c build.bat | ||
|
||
# move folder to build dir | ||
cp -R --verbose Build_MSVC/tmp/* $(builddir_build) | ||
cp -R --verbose Build_MSVC_static/tmp/lib/* $(builddir_build)/lib | ||
|
||
OMSIBaseInstall: OMSIBase | ||
cd SimulationRuntime/OMSI; \ | ||
$(foreach PLATFORM, $(PLATFORMS), \ | ||
(cd Build_$(PLATFORM); $(MAKE) install);) | ||
|
||
OMSIBaseClean: | ||
cd SimulationRuntime/OMSI; \ | ||
$(foreach PLATFORM, $(PLATFORMS), \ | ||
test -d Build_$(PLATFORM) && cd Build_$(PLATFORM) && $(MAKE) uninstall && $(MAKE) DESTDIR=$(OMBUILDDIR) clean && cd ..; \ | ||
rm -R -f Build_$(PLATFORM); \ | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) | ||
SET(CMAKE_VERBOSE_MAKEFILE ON) | ||
MESSAGE(STATUS "CMake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}") | ||
|
||
PROJECT(OMSIBaseSimulationRuntime) | ||
|
||
# enable warnings and use ANSI C compatible compiler | ||
if(CMAKE_COMPILER_IS_GNUCXX) | ||
message(STATUS "GCC detected, adding compile flags") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -ansi -pedantic -g") | ||
IF(NOT WIN32) | ||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") | ||
ENDIF() | ||
endif(CMAKE_COMPILER_IS_GNUCXX) | ||
message(STATUS "Compiling with C flags: ${CMAKE_C_FLAGS}") | ||
|
||
|
||
|
||
if(NOT PLATFORM OR PLATFORM STREQUAL "dynamic") | ||
set(BUILD_SHARED_LIBS ON) | ||
elseif(PLATFORM STREQUAL "static") | ||
set(BUILD_SHARED_LIBS OFF) | ||
else() | ||
endif() | ||
|
||
|
||
|
||
IF(BUILD_SHARED_LIBS) | ||
SET(LIBSUFFIX "") | ||
ELSE(BUILD_SHARED_LIBS) | ||
SET(LIBSUFFIX "_static") | ||
ENDIF(BUILD_SHARED_LIBS) | ||
|
||
|
||
|
||
IF(MSVC) | ||
MESSAGE(STATUS "MSVC") | ||
IF(LIB_OMC) | ||
SET(LIBINSTALLEXT "${LIB_OMC}/omsi/msvc" CACHE STRING "library directory" FORCE) | ||
ELSE(LIB_OMC) | ||
SET(LIBINSTALLEXT "omsi/msvc" CACHE STRING "library directory" FORCE) | ||
ENDIF(LIB_OMC) | ||
ELSE(MSVC) | ||
IF(LIB_OMC) | ||
SET(LIBINSTALLEXT "${LIB_OMC}/omsi" CACHE STRING "library directory" FORCE) | ||
ELSE(LIB_OMC) | ||
SET(LIBINSTALLEXT "omsi" CACHE STRING "library directory" FORCE) | ||
ENDIF(LIB_OMC) | ||
ENDIF(MSVC) | ||
message(STATUS "Libs will be installed in ${CMAKE_INSTALL_PREFIX}/${LIBINSTALLEXT}") | ||
|
||
SET(OSUBaseName ${LIBPREFIX}OMSIBase${LIBSUFFIX}) | ||
SET(OMSISolverName ${LIBPREFIX}OMSISolver${LIBSUFFIX}) | ||
|
||
include_directories ("${CMAKE_SOURCE_DIR}/include") | ||
# omsi base simulation runtime | ||
ADD_SUBDIRECTORY(base) | ||
ADD_SUBDIRECTORY(solver) | ||
|
||
install(FILES | ||
${CMAKE_SOURCE_DIR}/include/omsi.h | ||
${CMAKE_SOURCE_DIR}/include/omsi_callbacks.h | ||
${CMAKE_SOURCE_DIR}/include/omsi_api_functions.h | ||
DESTINATION include/omc/omsi) | ||
|
||
install(FILES | ||
${CMAKE_SOURCE_DIR}/include/fmi2/omsi_fmi2_cs.h | ||
${CMAKE_SOURCE_DIR}/include/fmi2/omsi_fmi2_me.h | ||
${CMAKE_SOURCE_DIR}/include/fmi2/omsi_fmi2_wrapper.h | ||
DESTINATION include/omc/omsi/fmi2/) | ||
|
||
# uninstall target | ||
if(NOT TARGET uninstall) | ||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
IMMEDIATE @ONLY) | ||
|
||
add_custom_target(uninstall | ||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | ||
endif() | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) | ||
#OMSI base simulation runtime | ||
PROJECT(OMSIBASE) | ||
SET(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
#set exapat lib for visual studio compiler | ||
IF(MSVC) | ||
INCLUDE_DIRECTORIES($ENV{OMDEV}/lib/expat-win32-msvc) | ||
link_directories($ENV{OMDEV}/lib/expat-win32-msvc) | ||
link_directories($ENV{OMDEV}/lib/lapack-win32-msvc) | ||
set(expat_lib "libexpat") | ||
ELSE(MSVC) | ||
set(expat_lib "expat") | ||
ENDIF(MSVC) | ||
|
||
include_directories ("${CMAKE_SOURCE_DIR}/base/include" "${CMAKE_SOURCE_DIR}/solver/include") | ||
add_library(${OSUBaseName} | ||
src/omsi_event_helper.c | ||
src/omsi_getters_and_setters.c | ||
src/omsi_initialization.c | ||
src/omsi_input_json.c | ||
src/omsi_input_model_variables.c | ||
src/omsi_input_sim_data.c | ||
src/omsi_input_xml.c | ||
src/omsi_mmap.c | ||
src/omsi_posix_func.c | ||
src/omsi_solve_alg_system.c | ||
src/omsi_utils.c) | ||
|
||
include_directories ("${OMSI_SOURCE_DIR}/solver/include") | ||
|
||
IF(WIN32) | ||
target_link_libraries(${OSUBaseName} ${OMSISolverName} ${CMAKE_DL_LIBS} wsock32 ws2_32 ${expat_lib}) | ||
ELSE(WIN32) | ||
target_link_libraries(${OSUBaseName} ${OMSISolverName} ${CMAKE_DL_LIBS} ) | ||
ENDIF(WIN32) | ||
|
||
install(TARGETS ${OSUBaseName} DESTINATION ${LIBINSTALLEXT}) | ||
|
||
install(FILES | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_event_helper.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_getters_and_setters.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_global.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_initialization.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_input_json.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_input_model_variables.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_input_sim_data.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_input_xml.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_mmap.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_posix_func.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_solve_alg_system.h | ||
${CMAKE_SOURCE_DIR}/base/include/omsi_utils.h | ||
${CMAKE_SOURCE_DIR}/base/include/uthash.h | ||
DESTINATION include/omc/omsi/base) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This file is part of OpenModelica. | ||
* | ||
* Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), | ||
* c/o Linköpings universitet, Department of Computer and Information Science, | ||
* SE-58183 Linköping, Sweden. | ||
* | ||
* All rights reserved. | ||
* | ||
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE | ||
* GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2. | ||
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES | ||
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3, | ||
* ACCORDING TO RECIPIENTS CHOICE. | ||
* | ||
* The OpenModelica software and the OSMC (Open Source Modelica Consortium) | ||
* Public License (OSMC-PL) are obtained from OSMC, either from the above | ||
* address, from the URLs: http://www.openmodelica.org or | ||
* http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica | ||
* distribution. GNU version 3 is obtained from: | ||
* http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from: | ||
* http://www.opensource.org/licenses/BSD-3-Clause. | ||
* | ||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied | ||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS | ||
* EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE | ||
* CONDITIONS OF OSMC-PL. | ||
* | ||
*/ | ||
|
||
|
||
#ifndef OMSI_EVENT_HELPER__H_ | ||
#define OMSI_EVENT_HELPER__H_ | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#include <stdio.h> | ||
#include <assert.h> | ||
#include <math.h> /* fmin, fmod */ | ||
|
||
/* Public OMSI headers */ | ||
#include <omsi.h> | ||
#include <omsi_utils.h> | ||
|
||
|
||
/* Function prototypes */ | ||
omsi_bool omsi_function_zero_crossings (omsi_function_t* this_function, | ||
omsi_bool new_zero_crossing, | ||
omsi_unsigned_int index, | ||
ModelState model_state); | ||
|
||
omsi_bool omsi_on_sample_event (omsi_function_t* this_function, | ||
omsi_unsigned_int sample_id, | ||
ModelState model_state); | ||
|
||
omsi_real omsi_next_sample(omsi_real time, | ||
omsi_sample* sample_event); | ||
|
||
omsi_real omsi_compute_next_event_time (omsi_real time, | ||
omsi_sample* sample_events, | ||
omsi_unsigned_int n_sample_events); | ||
|
||
omsi_bool omsi_check_discrete_changes (omsi_t* omsi_data); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif | ||
|
Oops, something went wrong.