Skip to content

Commit

Permalink
-added solver arkode
Browse files Browse the repository at this point in the history
  • Loading branch information
RuedKamp committed Jun 10, 2015
1 parent f54c86f commit 6adadd7
Show file tree
Hide file tree
Showing 14 changed files with 1,085 additions and 26 deletions.
26 changes: 15 additions & 11 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -1633,8 +1633,9 @@ extern "C" int runSimulation(void)
PATH modelicaSystem_path = "";
boost::shared_ptr<VxWorksFactory> factory = boost::shared_ptr<VxWorksFactory>(new VxWorksFactory(libraries_path, modelicaSystem_path));
ISimController* sim_controller = createSimController(libraries_path, modelicaSystem_path);
boost::weak_ptr<ISimData> simData = sim_controller->LoadSimData("model2");
boost::weak_ptr<IMixedSystem> system = sim_controller->LoadSystem("model2","model2");
boost::weak_ptr<ISimData> simData = sim_controller->LoadSimData("<%lastIdentOfPath(modelInfo.name)%>");
boost::weak_ptr<ISimVars> simVars = sim_controller->LoadSimVars("<%lastIdentOfPath(modelInfo.name)%>",<%numRealVars%>,<%numIntVars%>,<%numBoolVars%>,<%numPreVars%>,<%numStatevars(modelInfo)%>,<%numStateVarIndex(modelInfo)%>);
boost::weak_ptr<IMixedSystem> system = sim_controller->LoadSystem("<%lastIdentOfPath(modelInfo.name)%>","<%lastIdentOfPath(modelInfo.name)%>");
boost::shared_ptr<ISimData> simData_shared = simData.lock();


Expand Down Expand Up @@ -2656,6 +2657,9 @@ case "vxworks69" then

WIND_HOME := $(subst \,/,$(WIND_HOME))
WIND_BASE := $(subst \,/,$(WIND_BASE))
MLPI := $(subst \,/,$(MLPI))
OMDEV := $(subst \,/,$(OMDEV))
CPP_RUNTIME := $(subst \,/,$(CPP_RUNTIME))

all : clean pre_build main_all post_build

Expand Down Expand Up @@ -2703,10 +2707,10 @@ case "vxworks69" then
LIBPATH =
LIBS =

IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -ID:/Windriver_Projekte/1.10.1.0/mlpiCore/include -IC:/OMdev/lib/3rdParty/boost-1_49 -IC:/cpp_runtime_for_xm22/Include/SimCoreFactory -IC:/cpp_runtime_for_xm22/Include/Core -IC:/cpp_runtime_for_xm22/Include/

IDE_LIBRARIES = C:/wb335_BoschOEM/workspace/MATH_BIB/ATOMgnu/MATH_BIB/Debug/MATH_BIB.a C:/wb335_BoschOEM/workspace/ModelicaExternalC/ATOMgnu/ModelicaExternalC/Debug/ModelicaExternalC.a C:/wb335_BoschOEM/workspace/Math/ATOMgnu/Math/Debug/Math.a C:/wb335_BoschOEM/workspace/VxWorksFactory/ATOMgnu/VxWorksFactory/Debug/VxWorksFactory.a C:/wb335_BoschOEM/workspace/SimController/ATOMgnu/SimulationController/Debug/SimulationController.a C:/wb335_BoschOEM/workspace/DataExchange/ATOMgnu/DataExchange/Debug/DataExchange.a C:/wb335_BoschOEM/workspace/SimulationSettings/ATOMgnu/SimulationSettings/Debug/SimulationSettings.a C:/wb335_BoschOEM/workspace/Solver/ATOMgnu/Solver/Debug/Solver.a C:/wb335_BoschOEM/workspace/System/ATOMgnu/System/Debug/System.a C:/wb335_BoschOEM/workspace/RTSolver/ATOMgnu/RTSolver/Debug/RTSolver.a C:/wb335_BoschOEM/workspace/Kinsol_Sources/ATOMgnu/Kinsol_Sources/Debug/Kinsol_Sources.a C:/wb335_BoschOEM/workspace/Kinsol/ATOMgnu/Kinsol/Debug/Kinsol.a
IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -I$(MLPI)/mlpiCore/include -I$(OMDEV)/lib/3rdParty/boost-1_49 -I$(CPP_RUNTIME)/Include/Core -I$(CPP_RUNTIME)/Include

