Skip to content

Commit

Permalink
Modified interface method giveZeroFunc in cpp runtime, eps parameter …
Browse files Browse the repository at this point in the history
…is not needed.

Fix in CMake file of Modelica System

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11219 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
niklwors committed Feb 28, 2012
1 parent bcc2d83 commit 66179bb
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
10 changes: 5 additions & 5 deletions Compiler/susan_codegen/SimCode/CodegenCpp.tpl
Expand Up @@ -1215,8 +1215,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
<%initTimeEventFunctions%>
<%initEventHandling%>
_event_handling.init(this,<%helpvarlength(simCode)%>);
saveAll();
vector<unsigned int> var_ouputs_idx;
vector<unsigned int> var_ouputs_idx;
<%initOutputIndices%>
_historyImpl->setOutputs(var_ouputs_idx);
_historyImpl->clear();
Expand Down Expand Up @@ -2082,7 +2081,7 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
//Provide number (dimension) of zero functions
virtual int getDimZeroFunc();
//Provides current values of root/zero functions
virtual void giveZeroFunc(double* f,const double& eps);
virtual void giveZeroFunc(double* f);
virtual void giveConditions(bool* c);
virtual void setConditions(bool* c);
//Called to check conditions for event-handling
Expand Down Expand Up @@ -5759,7 +5758,7 @@ template handleSystemEvents(list<ZeroCrossing> zeroCrossings,list<SimWhenClause>
_event_handling.setHelpVars(h);
//iterate and handle all events inside the eventqueue
restart=_event_handling.IterateEventQueue(_conditions1);
saveAll();
}
saveConditions();
resetTimeEvents();
Expand Down Expand Up @@ -5812,7 +5811,7 @@ template giveZeroFunc1(list<ZeroCrossing> zeroCrossings,SimCode simCode)
match simCode
case SIMCODE(modelInfo = MODELINFO(__)) then
<<
void <%lastIdentOfPath(modelInfo.name)%>::giveZeroFunc(double* f,const double& eps)
void <%lastIdentOfPath(modelInfo.name)%>::giveZeroFunc(double* f)
{
<%varDecls%>
<%zeroCrossingsCode%>
Expand Down Expand Up @@ -6141,6 +6140,7 @@ template update( list<SimEqSystem> allEquationsPlusWhen,list<SimWhenClause> when
void <%lastIdentOfPath(modelInfo.name)%>::update(const UPDATE command)
{
<%varDecls%>
saveAll();
if(IContinous::RANKING) checkConditions(0,true);
<%all_equations%>
<%reinit%>
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Source/CMakeLists.txt
Expand Up @@ -23,8 +23,8 @@ endif()
ENDIF( WIN32 )

SET(MODELICA_MODEL "ModelicaSystem")
SET(USE_MICO ON)
SET(REDUCE_DAE ON)
SET(USE_MICO OFF)
SET(REDUCE_DAE OFF)
SET(USE_SUNDIALS ON)
SET(INSTALL_OMDEV_LIBS ON)

Expand Down
Expand Up @@ -359,14 +359,14 @@ void Cvode::CVodeCore()

// Nullstellen identifizieren, bei denen zu Beginn der Simulation der Zustand nicht entschieden werden kann
// Nullstellen identifizieren, bei denen zu Beginn der Simulation der Zustand nicht entschieden werden kann
event_system->giveZeroFunc(_zeroValLastSuccess,dynamic_cast<ISolverSettings*>(_cvodesettings)->getZeroTol());
event_system->giveZeroFunc(_zeroValLastSuccess);
event_system->giveConditions(_Cond);
for(int i=0;i<_dimZeroFunc;i++)
{
_Cond[i] = !_Cond[i];
}
event_system->setConditions(_Cond);
event_system->giveZeroFunc(_zeroVal,dynamic_cast<ISolverSettings*>(_cvodesettings)->getZeroTol());
event_system->giveZeroFunc(_zeroVal);
for(int i=0;i<_dimZeroFunc;i++)
{
if(_zeroValLastSuccess[i] == _zeroVal[i])
Expand Down Expand Up @@ -573,7 +573,7 @@ void Cvode::giveZeroVal(const double &t,const double *y,double *zeroValue)
// System aktualisieren
continous_system->update(IContinous::CONTINOUS);

event_system->giveZeroFunc(zeroValue,dynamic_cast<ISolverSettings*>(_cvodesettings)->getZeroTol());
event_system->giveZeroFunc(zeroValue);

}

Expand Down
Expand Up @@ -219,14 +219,14 @@ void Euler::solve(const SOLVERCALL command)
solverOutput(_accStps,_tCurrent,_z,_h);

// Nullstellen identifizieren, bei denen zu Beginn der Simulation der Zustand nicht entschieden werden kann
event_system->giveZeroFunc(_zeroValLastSuccess,dynamic_cast<ISolverSettings*>(_eulerSettings)->getZeroTol());
event_system->giveZeroFunc(_zeroValLastSuccess);
event_system->giveConditions(_Cond);
for(int i=0;i<_dimZeroFunc;i++)
{
_Cond[i] = !_Cond[i];
}
event_system->setConditions(_Cond);
event_system->giveZeroFunc(_zeroVal,dynamic_cast<ISolverSettings*>(_eulerSettings)->getZeroTol());
event_system->giveZeroFunc(_zeroVal);
for(int i=0;i<_dimZeroFunc;i++)
{
if(_zeroValLastSuccess[i] == _zeroVal[i])
Expand Down Expand Up @@ -828,7 +828,7 @@ void Euler::giveZeroVal(const double &t,const double *y,double *zeroValue)

// System aktualisieren
continous_system->update(IContinous::CONTINOUS);
event_system->giveZeroFunc(zeroValue,dynamic_cast<ISolverSettings*>(_eulerSettings)->getZeroTol());
event_system->giveZeroFunc(zeroValue);
}

void Euler::giveZeroIdx(double *vL,double *vR,int *zeroIdx, int &zeroExist)
Expand Down Expand Up @@ -1166,7 +1166,7 @@ void Euler::solverOutput(const int& stp, const double& t, double* z, const doubl
if (_zeroVal)
{
// read values of zero functions
event_system->giveZeroFunc(_zeroVal,dynamic_cast<ISolverSettings*>(_eulerSettings)->getZeroTol());
event_system->giveZeroFunc(_zeroVal);

// Determine the sign and hence the status of zero crossings
SolverDefaultImplementation::setZeroState();
Expand All @@ -1191,7 +1191,7 @@ void Euler::solverOutput(const int& stp, const double& t, double* z, const doubl
if(_zeroVal && (stp > 0))
{
// read values of zero functions
event_system->giveZeroFunc(_zeroVal,dynamic_cast<ISolverSettings*>(_eulerSettings)->getZeroTol());
event_system->giveZeroFunc(_zeroVal);

// Determine the sign and hence the status of zero crossings
SolverDefaultImplementation::setZeroState();
Expand Down
Expand Up @@ -310,7 +310,7 @@ void Idas::callIDA()
if(_idid == 2)
{
//_idid = IDAGetRootInfo(_idaMem, _zeroSign);
event_system->giveZeroFunc(_zeroVal,dynamic_cast<ISolverSettings*>(_idasSettings)->getZeroTol());
event_system->giveZeroFunc(_zeroVal);

//Event Iteration starten
//update_events_type update_event = boost::bind(&SolverDefaultImplementation::updateEventState, this);
Expand Down Expand Up @@ -378,7 +378,7 @@ void Idas::giveZeroVal(const double &t,const double *y,double *zeroValue)
// System aktualisieren
continous_system->update(IContinous::CONTINOUS);

event_system->giveZeroFunc(zeroValue,dynamic_cast<ISolverSettings*>(_idasSettings)->getZeroTol());
event_system->giveZeroFunc(zeroValue);

}

Expand Down
Expand Up @@ -123,7 +123,7 @@ void SolverDefaultImplementation::init()
_events = new bool[_dimZeroFunc];
_zeroValInit = new double[_dimZeroFunc];
_zeroValLargeStep = new double[_dimZeroFunc];
event_system->giveZeroFunc(_zeroVal,_settings->getZeroTol());
event_system->giveZeroFunc(_zeroVal);
memcpy(_zeroValLastSuccess,_zeroVal,_dimZeroFunc*sizeof(double));
memcpy(_zeroValInit,_zeroVal,_dimZeroFunc*sizeof(double));
memset(_events,false,_dimZeroFunc*sizeof(bool));
Expand Down Expand Up @@ -272,7 +272,7 @@ void SolverDefaultImplementation::writeToFile(const int& stp, const double& t, c
}
void SolverDefaultImplementation::updateEventState()
{
dynamic_cast<IEvent*>(_system)->giveZeroFunc(_zeroVal,_settings->getZeroTol());
dynamic_cast<IEvent*>(_system)->giveZeroFunc(_zeroVal);
setZeroState();
if (_zeroStatus == IDAESolver::ZERO_CROSSING) // An event triggered an other event
{
Expand Down
2 changes: 1 addition & 1 deletion SimulationRuntime/cpp/Source/System/Interfaces/IEvent.h
Expand Up @@ -28,7 +28,7 @@ class IEvent
virtual int getDimZeroFunc() /*const*/ = 0;

/// Provides current values of root/zero functions
virtual void giveZeroFunc(double* f,const double& eps) = 0;
virtual void giveZeroFunc(double* f) = 0;
virtual void giveConditions(bool* c) = 0;
virtual void setConditions(bool* c) = 0;
virtual void checkConditions(unsigned int, bool all) = 0;
Expand Down
3 changes: 2 additions & 1 deletion SimulationRuntime/cpp/Source/System/Modelica/CMakeLists.txt
Expand Up @@ -27,8 +27,9 @@ install (FILES

install (FILES HistoryImpl.h Modelica.h DESTINATION include/omc/cpp)
install (FILES Policies/TextfileWriter.h DESTINATION include/omc/cpp/policies)
if(REDUCE_DAE)
install (FILES Policies/BufferReaderWriter.h DESTINATION include/omc/cpp/policies)

endif()



Expand Up @@ -107,7 +107,7 @@ void Modelica::giveRHS(double* f, const INDEX index)
SystemDefaultImplementation::giveRHS(f,index);
}

void Modelica::giveZeroFunc(double* f,const double& eps)
void Modelica::giveZeroFunc(double* f)
{

}
Expand Down
Expand Up @@ -83,7 +83,7 @@ class Modelica: public IDAESystem ,public IContinous ,public IEvent ,public ISys
virtual int getDimZeroFunc() ;

// Provides current values of root/zero functions
virtual void giveZeroFunc(double* f,const double& eps);
virtual void giveZeroFunc(double* f);
virtual void giveConditions(bool* c);
virtual void setConditions(bool* c);
//Called to handle all events occured at same time
Expand Down

0 comments on commit 66179bb

Please sign in to comment.