Skip to content

Commit

Permalink
removed some includes in cpp runtime
Browse files Browse the repository at this point in the history
add solve in Kinsol  for linear system if linear tearing is active

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20638 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed May 16, 2014
1 parent 7810845 commit 3530a3f
Show file tree
Hide file tree
Showing 19 changed files with 316 additions and 48 deletions.
37 changes: 35 additions & 2 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -1374,7 +1374,7 @@ OFILES=$(CPPFILES:.cpp=.o)
.PHONY: <%lastIdentOfPath(modelInfo.name)%> $(CPPFILES)

<%fileNamePrefix%>: $(MAINFILE) $(OFILES)
<%\t%>$(CXX) -shared -I. -o $(SYSTEMOBJ) $(OFILES) $(CPPFLAGS) $(LDSYTEMFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> -lOMCppSystem -lOMCppModelicaUtilities -lOMCppMath
<%\t%>$(CXX) -shared -I. -o $(SYSTEMOBJ) $(OFILES) $(CPPFLAGS) $(LDMAINFLAGS) <%dirExtra%> <%libsPos1%> <%libsPos2%> -lOMCppSystem -lOMCppModelicaUtilities -lOMCppMath
<%\t%>$(CXX) $(CPPFLAGS) -I. -o $(MAINOBJ) $(MAINFILE) $(LDMAINFLAGS)
<% if boolNot(stringEq(makefileParams.platform, "win32")) then
<<
Expand Down Expand Up @@ -1541,6 +1541,8 @@ match eq
<%AlgloopDefaultImplementationCode(simCode,eq,context)%>
<%getAMatrixCode(simCode,eq)%>
<%isLinearCode(simCode,eq)%>
<%isLinearTearingCode(simCode,eq)%>
>>
end algloopCppFile;
Expand Down Expand Up @@ -3169,6 +3171,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
return false;
}
>>
case SES_LINEAR(__) then
<<
bool <%modelname%>Algloop<%index%>::isLinear()
Expand All @@ -3179,6 +3182,35 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
end isLinearCode;
template isLinearTearingCode(SimCode simCode,SimEqSystem eq)
::=
match simCode
case SIMCODE(modelInfo = MODELINFO(__)) then
let modelname = lastIdentOfPath(modelInfo.name)
let &varDecls = buffer ""
let &preExp = buffer ""
match eq
case SES_NONLINEAR(__) then
let lineartearing = if linearTearing then 'true' else 'false'
<<
bool <%modelname%>Algloop<%index%>::isLinearTearing()
{
return <%lineartearing%>;
}
>>
case SES_LINEAR(__) then
<<
bool <%modelname%>Algloop<%index%>::isLinearTearing()
{
return false;
}
>>
end isLinearTearingCode;
template initAlgloopEquation(SimEqSystem eq, Text &varDecls /*BUFP*/,SimCode simCode,Context context)
"Generates a non linear equation system."
Expand Down Expand Up @@ -3460,7 +3492,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
>>
%>
}
saveAll();
}
<%writeoutput1(modelInfo)%>
>>
Expand Down Expand Up @@ -3991,6 +4023,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
/// Output routine (to be called by the solver after every successful integration step)
virtual void getSystemMatrix(double* A_matrix);
virtual bool isLinear();
virtual bool isLinearTearing();
virtual bool isConsistent();
/// Set stream for output
virtual void setOutput(std::ostream* outputStream) ;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Core/DataExchange/stdafx.h
Expand Up @@ -39,6 +39,23 @@
#include <boost/math/tools/real_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Core/SimController/stdafx.h
Expand Up @@ -39,6 +39,23 @@
#include <boost/math/tools/real_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Core/SimulationSettings/stdafx.h
Expand Up @@ -43,6 +43,23 @@
#include <boost/range/algorithm/copy.hpp>
#include <boost/math/tools/real_cast.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Core/Solver/stdafx.h
Expand Up @@ -42,6 +42,23 @@
#include <boost/math/tools/real_cast.hpp>
#include <boost/multi_array.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Core/System/stdafx.h
Expand Up @@ -40,6 +40,23 @@
#include <boost/unordered_map.hpp>
#include <iostream>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Include/Core/Modelica.h
Expand Up @@ -58,6 +58,23 @@ using namespace std;
#include <boost/range/adaptor/map.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/math/special_functions/trunc.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using namespace boost::extensions;
using namespace boost::assign;
Expand Down
1 change: 1 addition & 0 deletions SimulationRuntime/cpp/Include/Core/System/IAlgLoop.h
Expand Up @@ -54,6 +54,7 @@ class IAlgLoop
virtual void getSystemMatrix(double* A_matrix) = 0;

virtual bool isLinear() = 0;
virtual bool isLinearTearing()=0;
virtual bool isConsistent() = 0;
/*/// Fügt das übergebene Objekt als Across-Kante hinzu
void addAcrossEdge(IObject& new_obj);
Expand Down
Expand Up @@ -7,47 +7,14 @@
#elif defined(SIMSTER_BUILD)


/*Factory includes*/
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>
/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;


