Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ISystemInitialization interface to cpp runtime
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@11133 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Showing
16 changed files
with
252 additions
and
32 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
38 changes: 38 additions & 0 deletions
38
SimulationRuntime/cpp/Source/Solver/Implementation/Initialization.cpp
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,38 @@ | ||
#include "stdafx.h" | ||
#include "Initialization.h" | ||
|
||
|
||
Initialization::Initialization(ISystemInitialization* system_initialization) | ||
:_system(system_initialization) | ||
{ | ||
} | ||
|
||
|
||
Initialization::~Initialization(void) | ||
{ | ||
} | ||
void Initialization::initializeSystem(double start_time, double end_time) | ||
{ | ||
IContinous* continous_system = dynamic_cast<IContinous*>(_system); | ||
IEvent* event_system = dynamic_cast<IEvent*>(_system); | ||
|
||
//Initialization of continous equations and bounded parameters | ||
_system->init(start_time,end_time); | ||
|
||
//Intialization of discrete equations | ||
_system->setInitial(true); | ||
bool restart=true; | ||
int iter=0; | ||
|
||
while(restart && !(iter++ > 10)) | ||
{ | ||
event_system->saveAll(); | ||
continous_system->update(IContinous::ALL); | ||
restart = event_system->checkForDiscreteEvents(); | ||
} | ||
|
||
event_system->saveAll(); | ||
|
||
|
||
_system->setInitial(false); | ||
} |
16 changes: 16 additions & 0 deletions
16
SimulationRuntime/cpp/Source/Solver/Implementation/Initialization.h
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,16 @@ | ||
#pragma once | ||
#include "System/Interfaces/ISystemInitialization.h" | ||
#include "System/Interfaces/IEvent.h" | ||
#include "System/Interfaces/IContinous.h" | ||
class Initialization | ||
{ | ||
public: | ||
Initialization(ISystemInitialization* system_initialization); | ||
~Initialization(void); | ||
void initializeSystem(double start_time, double end_time); | ||
private: | ||
|
||
ISystemInitialization* _system; | ||
|
||
}; | ||
|
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
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
Oops, something went wrong.