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() {}
std::unique_ptr<SimulationModel> SimulationModelFactory::create(
const std::string &simulationModelLabel)
std::unique_ptr<SimulationModel>
SimulationModelFactory::create(const std::string& simulationModelLabel)
{
if (simulationModelLabel == DRMSimulationModel::label) {
return std::make_unique<DRMSimulationModel>();
} else if (simulationModelLabel == ChronosEulerSimulationModel::label) {
return std::make_unique<ChronosEulerSimulationModel>();
}
std::cerr << "Simulation model used for computing the optimization results was "
"not recognized"
<< std::endl;
assert(false);
return nullptr;
if (simulationModelLabel == DRMSimulationModel::label) {
return std::make_unique<DRMSimulationModel>();
} else if (simulationModelLabel == ChronosEulerSimulationModel::label) {
return std::make_unique<ChronosEulerSimulationModel>();
} else if (simulationModelLabel == ChronosEulerLinearSimulationModel::label) {
return std::make_unique<ChronosEulerLinearSimulationModel>();
} else if (simulationModelLabel ==
ChronosEulerNonLinearSimulationModel::label) {
return std::make_unique<ChronosEulerNonLinearSimulationModel>();
} 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
#define SIMULATIONMODELFACTORY_HPP
#include "chronoseulerlinearsimulationmodel.hpp"
#include "chronoseulernonlinearsimulationmodel.hpp"
#include "chronoseulersimulationmodel.hpp"
#include "der_leimer.hpp"
#include "drmsimulationmodel.hpp"
#include "linearsimulationmodel.hpp"
#include <string>
class SimulationModelFactory
{
class SimulationModelFactory {
public:
SimulationModelFactory();
static std::unique_ptr<SimulationModel> create(const std::string &simulationModelLabel);
SimulationModelFactory();
static std::unique_ptr<SimulationModel>
create(const std::string &simulationModelLabel);
};
#endif // SIMULATIONMODELFACTORY_HPP