/*Defines*/
#define PATH fs::path

#include <Genericfactory/Factory.h>
#elif defined(OMC_BUILD)
/*Factory includes*/
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;


/*Defines*/
#define PATH fs::path
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Makefile
Expand Up @@ -13,7 +13,7 @@ ifeq ("$(ANALYZATION_MODE)","true")
cd ./Build && echo "change to Build" && cmake -DANALYZATION_MODE=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH="$(builddir_build)" ../
$(MAKE) -C Build;
else
cd ./Build && echo "change to Build" && cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_INSTALL_PREFIX:PATH="$(builddir_build)" ../
cd ./Build && echo "change to Build" && cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX:PATH="$(builddir_build)" ../
$(MAKE) -C Build;
endif

Expand Down
11 changes: 7 additions & 4 deletions SimulationRuntime/cpp/PrecompiledHeader.cmake
Expand Up @@ -56,7 +56,10 @@ SET(_sourceFound FALSE)
string (REPLACE "/Zm1000" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(_compiler_FLAGS ${${_flags_var_name}})
set(_compiler_FLAGS "/EHa /fp:except /W4 /MP ${_compiler_FLAGS}")
set(_compiler_FLAGS "/EHa /fp:except /W4 /MP ${_compiler_FLAGS}")
#disable optimization
string(REGEX REPLACE "/O[1-9]*[b,d,g,i,s,t,x]*[1-9]*" "" _compiler_FLAGS ${_compiler_FLAGS} )
set(_compiler_FLAGS "/Od ${_compiler_FLAGS}")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_compiler_FLAGS}")

#only generate precompiled header in relase mode in debug mode precompiled header can not generated because of different pdb files
Expand All @@ -74,7 +77,7 @@ IF(FORCEINCLUDE)
SET(PCH_COMPILE_FLAGS "${PCH_COMPILE_FLAGS} /FI${_name}")
ENDIF(FORCEINCLUDE)
ENDIF(_sourceWe STREQUAL ${_inputWe})
SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES COMPILE_FLAGS "${PCH_COMPILE_FLAGS}")
SET_SOURCE_FILES_PROPERTIES(${_source} PROPERTIES COMPILE_FLAGS "${PCH_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}")
ENDIF(_source MATCHES \\.\(cc|cxx|cpp\)$)
ENDFOREACH()
IF(NOT _sourceFound)
Expand Down Expand Up @@ -107,7 +110,7 @@ STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(_compiler_FLAGS ${${_flags_var_name}})
#remove compiler flag for optimization becaus Modelica system is compiled without optimization
string(REGEX REPLACE "O[1-9]" "O0" _compiler_FLAGS ${_compiler_FLAGS} )
string(REGEX REPLACE "-g" "" _compiler_FLAGS ${_compiler_FLAGS} )
#string(REGEX REPLACE "-g" "" _compiler_FLAGS ${_compiler_FLAGS} )

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(_compiler_FLAGS "${_compiler_FLAGS} -fPIC ")
Expand Down Expand Up @@ -154,7 +157,7 @@ STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(_compiler_FLAGS ${${_flags_var_name}})
#remove compiler flag for optimization becaus Modelica system is compiled without optimization
string(REGEX REPLACE "O[1-9]" "O0" _compiler_FLAGS ${_compiler_FLAGS} )
string(REGEX REPLACE "-g" "" _compiler_FLAGS ${_compiler_FLAGS} )
#string(REGEX REPLACE "-g" "" _compiler_FLAGS ${_compiler_FLAGS} )

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(_compiler_FLAGS "${_compiler_FLAGS} -fPIC ")
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/SimCoreFactory/OMCFactory/stdafx.h
Expand Up @@ -43,6 +43,23 @@
#include <boost/program_options.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down
17 changes: 17 additions & 0 deletions SimulationRuntime/cpp/Solver/CVode/stdafx.h
Expand Up @@ -40,6 +40,23 @@
#include <boost/math/tools/real_cast.hpp>
#include <boost/multi_array.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
#include "Utils/extension/extension.hpp"
#include "Utils/extension/factory.hpp"
#include "Utils/extension/type_map.hpp"
#include "Utils/extension/shared_library.hpp"
#include "Utils/extension/convenience.hpp"
#include "Utils/extension/factory_map.hpp"
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
//#include <boost/archive/xml_oarchive.hpp>
//#include <boost/archive/xml_iarchive.hpp>

#include <boost/unordered_map.hpp>

/*Namespaces*/
using namespace boost::extensions;
namespace fs = boost::filesystem;
using boost::unordered_map;
namespace uBlas = boost::numeric::ublas;
using std::vector;
using std::map;
Expand Down

0 comments on commit 3530a3f

Please sign in to comment.