Added linear and non linear chronos euler simulation model classes in order to be able to out-of-the-box use them with a factory class

This commit is contained in:
iasonmanolas 2022-08-08 12:02:41 +03:00
parent 68d5655214
commit dd21445f52
2 changed files with 26 additions and 16 deletions

View File

@ -2,17 +2,25 @@
SimulationModelFactory::SimulationModelFactory() {} SimulationModelFactory::SimulationModelFactory() {}
std::unique_ptr<SimulationModel> SimulationModelFactory::create( std::unique_ptr<SimulationModel>
const std::string &simulationModelLabel) SimulationModelFactory::create(const std::string& simulationModelLabel)
{ {
if (simulationModelLabel == DRMSimulationModel::label) { if (simulationModelLabel == DRMSimulationModel::label) {
return std::make_unique<DRMSimulationModel>(); return std::make_unique<DRMSimulationModel>();
} else if (simulationModelLabel == ChronosEulerSimulationModel::label) { } else if (simulationModelLabel == ChronosEulerSimulationModel::label) {
return std::make_unique<ChronosEulerSimulationModel>(); return std::make_unique<ChronosEulerSimulationModel>();
} } else if (simulationModelLabel == ChronosEulerLinearSimulationModel::label) {
std::cerr << "Simulation model used for computing the optimization results was " return std::make_unique<ChronosEulerLinearSimulationModel>();
"not recognized" } else if (simulationModelLabel ==
<< std::endl; ChronosEulerNonLinearSimulationModel::label) {
assert(false); return std::make_unique<ChronosEulerNonLinearSimulationModel>();
return nullptr; } else if (simulationModelLabel == LinearSimulationModel::label) {
return std::make_unique<LinearSimulationModel>();
}
std::cerr
<< "Simulation model used for computing the optimization results was "
"not recognized"
<< std::endl;
assert(false);
return nullptr;
} }

View File

@ -1,17 +1,19 @@
#ifndef SIMULATIONMODELFACTORY_HPP #ifndef SIMULATIONMODELFACTORY_HPP
#define SIMULATIONMODELFACTORY_HPP #define SIMULATIONMODELFACTORY_HPP
#include "chronoseulerlinearsimulationmodel.hpp"
#include "chronoseulernonlinearsimulationmodel.hpp"
#include "chronoseulersimulationmodel.hpp" #include "chronoseulersimulationmodel.hpp"
#include "der_leimer.hpp" #include "der_leimer.hpp"
#include "drmsimulationmodel.hpp" #include "drmsimulationmodel.hpp"
#include "linearsimulationmodel.hpp" #include "linearsimulationmodel.hpp"
#include <string> #include <string>
class SimulationModelFactory class SimulationModelFactory {
{
public: public:
SimulationModelFactory(); SimulationModelFactory();
static std::unique_ptr<SimulationModel> create(const std::string &simulationModelLabel); static std::unique_ptr<SimulationModel>
create(const std::string &simulationModelLabel);
}; };
#endif // SIMULATIONMODELFACTORY_HPP #endif // SIMULATIONMODELFACTORY_HPP