IDE_LIBRARIES = $(CPP_RUNTIME)/Build/VxWorks/SimCore.a

IDE_DEFINES = -DCPU=_VX_$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D_VSB_CONFIG_FILE=\"$(VSB_DIR)/h/config/vsbConfig.h\"


Expand Down Expand Up @@ -2752,8 +2756,8 @@ case "vxworks69" then
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : DEBUGFLAGS_Librarian =
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : DEBUGFLAGS_Assembler = -O2
endif
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -ID:/Windriver_Projekte/1.10.1.0/mlpiCore/include -IC:/OMdev/lib/3rdParty/boost-1_49 -IC:/cpp_runtime_for_xm22/Include/SimCoreFactory -IC:/cpp_runtime_for_xm22/Include/Core -IC:/cpp_runtime_for_xm22/Include/
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : IDE_LIBRARIES = C:/wb335_BoschOEM/workspace/MATH_BIB/ATOMgnu/MATH_BIB/Debug/MATH_BIB.a C:/wb335_BoschOEM/workspace/ModelicaExternalC/ATOMgnu/ModelicaExternalC/Debug/ModelicaExternalC.a C:/wb335_BoschOEM/workspace/Math/ATOMgnu/Math/Debug/Math.a C:/wb335_BoschOEM/workspace/VxWorksFactory/ATOMgnu/VxWorksFactory/Debug/VxWorksFactory.a C:/wb335_BoschOEM/workspace/SimController/ATOMgnu/SimulationController/Debug/SimulationController.a C:/wb335_BoschOEM/workspace/DataExchange/ATOMgnu/DataExchange/Debug/DataExchange.a C:/wb335_BoschOEM/workspace/SimulationSettings/ATOMgnu/SimulationSettings/Debug/SimulationSettings.a C:/wb335_BoschOEM/workspace/Solver/ATOMgnu/Solver/Debug/Solver.a C:/wb335_BoschOEM/workspace/System/ATOMgnu/System/Debug/System.a C:/wb335_BoschOEM/workspace/RTSolver/ATOMgnu/RTSolver/Debug/RTSolver.a C:/wb335_BoschOEM/workspace/Kinsol_Sources/ATOMgnu/Kinsol_Sources/Debug/Kinsol_Sources.a C:/wb335_BoschOEM/workspace/Kinsol/ATOMgnu/Kinsol/Debug/Kinsol.a
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -I$(MLPI)/mlpiCore/include -I$(OMDEV)/lib/3rdParty/boost-1_49 -I$(CPP_RUNTIME)/Include/Core -I$(CPP_RUNTIME)/Include
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : IDE_LIBRARIES = $(CPP_RUNTIME)/Build/VxWorks/SimCore.a
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : IDE_DEFINES = -DCPU=_VX_$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D_VSB_CONFIG_FILE=\"$(VSB_DIR)/h/config/vsbConfig.h\"
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : PROJECT_TYPE = DKM
com.boschrexroth.$(MODEL_NAME)/$(MODE_DIR)/% : DEFINES =
Expand Down Expand Up @@ -2804,8 +2808,8 @@ case "vxworks69" then
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : DEBUGFLAGS_Librarian =
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : DEBUGFLAGS_Assembler = -O2
endif
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -ID:/Windriver_Projekte/1.10.1.0/mlpiCore/include -IC:/OMdev/lib/3rdParty/boost-1_49 -IC:/cpp_runtime_for_xm22/Include/SimCoreFactory -IC:/cpp_runtime_for_xm22/Include/Core -IC:/cpp_runtime_for_xm22/Include/
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : IDE_LIBRARIES = C:/wb335_BoschOEM/workspace/MATH_BIB/ATOMgnu/MATH_BIB/Debug/MATH_BIB.a C:/wb335_BoschOEM/workspace/ModelicaExternalC/ATOMgnu/ModelicaExternalC/Debug/ModelicaExternalC.a C:/wb335_BoschOEM/workspace/Math/ATOMgnu/Math/Debug/Math.a C:/wb335_BoschOEM/workspace/VxWorksFactory/ATOMgnu/VxWorksFactory/Debug/VxWorksFactory.a C:/wb335_BoschOEM/workspace/SimController/ATOMgnu/SimulationController/Debug/SimulationController.a C:/wb335_BoschOEM/workspace/DataExchange/ATOMgnu/DataExchange/Debug/DataExchange.a C:/wb335_BoschOEM/workspace/SimulationSettings/ATOMgnu/SimulationSettings/Debug/SimulationSettings.a C:/wb335_BoschOEM/workspace/Solver/ATOMgnu/Solver/Debug/Solver.a C:/wb335_BoschOEM/workspace/System/ATOMgnu/System/Debug/System.a C:/wb335_BoschOEM/workspace/RTSolver/ATOMgnu/RTSolver/Debug/RTSolver.a C:/wb335_BoschOEM/workspace/Kinsol_Sources/ATOMgnu/Kinsol_Sources/Debug/Kinsol_Sources.a C:/wb335_BoschOEM/workspace/Kinsol/ATOMgnu/Kinsol/Debug/Kinsol.a
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip -I$(MLPI)/mlpiCore/include -I$(OMDEV)/lib/3rdParty/boost-1_49 -I$(CPP_RUNTIME)/Include/Core -I$(CPP_RUNTIME)/Include
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : IDE_LIBRARIES = $(CPP_RUNTIME)/Build/VxWorks/SimCore.a
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : IDE_DEFINES = -DCPU=_VX_$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D_VSB_CONFIG_FILE=\"$(VSB_DIR)/h/config/vsbConfig.h\"
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : PROJECT_TYPE = DKM
com.boschrexroth.$(MODEL_NAME)_partialImage/$(MODE_DIR)/% : DEFINES =
Expand Down Expand Up @@ -9858,7 +9862,7 @@ template generateInitAlgloopsolverVariables1(list<SimEqSystem> allEquationsPlusW
generateInitAlgloopsolverVariables2(eq, contextOther, &varDecls /*BUFC*/,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace);separator="\n")
;separator="\n")

