From 33774c546ccd7056ada8d2f98642984943732396 Mon Sep 17 00:00:00 2001 From: iasonmanolas Date: Wed, 9 Jun 2021 21:01:00 +0300 Subject: [PATCH] Added bool variable for exportation of optimization results --- reducedmodeloptimizer_structs.hpp | 50 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/reducedmodeloptimizer_structs.hpp b/reducedmodeloptimizer_structs.hpp index a2666cb..c05ab8f 100644 --- a/reducedmodeloptimizer_structs.hpp +++ b/reducedmodeloptimizer_structs.hpp @@ -284,7 +284,7 @@ struct Colors 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); //clear directory @@ -326,29 +326,33 @@ struct Colors /*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 the reduced and full patterns - const std::filesystem::path simulationJobsPath( - std::filesystem::path(saveToPath).append("SimulationJobs")); - const int numberOfSimulationJobs = fullPatternSimulationJobs.size(); - for (int simulationScenarioIndex = 0; simulationScenarioIndex < numberOfSimulationJobs; - simulationScenarioIndex++) { - const std::shared_ptr &pFullPatternSimulationJob - = fullPatternSimulationJobs[simulationScenarioIndex]; - std::filesystem::path simulationJobFolderPath( - std::filesystem::path(simulationJobsPath).append(pFullPatternSimulationJob->label)); - std::filesystem::create_directories(simulationJobFolderPath); - const auto fullPatternDirectoryPath = std::filesystem::path(simulationJobFolderPath) - .append("Full"); - std::filesystem::create_directory(fullPatternDirectoryPath); - pFullPatternSimulationJob->save(fullPatternDirectoryPath.string()); - const std::shared_ptr &pReducedPatternSimulationJob - = reducedPatternSimulationJobs[simulationScenarioIndex]; - const auto reducedPatternDirectoryPath - = std::filesystem::path(simulationJobFolderPath).append("Reduced"); - if (!std::filesystem::exists(reducedPatternDirectoryPath)) { - std::filesystem::create_directory(reducedPatternDirectoryPath); + if (shouldExportDebugFiles) { + //Save the reduced and full patterns + const std::filesystem::path simulationJobsPath( + std::filesystem::path(saveToPath).append("SimulationJobs")); + const int numberOfSimulationJobs = fullPatternSimulationJobs.size(); + for (int simulationScenarioIndex = 0; + simulationScenarioIndex < numberOfSimulationJobs; + simulationScenarioIndex++) { + const std::shared_ptr &pFullPatternSimulationJob + = fullPatternSimulationJobs[simulationScenarioIndex]; + std::filesystem::path simulationJobFolderPath( + std::filesystem::path(simulationJobsPath) + .append(pFullPatternSimulationJob->label)); + std::filesystem::create_directories(simulationJobFolderPath); + const auto fullPatternDirectoryPath + = std::filesystem::path(simulationJobFolderPath).append("Full"); + std::filesystem::create_directory(fullPatternDirectoryPath); + pFullPatternSimulationJob->save(fullPatternDirectoryPath.string()); + const std::shared_ptr &pReducedPatternSimulationJob + = reducedPatternSimulationJobs[simulationScenarioIndex]; + 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);