Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@25418 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
1 parent
c1810e5
commit ccc0e9e
Showing
3 changed files
with
167 additions
and
167 deletions.
There are no files selected for viewing
50 changes: 25 additions & 25 deletions
50
SimulationRuntime/cpp/Include/SimCoreFactory/BodasFactory/BodasFactory.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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
#pragma once | ||
#include "Modelica.h" | ||
#include <Policies/FactoryConfig.h> | ||
#include <memory> | ||
|
||
class ISimController; | ||
class ISettingsFactory; | ||
|
||
class BodasFactory | ||
{ | ||
public: | ||
BodasFactory(std::string library_path, std::string modelicasystem_path); | ||
boost::shared_ptr<ISimController> LoadSimController(); | ||
boost::shared_ptr<ISettingsFactory> LoadSettingsFactory(); | ||
boost::shared_ptr<IAlgLoopSolverFactory> LoadAlgLoopSolverFactory(IGlobalSettings*); | ||
boost::shared_ptr<ISolver> LoadSolver(IMixedSystem* system, string solver_name,boost::shared_ptr<ISolverSettings> solver_settings); | ||
boost::shared_ptr<IMixedSystem> LoadSystem(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>); | ||
boost::shared_ptr<ISimData> LoadSimData(); | ||
boost::shared_ptr<ISolverSettings> LoadSolverSettings(string solver_name, boost::shared_ptr<IGlobalSettings>); | ||
boost::shared_ptr<IAlgLoopSolver> LoadAlgLoopSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings); | ||
boost::shared_ptr<INonLinSolverSettings> LoadAlgLoopSolverSettings(string solver_name); | ||
|
||
private: | ||
string _library_path; | ||
string _modelicasystem_path; | ||
#pragma once | ||
#include "Modelica.h" | ||
#include <Policies/FactoryConfig.h> | ||
#include <memory> | ||
|
||
class ISimController; | ||
class ISettingsFactory; | ||
|
||
class BodasFactory | ||
{ | ||
public: | ||
BodasFactory(std::string library_path, std::string modelicasystem_path); | ||
boost::shared_ptr<ISimController> LoadSimController(); | ||
boost::shared_ptr<ISettingsFactory> LoadSettingsFactory(); | ||
boost::shared_ptr<IAlgLoopSolverFactory> LoadAlgLoopSolverFactory(IGlobalSettings*); | ||
boost::shared_ptr<ISolver> LoadSolver(IMixedSystem* system, string solver_name,boost::shared_ptr<ISolverSettings> solver_settings); | ||
boost::shared_ptr<IMixedSystem> LoadSystem(IGlobalSettings*, boost::shared_ptr<IAlgLoopSolverFactory>, boost::shared_ptr<ISimData>); | ||
boost::shared_ptr<ISimData> LoadSimData(); | ||
boost::shared_ptr<ISolverSettings> LoadSolverSettings(string solver_name, boost::shared_ptr<IGlobalSettings>); | ||
boost::shared_ptr<IAlgLoopSolver> LoadAlgLoopSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings); | ||
boost::shared_ptr<INonLinSolverSettings> LoadAlgLoopSolverSettings(string solver_name); | ||
|
||
private: | ||
string _library_path; | ||
string _modelicasystem_path; | ||
}; |
68 changes: 34 additions & 34 deletions
68
SimulationRuntime/cpp/Include/SimCoreFactory/Policies/LinSolverBodasFactory.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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
#pragma once | ||
#include <ObjectFactory.h> | ||
|
||
/* | ||
Policy class to create lin solver object | ||
*/ | ||
template<class CreationPolicy> | ||
struct LinSolverBodasFactory : public ObjectFactory<CreationPolicy> | ||
{ | ||
public: | ||
LinSolverBodasFactory(PATH library_path, PATH modelicasystem_path, PATH config_path) | ||
: ObjectFactory<CreationPolicy>(library_path, modelicasystem_path, config_path) | ||
, _last_selected_solver("empty") | ||
{ | ||
} | ||
|
||
virtual ~LinSolverBodasFactory() | ||
{ | ||
} | ||
|
||
virtual boost::shared_ptr<ILinSolverSettings> createLinSolverSettings(string lin_solver) | ||
{ | ||
boost::shared_ptr<ILinSolverSettings> linsolversetting; | ||
return linsolversetting; | ||
} | ||
|
||
virtual boost::shared_ptr<IAlgLoopSolver> createLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<ILinSolverSettings> solver_settings) | ||
{ | ||
boost::shared_ptr<IAlgLoopSolver> solver; | ||
return solver; | ||
} | ||
|
||
protected: | ||
string _last_selected_solver; | ||
#pragma once | ||
#include <ObjectFactory.h> | ||
|
||
/* | ||
Policy class to create lin solver object | ||
*/ | ||
template<class CreationPolicy> | ||
struct LinSolverBodasFactory : public ObjectFactory<CreationPolicy> | ||
{ | ||
public: | ||
LinSolverBodasFactory(PATH library_path, PATH modelicasystem_path, PATH config_path) | ||
: ObjectFactory<CreationPolicy>(library_path, modelicasystem_path, config_path) | ||
, _last_selected_solver("empty") | ||
{ | ||
} | ||
|
||
virtual ~LinSolverBodasFactory() | ||
{ | ||
} | ||
|
||
virtual boost::shared_ptr<ILinSolverSettings> createLinSolverSettings(string lin_solver) | ||
{ | ||
boost::shared_ptr<ILinSolverSettings> linsolversetting; | ||
return linsolversetting; | ||
} | ||
|
||
virtual boost::shared_ptr<IAlgLoopSolver> createLinSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<ILinSolverSettings> solver_settings) | ||
{ | ||
boost::shared_ptr<IAlgLoopSolver> solver; | ||
return solver; | ||
} | ||
|
||
protected: | ||
string _last_selected_solver; | ||
}; |
216 changes: 108 additions & 108 deletions
216
SimulationRuntime/cpp/SimCoreFactory/BodasFactory/BodasFactory.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 |
---|---|---|
@@ -1,109 +1,109 @@ | ||
#include <Core/SimController/ISimController.h> | ||
#include <SimCoreFactory/BodasFactory/BodasFactory.h> | ||
|
||
extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path); | ||
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings, PATH library_path, PATH modelicasystem_path); | ||
extern "C" ISettingsFactory* createSettingsFactory(PATH library_path, PATH modelicasystem_path); | ||
extern "C" ISimData* createSimData(); | ||
extern "C" ISolverSettings* createRTEulerSettings(IGlobalSettings* globalSettings); | ||
extern "C" ISolver* createRTEuler(IMixedSystem* system, ISolverSettings* settings); | ||
extern "C" INonLinSolverSettings* createKinsolSettings(); | ||
extern "C" IAlgLoopSolver* createKinsol(IAlgLoop* algloop, INonLinSolverSettings* solver_settings); | ||
extern "C" IMixedSystem* createModelicaSystem(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolver, boost::shared_ptr<ISimData> simdata); | ||
|
||
BodasFactory::BodasFactory(string library_path, string modelicasystem_path) | ||
: _library_path(library_path) | ||
, _modelicasystem_path(modelicasystem_path) | ||
{ | ||
} | ||
|
||
boost::shared_ptr<ISimController> BodasFactory::LoadSimController() | ||
{ | ||
ISimController* simController = createSimController(_library_path, _modelicasystem_path); | ||
return boost::shared_ptr<ISimController>(simController); | ||
} | ||
|
||
boost::shared_ptr<ISettingsFactory> BodasFactory::LoadSettingsFactory() | ||
{ | ||
ISettingsFactory* settingsFactory = createSettingsFactory(_library_path, _modelicasystem_path); | ||
return boost::shared_ptr<ISettingsFactory>(settingsFactory); | ||
} | ||
|
||
boost::shared_ptr<IAlgLoopSolverFactory> BodasFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings) | ||
{ | ||
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactory(globalSettings, _library_path, _modelicasystem_path); | ||
return boost::shared_ptr<IAlgLoopSolverFactory>(algloopsolverFactory); | ||
} | ||
|
||
boost::shared_ptr<IMixedSystem> BodasFactory::LoadSystem(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolver, boost::shared_ptr<ISimData> simData) | ||
{ | ||
IMixedSystem* system = createModelicaSystem(globalSettings, nonlinsolver, simData); | ||
return boost::shared_ptr<IMixedSystem>(system); | ||
} | ||
|
||
boost::shared_ptr<ISimData> BodasFactory::LoadSimData() | ||
{ | ||
ISimData* simData = createSimData(); | ||
return boost::shared_ptr<ISimData>(simData); | ||
} | ||
|
||
boost::shared_ptr<ISolver> BodasFactory::LoadSolver(IMixedSystem* system, string solver_name, boost::shared_ptr<ISolverSettings> solver_settings) | ||
{ | ||
ISolver* solver; | ||
if (solver_name.compare("createRTEuler") == 0) | ||
{ | ||
solver = createRTEuler(system, solver_settings.get()); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<ISolver>(solver); | ||
} | ||
|
||
boost::shared_ptr<ISolverSettings> BodasFactory::LoadSolverSettings(string solver_name, boost::shared_ptr<IGlobalSettings> global_settings) | ||
{ | ||
ISolverSettings* solver_settings; | ||
if (solver_name.compare("createRTEulerSettings") == 0) | ||
{ | ||
solver_settings = createRTEulerSettings(global_settings.get()); | ||
} | ||
else | ||
{ | ||
|
||
} | ||
return boost::shared_ptr<ISolverSettings>(solver_settings); | ||
} | ||
|
||
boost::shared_ptr<IAlgLoopSolver> BodasFactory::LoadAlgLoopSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings) | ||
{ | ||
IAlgLoopSolver* algloopsolver; | ||
if (solver_name.compare("createNewton") == 0) | ||
{ | ||
//algloopsolver = createNewton(algLoop, solver_settings.get()); | ||
} | ||
else if (solver_name.compare("createKinsol") == 0) | ||
{ | ||
algloopsolver = createKinsol(algLoop, solver_settings.get()); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<IAlgLoopSolver>(algloopsolver); | ||
} | ||
|
||
boost::shared_ptr<INonLinSolverSettings> BodasFactory::LoadAlgLoopSolverSettings(string solver_name) | ||
{ | ||
INonLinSolverSettings* solver_settings; | ||
if (solver_name.compare("createNewtonSettings") == 0) | ||
{ | ||
//solver_settings = createNewtonSettings(); | ||
} | ||
else if (solver_name.compare("createKinsolSettings") == 0) | ||
{ | ||
solver_settings = createKinsolSettings(); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<INonLinSolverSettings>(solver_settings); | ||
#include <Core/SimController/ISimController.h> | ||
#include <SimCoreFactory/BodasFactory/BodasFactory.h> | ||
|
||
extern "C" ISimController* createSimController(PATH library_path, PATH modelicasystem_path); | ||
extern "C" IAlgLoopSolverFactory* createAlgLoopSolverFactory(IGlobalSettings* globalSettings, PATH library_path, PATH modelicasystem_path); | ||
extern "C" ISettingsFactory* createSettingsFactory(PATH library_path, PATH modelicasystem_path); | ||
extern "C" ISimData* createSimData(); | ||
extern "C" ISolverSettings* createRTEulerSettings(IGlobalSettings* globalSettings); | ||
extern "C" ISolver* createRTEuler(IMixedSystem* system, ISolverSettings* settings); | ||
extern "C" INonLinSolverSettings* createKinsolSettings(); | ||
extern "C" IAlgLoopSolver* createKinsol(IAlgLoop* algloop, INonLinSolverSettings* solver_settings); | ||
extern "C" IMixedSystem* createModelicaSystem(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolver, boost::shared_ptr<ISimData> simdata); | ||
|
||
BodasFactory::BodasFactory(string library_path, string modelicasystem_path) | ||
: _library_path(library_path) | ||
, _modelicasystem_path(modelicasystem_path) | ||
{ | ||
} | ||
|
||
boost::shared_ptr<ISimController> BodasFactory::LoadSimController() | ||
{ | ||
ISimController* simController = createSimController(_library_path, _modelicasystem_path); | ||
return boost::shared_ptr<ISimController>(simController); | ||
} | ||
|
||
boost::shared_ptr<ISettingsFactory> BodasFactory::LoadSettingsFactory() | ||
{ | ||
ISettingsFactory* settingsFactory = createSettingsFactory(_library_path, _modelicasystem_path); | ||
return boost::shared_ptr<ISettingsFactory>(settingsFactory); | ||
} | ||
|
||
boost::shared_ptr<IAlgLoopSolverFactory> BodasFactory::LoadAlgLoopSolverFactory(IGlobalSettings* globalSettings) | ||
{ | ||
IAlgLoopSolverFactory* algloopsolverFactory = createAlgLoopSolverFactory(globalSettings, _library_path, _modelicasystem_path); | ||
return boost::shared_ptr<IAlgLoopSolverFactory>(algloopsolverFactory); | ||
} | ||
|
||
boost::shared_ptr<IMixedSystem> BodasFactory::LoadSystem(IGlobalSettings* globalSettings, boost::shared_ptr<IAlgLoopSolverFactory> nonlinsolver, boost::shared_ptr<ISimData> simData) | ||
{ | ||
IMixedSystem* system = createModelicaSystem(globalSettings, nonlinsolver, simData); | ||
return boost::shared_ptr<IMixedSystem>(system); | ||
} | ||
|
||
boost::shared_ptr<ISimData> BodasFactory::LoadSimData() | ||
{ | ||
ISimData* simData = createSimData(); | ||
return boost::shared_ptr<ISimData>(simData); | ||
} | ||
|
||
boost::shared_ptr<ISolver> BodasFactory::LoadSolver(IMixedSystem* system, string solver_name, boost::shared_ptr<ISolverSettings> solver_settings) | ||
{ | ||
ISolver* solver; | ||
if (solver_name.compare("createRTEuler") == 0) | ||
{ | ||
solver = createRTEuler(system, solver_settings.get()); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<ISolver>(solver); | ||
} | ||
|
||
boost::shared_ptr<ISolverSettings> BodasFactory::LoadSolverSettings(string solver_name, boost::shared_ptr<IGlobalSettings> global_settings) | ||
{ | ||
ISolverSettings* solver_settings; | ||
if (solver_name.compare("createRTEulerSettings") == 0) | ||
{ | ||
solver_settings = createRTEulerSettings(global_settings.get()); | ||
} | ||
else | ||
{ | ||
|
||
} | ||
return boost::shared_ptr<ISolverSettings>(solver_settings); | ||
} | ||
|
||
boost::shared_ptr<IAlgLoopSolver> BodasFactory::LoadAlgLoopSolver(IAlgLoop* algLoop, string solver_name, boost::shared_ptr<INonLinSolverSettings> solver_settings) | ||
{ | ||
IAlgLoopSolver* algloopsolver; | ||
if (solver_name.compare("createNewton") == 0) | ||
{ | ||
//algloopsolver = createNewton(algLoop, solver_settings.get()); | ||
} | ||
else if (solver_name.compare("createKinsol") == 0) | ||
{ | ||
algloopsolver = createKinsol(algLoop, solver_settings.get()); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<IAlgLoopSolver>(algloopsolver); | ||
} | ||
|
||
boost::shared_ptr<INonLinSolverSettings> BodasFactory::LoadAlgLoopSolverSettings(string solver_name) | ||
{ | ||
INonLinSolverSettings* solver_settings; | ||
if (solver_name.compare("createNewtonSettings") == 0) | ||
{ | ||
//solver_settings = createNewtonSettings(); | ||
} | ||
else if (solver_name.compare("createKinsolSettings") == 0) | ||
{ | ||
solver_settings = createKinsolSettings(); | ||
} | ||
else | ||
{ | ||
} | ||
return boost::shared_ptr<INonLinSolverSettings>(solver_settings); | ||
} |