let &funcCalls += 'initializeAlgloopSolverVariables_<%partIdx%>();'
let &funcCalls += 'initializeAlgloopSolverVariables_<%partIdx%>(); <%\n%>'
<<
void <%className%>::initializeAlgloopSolverVariables_<%partIdx%>()
{
Expand Down Expand Up @@ -9932,7 +9936,7 @@ template generateDeleteAlgloopsolverVariables1(list<SimEqSystem> allEquationsPlu
let algloopsolver = (allEquationsPlusWhen |> eqs => (eqs |> eq =>
generateDeleteAlgloopsolverVariables2(eq, contextOther, &varDecls /*BUFC*/,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace);separator="\n")
;separator="\n")
let &funcCalls += 'deleteAlgloopSolverVariables_<%partIdx%>();'
let &funcCalls += 'deleteAlgloopSolverVariables_<%partIdx%>(); <%\n%>'
<<
void <%className%>::deleteAlgloopSolverVariables_<%partIdx%>()
{
Expand Down
12 changes: 11 additions & 1 deletion SimulationRuntime/cpp/CMakeLists.txt
Expand Up @@ -55,6 +55,7 @@ SET(ModelicaTablesName ModelicaStandardTables)
SET(SimulationSettings ${LIBPREFIX}SimulationSettings)
SET(SimControllerName ${LIBPREFIX}SimController)
SET(CVodeName ${LIBPREFIX}CVode)
SET(ARKodeName ${LIBPREFIX}ARKode)
SET(IDAName ${LIBPREFIX}IDA)
SET(PeerName ${LIBPREFIX}Peer)
SET(RTRKName ${LIBPREFIX}RTRK)
Expand Down Expand Up @@ -323,6 +324,11 @@ IF(USE_SUNDIALS)
IF(NOT SUNDIALS_CVODES_LIB)
MESSAGE(FATAL_ERROR "Could not find libsundials_cvodes!")
ENDIF()

FIND_LIBRARY(SUNDIALS_ARKODE_LIB "sundials_arkode" PATHS ${SUNDIALS_LIBRARY_RELEASE_HOME} $ENV{SUNDIALS_ROOT}/lib)
IF(NOT SUNDIALS_ARKODE_LIB)
MESSAGE(FATAL_ERROR "Could not find libsundials_ARKODE!")
ENDIF()

FIND_LIBRARY(SUNDIALS_IDA_LIB "sundials_idas" PATHS ${SUNDIALS_LIBRARY_RELEASE_HOME} $ENV{SUNDIALS_ROOT}/lib)
include_directories(${SUNDIALS_INCLUDE_DIR}/ida ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
Expand All @@ -334,7 +340,7 @@ IF(USE_SUNDIALS)
IF(NOT SUNDIALS_KINSOL_LIB)
MESSAGE(FATAL_ERROR "Could not find libsundials_kinsol!")
ENDIF()
SET(SUNDIALS_LIBRARIES ${SUNDIALS_NVECSERIAL_LIB} ${SUNDIALS_CVODES_LIB} ${SUNDIALS_IDA_LIB} ${SUNDIALS_KINSOL_LIB})
SET(SUNDIALS_LIBRARIES ${SUNDIALS_NVECSERIAL_LIB} ${SUNDIALS_CVODES_LIB} ${SUNDIALS_IDA_LIB} ${SUNDIALS_KINSOL_LIB} ${SUNDIALS_ARKODE_LIB})

MESSAGE(STATUS "Sundials Libraries:")
MESSAGE(STATUS "${SUNDIALS_LIBS}")
Expand Down Expand Up @@ -448,13 +454,16 @@ endif()
if(USE_SUNDIALS)
#add Cvode solver project
add_subdirectory (Solver/CVode)
add_subdirectory (Solver/ARKode)
add_subdirectory(Solver/IDA)
add_subdirectory (Solver/Kinsol)
#add Idas solver project
##add_subdirectory (Solver/Idas/Implementation)
##add_subdirectory (Solver/Ida/Implementation)
GET_TARGET_PROPERTY(libCVode ${CVodeName} LOCATION)
GET_TARGET_PROPERTY(libARKode ${ARKodeName} LOCATION)
GET_FILENAME_COMPONENT(libCVodeName ${libCVode} NAME)
GET_FILENAME_COMPONENT(libARKodeName ${libARKode} NAME)

GET_TARGET_PROPERTY(libIDA ${IDAName} LOCATION)
GET_FILENAME_COMPONENT(libIDAName ${libIDA} NAME)
Expand All @@ -468,6 +477,7 @@ GET_FILENAME_COMPONENT(libKinsolName ${libKinsol} NAME)

#set (IDAS_LIB ${libIdasName})
set (CVODE_LIB ${libCVodeName})
set (ARKODE_LIB ${libARKodeName})
set(IDA_LIB ${libIDAName})
set (KINSOL_LIB ${libKinsolName})
#set (IDA_LIB ${libIdaName})
Expand Down
8 changes: 1 addition & 7 deletions SimulationRuntime/cpp/Core/DataExchange/FactoryExport.cpp
Expand Up @@ -3,13 +3,7 @@
#include <Core/Modelica.h>
#if defined(__TRICORE__) || defined(__vxworks)


#include <Core/DataExchange/SimData.h>

extern "C" ISimData* createSimData()
{
return new SimData();
}
#include <Core/DataExchange/SimData.h>

#elif defined(OMC_BUILD)

Expand Down
Expand Up @@ -6,8 +6,32 @@

/*Defines*/
#define PATH string
#include <SimCoreFactory/VxWorksFactory/VxWorksFactory.h>

/* TODO
#include <Core/System/ISystemProperties.h>
#include <Core/System/ISystemInitialization.h>
#include <Core/System/IWriteOutput.h>
#include <Core/System/IContinuous.h>
#include <Core/System/ITime.h>
#include <Core/System/IEvent.h>
#include <Core/System/IStepEvent.h>
#include <Core/Solver/INonLinSolverSettings.h>
#include <Core/Solver/ILinSolverSettings.h>
#include <Core/DataExchange/IHistory.h>
#include <Core/System/IMixedSystem.h>
#include <Core/SimulationSettings/IGlobalSettings.h>
#include <Core/System/IMixedSystem.h>
#include <Core/System/IAlgLoop.h>
#include <Core/Solver/ISolverSettings.h>
#include <Core/Solver/ISolver.h>
#include <Core/Solver/IAlgLoopSolver.h>
#include <Core/System/IAlgLoopSolverFactory.h>
#include <Core/System/ISimVars.h>
#include <Core/System/PreVariables.h>
#include <Core/DataExchange/ISimVar.h>
#include <Core/SimController/ISimData.h>
#include <Core/SimulationSettings/ISimControllerSettings.h>
#include <SimCoreFactory/VxWorksFactory/VxWorksFactory.h>
*/
#elif defined(__TRICORE__)

/*Defines*/
Expand Down
Expand Up @@ -112,6 +112,17 @@ struct SolverOMCFactory : public ObjectFactory<CreationPolicy>
{
throw ModelicaSimulationError(MODEL_FACTORY,"Failed loading CVode solver library!");
}
}
else if((solvername.compare("arkode")==0))
{
PATH arkode_path = ObjectFactory<CreationPolicy>::_library_path;
PATH arkode_name(ARKODE_LIB);
arkode_path /= arkode_name;
LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(arkode_path.string(),*_solver_type_map);
if (result != LOADER_SUCCESS)
{
throw ModelicaSimulationError(MODEL_FACTORY,"Failed loading ARKode solver library!");
}
}
else
throw ModelicaSimulationError(MODEL_FACTORY,"Selected Solver is not available");
Expand Down
Expand Up @@ -101,6 +101,18 @@ struct SolverSettingsOMCFactory : public ObjectFactory<CreationPolicy>
throw ModelicaSimulationError(MODEL_FACTORY,"Failed loading CVode solver library!");
}
solver_settings_key.assign("extension_export_cvode");
}
else if((solvername.compare("arkode")==0))
{
PATH arkode_path = ObjectFactory<CreationPolicy>::_library_path;
PATH arkode_name(ARKODE_LIB);
arkode_path/=arkode_name;
LOADERRESULT result = ObjectFactory<CreationPolicy>::_factory->LoadLibrary(arkode_path.string(),*_solver_type_map);
if (result != LOADER_SUCCESS)
{
throw ModelicaSimulationError(MODEL_FACTORY,"Failed loading ARKode solver library!");
}
solver_settings_key.assign("extension_export_arkode");
}
else
throw ModelicaSimulationError(MODEL_FACTORY,"Selected Solver is not available");
Expand Down
Expand Up @@ -5,9 +5,12 @@
*/
#include <Core/SimController/ISimController.h>
#include <Core/ModelicaDefine.h>
#include <Core/Modelica.h>

#include <Core/Modelica.h>

#include <SimCoreFactory/Policies/FactoryConfig.h>
/*
class ISimController;
*/

class VxWorksFactory
{
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/cpp/LibrariesConfig.h.in
Expand Up @@ -2,6 +2,7 @@
#define EULER_LIB "@EULER_LIB@"
#define RTEULER_LIB "@RTEULER_LIB@"
#define CVODE_LIB "@CVODE_LIB@"
#define ARKODE_LIB "@ARKODE_LIB@"
#define PEER_LIB "@PEER_LIB@"
#define RTRK_LIB "@RTRK_LIB@"
#define IDAS_LIB "@IDAS_LIB@"
Expand Down
6 changes: 3 additions & 3 deletions SimulationRuntime/cpp/Makefile.omdev.mingw
Expand Up @@ -30,12 +30,12 @@ else
make;
endif

runtimeCPPmsvc: clean
runtimeCPPmsvc: #clean

test -f """${VS100COMNTOOLS}/../../VC/vcvarsall.bat"""
echo 'Build the cppRuntime with MSVC'
rm -rf build_msvc
mkdir -p build_msvc
#rm -rf build_msvc
#mkdir -p build_msvc
echo call '"%VS100COMNTOOLS%\\..\\..\\VC\\vcvarsall.bat"' > build_msvc/build.bat
#echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DCMAKE_INSTALL_PREFIX=./tmp ../ -G "Visual Studio 10"' >> build_msvc/build.bat
ifeq ($(BUILDTYPE),Debug)
Expand Down
Expand Up @@ -2,6 +2,10 @@
*
* @{
*/
/* TODO
#include <Core/ModelicaDefine.h>
#include <Core/Modelica.h>
*/
#include <SimCoreFactory/VxWorksFactory/VxWorksFactory.h>

extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path);
Expand Down Expand Up @@ -37,6 +41,7 @@ boost::shared_ptr<ISettingsFactory> VxWorksFactory::LoadSettingsFactory()
{
ISettingsFactory* settingsFactory = createSettingsFactory(_library_path, _modelicasystem_path);
return boost::shared_ptr<ISettingsFactory>(settingsFactory);

}

boost::shared_ptr<IAlgLoopSolverFactory> VxWorksFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings)
Expand Down

0 comments on commit 6adadd7

Please sign in to comment.