Skip to content

Commit

Permalink
- added kinsol support to ANALYZATION_MODE
Browse files Browse the repository at this point in the history
- simple scorep-trace macro for cvode-initialization added

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20280 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Marcus Walther committed Apr 28, 2014
1 parent 1b251be commit 42ce737
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 14 deletions.
Expand Up @@ -4,6 +4,7 @@ LIBOMCPPSIMULATIONSETTINGS = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@SimulationSe
LIBOMCPPSYSTEM = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@SystemName@.a"
LIBOMCPPDATAEXCHANGE = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@DataExchangeName@_static.a"
LIBOMCPPNEWTON = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@NewtonName@.a"
LIBOMCPPKINSOL = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@KinsolName@.a"
LIBOMCPPCVODE = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@CVodeName@.a"
LIBOMCPPSOLVER = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@SolverName@.a"
LIBOMCPPMATH = "$(OMHOME)/lib/omc/@LIBINSTALLEXT@/lib@MathName@.a"
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Core/SimController/CMakeLists.txt
Expand Up @@ -4,7 +4,7 @@ project(${SimControllerName})

IF(ANALYZATION_MODE)
message(STATUS "Building SimController for analyzation")
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})
add_library(${SimControllerName} STATIC Configuration.cpp FactoryExport.cpp Initialization.cpp SimController.cpp SimManager.cpp)
target_link_libraries( ${SimControllerName} ${SystemName} ${OMCFactoryName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} )
ELSE(ANALYZATION_MODE)
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Core/System/CMakeLists.txt
Expand Up @@ -4,7 +4,7 @@ project(${SystemName})
# add the system default implementation library
IF(ANALYZATION_MODE)
add_library(${SystemName} STATIC AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp SystemDefaultImplementation.cpp FactoryExport.cpp)
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})
target_link_libraries (${SystemName} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${OMCFactoryName} )
ELSE(ANALYZATION_MODE)
add_library(${SystemName} SHARED AlgLoopDefaultImplementation.cpp AlgLoopSolverFactory.cpp EventHandling.cpp SystemDefaultImplementation.cpp FactoryExport.cpp)
Expand Down
Expand Up @@ -2,6 +2,8 @@

#include <Policies/NonLinSolverOMCFactory.h>
#include <Solver/Newton/Newton.h>
#include <Solver/Kinsol/Kinsol.h>
#include <Solver/Kinsol/KinsolSettings.h>

template<class T>
struct ObjectFactory;
Expand Down Expand Up @@ -29,13 +31,29 @@ class StaticNonLinSolverOMCFactory : public NonLinSolverOMCFactory<CreationPoli
boost::shared_ptr<INonLinSolverSettings> settings = boost::shared_ptr<INonLinSolverSettings>(new NewtonSettings());
return settings;
}
else
else if(nonlin_solver.compare("kinsol")==0)
{
boost::shared_ptr<INonLinSolverSettings> settings = boost::shared_ptr<INonLinSolverSettings>(new KinsolSettings());
return settings;
}
else
return NonLinSolverOMCFactory<CreationPolicy>::createNonLinSolverSettings(nonlin_solver);
}

virtual boost::shared_ptr<IAlgLoopSolver> createNonLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings)
virtual boost::shared_ptr<IAlgLoopSolver> createNonLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings)
{
boost::shared_ptr<IAlgLoopSolver> solver = boost::shared_ptr<IAlgLoopSolver>(new Newton(algLoop,solver_settings.get()));
return solver;
if(solver_name.compare("newton")==0)
{
boost::shared_ptr<IAlgLoopSolver> solver = boost::shared_ptr<IAlgLoopSolver>(new Newton(algLoop,solver_settings.get()));
return solver;
}
else if(solver_name.compare("kinsol")==0)
{
boost::shared_ptr<IAlgLoopSolver> settings = boost::shared_ptr<IAlgLoopSolver>(new Kinsol(algLoop,solver_settings.get()));
return settings;
}
else
return NonLinSolverOMCFactory<CreationPolicy>::createNonLinSolver(algLoop, solver_name, solver_settings);

}
};
Expand Up @@ -7,12 +7,12 @@ IF(ANALYZATION_MODE)
# add the system default implementation library
add_library(${OMCFactoryName} STATIC OMCFactory.cpp StaticOMCFactory.cpp)
#LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/../../../../build/lib/omc/${LIBINSTALLEXT})
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR})
include_directories(${SUNDIALS_INCLUDE_DIR}/cvodes ${SUNDIALS_INCLUDE_DIR}/nvector ${SUNDIALS_INCLUDE_DIR}/sundials ${SUNDIALS_INCLUDE_DIR}/kinsol ${SUNDIALS_INCLUDE_DIR})

if (UNIX)
target_link_libraries( ${OMCFactoryName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${NewtonName} ${CVodeName} ${SimControllerName} ${CMAKE_DL_LIBS})
target_link_libraries( ${OMCFactoryName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${NewtonName} ${KinsolName} ${CVodeName} ${SimControllerName} ${CMAKE_DL_LIBS})
else (UNIX)
target_link_libraries( ${OMCFactoryName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${NewtonName} ${CVodeName} ${SimControllerName})
target_link_libraries( ${OMCFactoryName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${NewtonName} ${KinsolName} ${CVodeName} ${SimControllerName})
endif(UNIX)
ELSE(ANALYZATION_MODE)
# add the system default implementation library
Expand Down
7 changes: 7 additions & 0 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -43,6 +43,10 @@ Cvode::~Cvode()

void Cvode::initialize()
{
#ifdef SCOREP_TRACE
SCOREP_USER_REGION_DEFINE(cvode_initialization_handle)
SCOREP_USER_REGION_BEGIN(cvode_initialization_handle, "Cvode_initialization", SCOREP_USER_REGION_TYPE_FUNCTION )
#endif
_properties = dynamic_cast<ISystemProperties*>(_system);
_continuous_system = dynamic_cast<IContinuous*>(_system);
_event_system = dynamic_cast<IEvent*>(_system);
Expand Down Expand Up @@ -192,6 +196,9 @@ void Cvode::initialize()
//

}
#ifdef SCOREP_TRACE
SCOREP_USER_REGION_END(cvode_initialization_handle)
#endif
}

void Cvode::solve(const SOLVERCALL action)
Expand Down
4 changes: 3 additions & 1 deletion SimulationRuntime/cpp/Solver/CVode/CVode.h
Expand Up @@ -8,7 +8,9 @@
#include <nvector/nvector_serial.h>
#include <cvodes/cvodes_dense.h>


#ifdef SCOREP_TRACE
#include <scorep/SCOREP_User.h>
#endif

/*****************************************************************************/
// Cvode aus dem SUNDIALS-Package
Expand Down
8 changes: 4 additions & 4 deletions SimulationRuntime/cpp/Solver/Kinsol/Kinsol.h
Expand Up @@ -2,10 +2,10 @@
#pragma once

#include "FactoryExport.h"
#include<kinsol.h>
#include<nvector_serial.h>
#include<kinsol_dense.h>
#include<kinsol_spgmr.h>
#include <kinsol.h>
#include <nvector_serial.h>
#include <kinsol_dense.h>
#include <kinsol_spgmr.h>
#include <kinsol_spbcgs.h>
#include <kinsol_sptfqmr.h>
#include <boost/math/special_functions/fpclassify.hpp>
Expand Down

0 comments on commit 42ce737

Please sign in to comment.