Added bool variable for exportation of optimization results

This commit is contained in:
iasonmanolas 2021-06-09 21:01:00 +03:00
parent 596dbaba7e
commit 33774c546c
1 changed files with 27 additions and 23 deletions

View File

@ -284,7 +284,7 @@ struct Colors
inline static std::string Settings{"OptimizationSettings"}; inline static std::string Settings{"OptimizationSettings"};
}; };
void save(const string &saveToPath) void save(const string &saveToPath, const bool shouldExportDebugFiles = false)
{ {
std::filesystem::create_directories(saveToPath); std::filesystem::create_directories(saveToPath);
//clear directory //clear directory
@ -326,29 +326,33 @@ struct Colors
/*TODO: Refactor since the meshes are saved for each simulation scenario although they do not change*/ /*TODO: Refactor since the meshes are saved for each simulation scenario although they do not change*/
//Save jobs and meshes for each simulation scenario //Save jobs and meshes for each simulation scenario
//Save the reduced and full patterns if (shouldExportDebugFiles) {
const std::filesystem::path simulationJobsPath( //Save the reduced and full patterns
std::filesystem::path(saveToPath).append("SimulationJobs")); const std::filesystem::path simulationJobsPath(
const int numberOfSimulationJobs = fullPatternSimulationJobs.size(); std::filesystem::path(saveToPath).append("SimulationJobs"));
for (int simulationScenarioIndex = 0; simulationScenarioIndex < numberOfSimulationJobs; const int numberOfSimulationJobs = fullPatternSimulationJobs.size();
simulationScenarioIndex++) { for (int simulationScenarioIndex = 0;
const std::shared_ptr<SimulationJob> &pFullPatternSimulationJob simulationScenarioIndex < numberOfSimulationJobs;
= fullPatternSimulationJobs[simulationScenarioIndex]; simulationScenarioIndex++) {
std::filesystem::path simulationJobFolderPath( const std::shared_ptr<SimulationJob> &pFullPatternSimulationJob
std::filesystem::path(simulationJobsPath).append(pFullPatternSimulationJob->label)); = fullPatternSimulationJobs[simulationScenarioIndex];
std::filesystem::create_directories(simulationJobFolderPath); std::filesystem::path simulationJobFolderPath(
const auto fullPatternDirectoryPath = std::filesystem::path(simulationJobFolderPath) std::filesystem::path(simulationJobsPath)
.append("Full"); .append(pFullPatternSimulationJob->label));
std::filesystem::create_directory(fullPatternDirectoryPath); std::filesystem::create_directories(simulationJobFolderPath);
pFullPatternSimulationJob->save(fullPatternDirectoryPath.string()); const auto fullPatternDirectoryPath
const std::shared_ptr<SimulationJob> &pReducedPatternSimulationJob = std::filesystem::path(simulationJobFolderPath).append("Full");
= reducedPatternSimulationJobs[simulationScenarioIndex]; std::filesystem::create_directory(fullPatternDirectoryPath);
const auto reducedPatternDirectoryPath pFullPatternSimulationJob->save(fullPatternDirectoryPath.string());
= std::filesystem::path(simulationJobFolderPath).append("Reduced"); const std::shared_ptr<SimulationJob> &pReducedPatternSimulationJob
if (!std::filesystem::exists(reducedPatternDirectoryPath)) { = reducedPatternSimulationJobs[simulationScenarioIndex];
std::filesystem::create_directory(reducedPatternDirectoryPath); const auto reducedPatternDirectoryPath
= std::filesystem::path(simulationJobFolderPath).append("Reduced");
if (!std::filesystem::exists(reducedPatternDirectoryPath)) {
std::filesystem::create_directory(reducedPatternDirectoryPath);
}
pReducedPatternSimulationJob->save(reducedPatternDirectoryPath.string());
} }
pReducedPatternSimulationJob->save(reducedPatternDirectoryPath.string());
} }
settings.save(saveToPath); settings.save(saveToPath);