Hardcoded the 22 hexagon test-surface
This commit is contained in:
parent
90dc2ac081
commit
b2bd12d8df
|
@ -1,7 +1,9 @@
|
|||
#include "reducedmodelevaluator.hpp"
|
||||
#include "hexagonremesher.hpp"
|
||||
#include "reducedmodel.hpp"
|
||||
#include "reducedmodeloptimizer.hpp"
|
||||
#include "trianglepatterngeometry.hpp"
|
||||
#include <execution>
|
||||
#include <filesystem>
|
||||
|
||||
using FullPatternVertexIndex = VertexIndex;
|
||||
|
@ -9,28 +11,77 @@ using ReducedPatternVertexIndex = VertexIndex;
|
|||
|
||||
ReducedModelEvaluator::ReducedModelEvaluator()
|
||||
{
|
||||
|
||||
pTileIntoSurface = [&]() {
|
||||
std::istringstream inputStream_tileIntoTriSurface(tileIntoSurfaceFileContent);
|
||||
VCGTriMesh tileInto_triMesh;
|
||||
const bool surfaceLoadSuccessfull = tileInto_triMesh.load(inputStream_tileIntoTriSurface);
|
||||
tileInto_triMesh.setLabel("instantMeshes_plane_34");
|
||||
assert(surfaceLoadSuccessfull);
|
||||
return PolygonalRemeshing::remeshWithPolygons(tileInto_triMesh);
|
||||
}();
|
||||
}
|
||||
|
||||
//double ReducedModelEvaluator::evaluateOptimizationSettings(
|
||||
// const ReducedModelOptimization::Settings &optimizationSettings,
|
||||
// const std::vector<std::shared_ptr<PatternGeometry>> &pPatterns,
|
||||
// std::vector<ReducedModelEvaluator::Results> &patternEvaluationResults)
|
||||
//{
|
||||
// assert(!pPatterns.empty());
|
||||
// double optimizationError = 0;
|
||||
// auto start = std::chrono::high_resolution_clock::now();
|
||||
// std::vector<double> averageNormalizedError(pPatterns.size(), 0);
|
||||
// patternEvaluationResults.clear();
|
||||
// patternEvaluationResults.resize(pPatterns.size());
|
||||
// std::for_each(
|
||||
// // std::execution::par_unseq,
|
||||
// pPatterns.begin(),
|
||||
// pPatterns.end(),
|
||||
// [&](const std::shared_ptr<ConstPatternGeometry> &pPattern) {
|
||||
// // std::cout << "Optimizing " << pPattern->getLabel() << std::endl;
|
||||
// ReducedModelOptimization::Results optimizationResults;
|
||||
// ReducedModelOptimizer optimizer;
|
||||
// optimizer.optimize(*pPattern, optimizationSettings, optimizationResults);
|
||||
// const auto evaluationResults
|
||||
// = ReducedModelEvaluator::evaluateReducedModel(optimizationResults,
|
||||
// tileIntoSurfaceFilePath,
|
||||
// scenariosDirPath,
|
||||
// fullPatternTessellatedResultsDirPath);
|
||||
// const double averageNormalizedErrorOfPattern
|
||||
// = std::reduce(evaluationResults.distances_normalizedDrm2reduced.begin(),
|
||||
// evaluationResults.distances_normalizedDrm2reduced.end())
|
||||
// / evaluationResults.distances_normalizedDrm2reduced.size();
|
||||
// const int patternIndex = &pPattern - &patterns[0];
|
||||
// averageNormalizedError[patternIndex] = averageNormalizedErrorOfPattern;
|
||||
// patternsEvaluationResults[patternIndex] = evaluationResults;
|
||||
// });
|
||||
// const double strategyAverageNormalizedError = std::reduce(std::execution::par_unseq,
|
||||
// averageNormalizedError.begin(),
|
||||
// averageNormalizedError.end())
|
||||
// / pPointers.size();
|
||||
// const auto totalDuration_min = std::chrono::duration_cast<std::chrono::seconds>(
|
||||
// std::chrono::high_resolution_clock::now() - start)
|
||||
// .count()
|
||||
// / 60.0;
|
||||
// std::cout << "Optimized pattern(s) in:" << totalDuration_min << " minutes." << std::endl;
|
||||
// std::cout << "Average time per pattern:" << totalDuration_min / patternsPointers.size()
|
||||
// << " minutes." << std::endl;
|
||||
// std::cout << "Objective value:" << strategyAverageNormalizedError << std::endl;
|
||||
// return strategyAverageNormalizedError;
|
||||
// // std::cout << "After:" << ++numberOfOptimizationRoundsExecuted << " iterations." << std::endl;
|
||||
//}
|
||||
|
||||
ReducedModelEvaluator::Results ReducedModelEvaluator::evaluateReducedModel(
|
||||
ReducedModelOptimization::Results &optimizationResult)
|
||||
{
|
||||
const std::filesystem::path tileInto_triMesh_filePath
|
||||
= "/home/iason/Coding/build/PatternTillingReducedModel/Meshes/"
|
||||
"instantMeshes_plane_34.ply";
|
||||
const std::filesystem::path scenariosDirectoryPath
|
||||
= "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
"patterns/ReducedModelEvaluator/Scenarios";
|
||||
// const std::filesystem::path reducedPatternFilePath
|
||||
// = "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/TestSet/ReducedPatterns/single_reduced.ply";
|
||||
const std::filesystem::path fullPatternTessellatedResultsDirectoryPath
|
||||
= "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
"patterns/ReducedModelEvaluator/TessellatedResults";
|
||||
|
||||
return evaluateReducedModel(optimizationResult,
|
||||
tileInto_triMesh_filePath,
|
||||
scenariosDirectoryPath,
|
||||
// reducedPatternFilePath,
|
||||
fullPatternTessellatedResultsDirectoryPath);
|
||||
}
|
||||
//void ReducedModelEvaluator::printResults(const Results &evaluationResults,
|
||||
|
@ -77,6 +128,7 @@ void ReducedModelEvaluator::printResults(const Results &evaluationResults,
|
|||
csvFile &csvOutput)
|
||||
{
|
||||
if (settings.shouldWriteHeader) {
|
||||
csvOutput << csvExportingDataStrings[settings.exportingData];
|
||||
printHeader(settings, csvOutput);
|
||||
// csvOutput << "Average error";
|
||||
// csvOutput<<"Cumulative error";
|
||||
|
@ -95,8 +147,6 @@ void ReducedModelEvaluator::printResults(const Results &evaluationResults,
|
|||
void ReducedModelEvaluator::printHeader(const Settings &settings, csvFile &csvOutput)
|
||||
{
|
||||
if (settings.exportingDirection == Horizontal) {
|
||||
csvOutput << csvExportingDataStrings[settings.exportingData];
|
||||
csvOutput.endrow();
|
||||
// csvOutput << "Job label";
|
||||
for (int jobIndex = 0; jobIndex < ReducedModelEvaluator::scenariosTestSetLabels.size();
|
||||
jobIndex++) {
|
||||
|
@ -213,50 +263,49 @@ void ReducedModelEvaluator::printResultsVertically(const Results &evaluationResu
|
|||
csvOutput << endrow;
|
||||
}
|
||||
|
||||
//void ReducedModelEvaluator::createFullAndReducedPatternTessellations(){
|
||||
|
||||
//}
|
||||
|
||||
//ReducedModelEvaluator::Results ReducedModelEvaluator::evaluateReducedModel(
|
||||
// std::vector<ReducedModelOptimization::Results> &optimizationResults,
|
||||
// const std::filesystem::path &tileInto_triMesh_filePath,
|
||||
// const std::filesystem::path &scenariosDirectoryPath,
|
||||
// // const std::filesystem::path &reducedPatternFilePath,
|
||||
// const std::filesystem::path &fullPatternTessellatedResultsDirectoryPath)
|
||||
//{
|
||||
// //Load surface
|
||||
// std::shared_ptr<VCGPolyMesh> pTileIntoSurface = [&]() {
|
||||
// VCGTriMesh tileInto_triMesh;
|
||||
// const bool surfaceLoadSuccessfull = tileInto_triMesh.load(tileInto_triMesh_filePath);
|
||||
// assert(surfaceLoadSuccessfull);
|
||||
// return PolygonalRemeshing::remeshWithPolygons(tileInto_triMesh);
|
||||
// }();
|
||||
// const double optimizedBaseTriangleHeight = vcg::Distance(optimizationResult.baseTriangle.cP(0),
|
||||
// (optimizationResult.baseTriangle.cP(1)
|
||||
// + optimizationResult.baseTriangle.cP(
|
||||
// 2))
|
||||
// / 2);
|
||||
// pTileIntoSurface->moveToCenter();
|
||||
// const double scaleFactor = optimizedBaseTriangleHeight
|
||||
// / pTileIntoSurface->getAverageFaceRadius();
|
||||
// vcg::tri::UpdatePosition<VCGPolyMesh>::Scale(*pTileIntoSurface, scaleFactor);
|
||||
// //Tile full pattern into surface
|
||||
|
||||
//}
|
||||
|
||||
ReducedModelEvaluator::Results ReducedModelEvaluator::evaluateReducedModel(
|
||||
ReducedModelOptimization::Results &optimizationResult,
|
||||
const std::filesystem::path &tileInto_triMesh_filePath,
|
||||
const std::filesystem::path &scenariosDirectoryPath,
|
||||
// const std::filesystem::path &reducedPatternFilePath,
|
||||
const std::filesystem::path &fullPatternTessellatedResultsDirectoryPath)
|
||||
{
|
||||
// std::shared_ptr<VCGPolyMesh> pTileIntoSurface = std::make_shared<VCGPolyMesh>();
|
||||
// std::filesystem::path tileIntoSurfaceFilePath{
|
||||
// "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/TestSet/TileIntoSurface/plane_34Polygons.ply"};
|
||||
// assert(std::filesystem::exists(tileIntoSurfaceFilePath));
|
||||
// pTileIntoSurface->load(tileIntoSurfaceFilePath);
|
||||
|
||||
//Set required file paths
|
||||
// const std::filesystem::path drmSettingsFilePath
|
||||
// = "/home/iason/Coding/Projects/Approximating shapes with flat "
|
||||
// "patterns/ReducedModelOptimization/DefaultSettings/DRMSettings/"
|
||||
// "defaultDRMSimulationSettings.json";
|
||||
DRMSimulationModel::Settings drmSimulationSettings;
|
||||
drmSimulationSettings.totalExternalForcesNormPercentageTermination = 1e-3;
|
||||
// drmSimulationSettings.load(drmSettingsFilePath);
|
||||
drmSimulationSettings.linearGuessForceScaleFactor = 0.5;
|
||||
drmSimulationSettings.debugModeStep = 10000;
|
||||
drmSimulationSettings.beVerbose = true;
|
||||
drmSimulationSettings.maxDRMIterations = 1e6;
|
||||
// drmSimulationSettings.translationalKineticEnergyThreshold = 1e-15;
|
||||
// drmSimulationSettings.viscousDampingFactor = 1e-2;
|
||||
constexpr bool shouldRerunFullPatternSimulation = false;
|
||||
|
||||
//Load surface
|
||||
std::shared_ptr<VCGPolyMesh> pTileIntoSurface = [&]() {
|
||||
VCGTriMesh tileInto_triMesh;
|
||||
const bool surfaceLoadSuccessfull = tileInto_triMesh.load(tileInto_triMesh_filePath);
|
||||
assert(surfaceLoadSuccessfull);
|
||||
return PolygonalRemeshing::remeshWithPolygons(tileInto_triMesh);
|
||||
}();
|
||||
const double optimizedBaseTriangleHeight = vcg::Distance(optimizationResult.baseTriangle.cP(0),
|
||||
(optimizationResult.baseTriangle.cP(1)
|
||||
+ optimizationResult.baseTriangle.cP(
|
||||
2))
|
||||
/ 2);
|
||||
// const double optimizedBaseTriangleHeight = vcg::Distance(optimizationResult.baseTriangle.cP(0),
|
||||
// (optimizationResult.baseTriangle.cP(1)
|
||||
// + optimizationResult.baseTriangle.cP(
|
||||
// 2))
|
||||
// / 2);
|
||||
pTileIntoSurface->moveToCenter();
|
||||
const double scaleFactor = optimizedBaseTriangleHeight
|
||||
const double scaleFactor = optimizationResult.settings.targetBaseTriangleSize
|
||||
/ pTileIntoSurface->getAverageFaceRadius();
|
||||
vcg::tri::UpdatePosition<VCGPolyMesh>::Scale(*pTileIntoSurface, scaleFactor);
|
||||
// tileIntoSurface.registerForDrawing();
|
||||
|
@ -291,7 +340,7 @@ ReducedModelEvaluator::Results ReducedModelEvaluator::evaluateReducedModel(
|
|||
std::vector<PatternGeometry> reducedPatterns(1);
|
||||
reducedPatterns[0].copy(reducedModel);
|
||||
const auto reducedPatternBaseTriangle = reducedModel.computeBaseTriangle();
|
||||
ReducedModelOptimization::Results::applyOptimizationResults_innerHexagon(
|
||||
ReducedModelOptimization::Results::applyOptimizationResults_reducedModel_nonFanned(
|
||||
optimizationResult, reducedPatternBaseTriangle, reducedPatterns[0]);
|
||||
|
||||
std::vector<std::vector<size_t>> perPatternIndexTiledReducedPatternEdgeIndices;
|
||||
|
@ -345,139 +394,178 @@ ReducedModelEvaluator::Results ReducedModelEvaluator::evaluateReducedModel(
|
|||
= perPatternIndexTiledReducedPatternEdgeIndices[0];
|
||||
ReducedModelOptimization::Results::applyOptimizationResults_elements(
|
||||
optimizationResult, pTiledReducedPattern_simulationMesh);
|
||||
pTiledReducedPattern_simulationMesh->reset();
|
||||
// pTiledReducedPattern_simulationMesh->reset();
|
||||
Results evaluationResults;
|
||||
evaluationResults.distances_drm2reduced.fill(-1);
|
||||
evaluationResults.distances_normalizedDrm2reduced.fill(-1);
|
||||
for (int jobIndex = 0; jobIndex < scenariosTestSetLabels.size(); jobIndex++) {
|
||||
const std::string &jobLabel = scenariosTestSetLabels[jobIndex];
|
||||
const std::filesystem::path tiledReducedPatternJobFilePath
|
||||
= std::filesystem::path(scenariosDirectoryPath)
|
||||
.append(pTileIntoSurface->getLabel())
|
||||
.append(jobLabel)
|
||||
.append("ReducedJob")
|
||||
.append(SimulationJob::jsonDefaultFileName);
|
||||
if (!std::filesystem::exists(tiledReducedPatternJobFilePath)) {
|
||||
std::cerr << "Scenario " << jobLabel
|
||||
<< " not found in:" << tiledReducedPatternJobFilePath << std::endl;
|
||||
continue;
|
||||
}
|
||||
//set jobs
|
||||
std::shared_ptr<SimulationJob> pJob_tiledReducedPattern;
|
||||
pJob_tiledReducedPattern = std::make_shared<SimulationJob>(SimulationJob());
|
||||
pJob_tiledReducedPattern->load(tiledReducedPatternJobFilePath, false);
|
||||
pJob_tiledReducedPattern->pMesh = pTiledReducedPattern_simulationMesh;
|
||||
std::shared_ptr<SimulationJob> pJob_tiledFullPattern;
|
||||
pJob_tiledFullPattern = std::make_shared<SimulationJob>(SimulationJob());
|
||||
pJob_tiledFullPattern->pMesh = pTiledFullPattern_simulationMesh;
|
||||
pJob_tiledReducedPattern->remap(reducedToFullViMap, *pJob_tiledFullPattern);
|
||||
// pJob_tiledReducedPattern->registerForDrawing(pTiledReducedPattern->getLabel());
|
||||
// pJob_tiledFullPattern->registerForDrawing(pTiledFullPattern->getLabel());
|
||||
// polyscope::show();
|
||||
//Save reduced job
|
||||
DRMSimulationModel::Settings drmSimulationSettings;
|
||||
drmSimulationSettings.totalExternalForcesNormPercentageTermination = 1e-3;
|
||||
// drmSimulationSettings.load(drmSettingsFilePath);
|
||||
drmSimulationSettings.beVerbose = true;
|
||||
drmSimulationSettings.maxDRMIterations = 5e6;
|
||||
drmSimulationSettings.debugModeStep = 100000;
|
||||
drmSimulationSettings.translationalKineticEnergyThreshold = 1e-15;
|
||||
drmSimulationSettings.linearGuessForceScaleFactor = 0.8;
|
||||
drmSimulationSettings.viscousDampingFactor = 7e-3;
|
||||
drmSimulationSettings.xi = 0.9999;
|
||||
// drmSimulationSettings.Dtini = 5.86;
|
||||
drmSimulationSettings.gamma = 0.25;
|
||||
#ifdef POLYSCOPE_DEFINED
|
||||
// drmSimulationSettings.shouldDraw = true;
|
||||
drmSimulationSettings.shouldCreatePlots = true;
|
||||
#endif
|
||||
constexpr bool shouldRerunFullPatternSimulation = false;
|
||||
// for (int jobIndex = 0; jobIndex < scenariosTestSetLabels.size(); jobIndex++) {
|
||||
std::for_each(
|
||||
//#ifndef POLYSCOPE_DEFINED
|
||||
// std::execution::par_unseq,
|
||||
//#endif
|
||||
scenariosTestSetLabels.begin(),
|
||||
scenariosTestSetLabels.end(),
|
||||
[&](const std::string &jobLabel) {
|
||||
//check if reduced model scenario exists
|
||||
// const std::string &jobLabel = scenariosTestSetLabels[jobIndex];
|
||||
const std::filesystem::path tiledReducedPatternJobFilePath
|
||||
= std::filesystem::path(scenariosDirectoryPath)
|
||||
.append(pTileIntoSurface->getLabel())
|
||||
.append(jobLabel)
|
||||
.append("ReducedJob")
|
||||
.append(SimulationJob::jsonDefaultFileName);
|
||||
if (!std::filesystem::exists(tiledReducedPatternJobFilePath)) {
|
||||
std::cerr << "Scenario " << jobLabel
|
||||
<< " not found in:" << tiledReducedPatternJobFilePath << std::endl;
|
||||
// continue; //if not move on to the next scenario
|
||||
return;
|
||||
}
|
||||
//Map the reduced job to the job on the pattern tessellation
|
||||
//set jobs
|
||||
std::shared_ptr<SimulationJob> pJob_tiledReducedPattern;
|
||||
pJob_tiledReducedPattern = std::make_shared<SimulationJob>(SimulationJob());
|
||||
pJob_tiledReducedPattern->load(tiledReducedPatternJobFilePath, false);
|
||||
pJob_tiledReducedPattern->pMesh = pTiledReducedPattern_simulationMesh;
|
||||
std::shared_ptr<SimulationJob> pJob_tiledFullPattern;
|
||||
pJob_tiledFullPattern = std::make_shared<SimulationJob>(SimulationJob());
|
||||
pJob_tiledFullPattern->pMesh = pTiledFullPattern_simulationMesh;
|
||||
pJob_tiledReducedPattern->remap(reducedToFullViMap, *pJob_tiledFullPattern);
|
||||
// pJob_tiledReducedPattern->registerForDrawing(pTiledReducedPattern->getLabel());
|
||||
// pJob_tiledFullPattern->registerForDrawing(pTiledFullPattern->getLabel());
|
||||
// polyscope::show();
|
||||
const std::filesystem::path surfaceFolderPath
|
||||
= std::filesystem::path(fullPatternTessellatedResultsDirectoryPath)
|
||||
.append(pTileIntoSurface->getLabel());
|
||||
const std::string scenarioLabel = pJob_tiledFullPattern->getLabel();
|
||||
const std::filesystem::path scenarioDirectoryPath
|
||||
= std::filesystem::path(surfaceFolderPath).append(scenarioLabel);
|
||||
//Save reduced job
|
||||
constexpr bool exportReducedJob = false;
|
||||
if (exportReducedJob) {
|
||||
const std::filesystem::path reducedJobDirectoryPath
|
||||
= std::filesystem::path(scenarioDirectoryPath).append("ReducedJob");
|
||||
std::filesystem::create_directories(reducedJobDirectoryPath);
|
||||
pJob_tiledReducedPattern->save(reducedJobDirectoryPath);
|
||||
}
|
||||
//Check if the drm simulation of the full pattern has already been computed
|
||||
////Full
|
||||
const std::string &patternLabel = [&]() {
|
||||
const std::string patternLabel = optimizationResult.baseTriangleFullPattern
|
||||
.getLabel();
|
||||
if (patternLabel.find("_") == std::string::npos) {
|
||||
return std::to_string(optimizationResult.baseTriangleFullPattern.EN()) + "_"
|
||||
+ patternLabel;
|
||||
} else {
|
||||
return patternLabel;
|
||||
}
|
||||
}();
|
||||
const auto fullResultsFolderPath = std::filesystem::path(scenarioDirectoryPath)
|
||||
.append(patternLabel)
|
||||
.append("Results");
|
||||
if (shouldRerunFullPatternSimulation && std::filesystem::exists(fullResultsFolderPath)) {
|
||||
std::filesystem::remove_all(fullResultsFolderPath);
|
||||
}
|
||||
|
||||
const std::filesystem::path surfaceFolderPath
|
||||
= std::filesystem::path(fullPatternTessellatedResultsDirectoryPath)
|
||||
.append(pTileIntoSurface->getLabel());
|
||||
const std::string scenarioLabel = pJob_tiledFullPattern->getLabel();
|
||||
const std::filesystem::path scenarioDirectoryPath = std::filesystem::path(surfaceFolderPath)
|
||||
.append(scenarioLabel);
|
||||
const std::filesystem::path reducedJobDirectoryPath
|
||||
= std::filesystem::path(scenarioDirectoryPath).append("ReducedJob");
|
||||
std::filesystem::create_directories(reducedJobDirectoryPath);
|
||||
pJob_tiledReducedPattern->save(reducedJobDirectoryPath);
|
||||
//Run scenario
|
||||
////Full
|
||||
// const std::string patternLabel = std::to_string(
|
||||
// optimizationResult.baseTriangleFullPattern.EN())
|
||||
// + "_"
|
||||
// + optimizationResult.baseTriangleFullPattern.getLabel();
|
||||
const std::string &patternLabel = optimizationResult.baseTriangleFullPattern.getLabel();
|
||||
const auto fullResultsFolderPath
|
||||
= std::filesystem::path(scenarioDirectoryPath).append(patternLabel).append("Results");
|
||||
if (shouldRerunFullPatternSimulation && std::filesystem::exists(fullResultsFolderPath)) {
|
||||
std::filesystem::remove_all(fullResultsFolderPath);
|
||||
}
|
||||
const std::filesystem::path fullPatternJobFolderPath = std::filesystem::path(
|
||||
scenarioDirectoryPath)
|
||||
.append(patternLabel)
|
||||
.append("SimulationJob");
|
||||
SimulationResults simulationResults_tiledFullPattern_drm;
|
||||
if (std::filesystem::exists(fullResultsFolderPath)) {
|
||||
//Load full pattern results
|
||||
assert(std::filesystem::exists(fullPatternJobFolderPath));
|
||||
simulationResults_tiledFullPattern_drm.load(fullResultsFolderPath,
|
||||
fullPatternJobFolderPath);
|
||||
//#ifdef POLYSCOPE_DEFINED
|
||||
// std::array<double, 3> resultsColor({28.0, 99.0, 227.0});
|
||||
// simulationResults_tiledFullPattern_drm.registerForDrawing(resultsColor);
|
||||
// std::ifstream ifs("CameraSettings.json");
|
||||
// nlohmann::json json;
|
||||
// ifs >> json;
|
||||
// polyscope::view::setCameraFromJson(json.dump(), false);
|
||||
// // polyscope::show();
|
||||
// const std::string cameraJson = polyscope::view::getCameraJson();
|
||||
// std::filesystem::path jsonFilePath("CameraSettings.json");
|
||||
// std::ofstream jsonFile_cameraSettings(jsonFilePath.string());
|
||||
// jsonFile_cameraSettings << cameraJson;
|
||||
// jsonFile_cameraSettings.close();
|
||||
// std::filesystem::create_directories("screenshots");
|
||||
// const std::string screenshotOutputFilePath
|
||||
// = (std::filesystem::current_path()
|
||||
// .append("screenshots")
|
||||
// .append(optimizationResult.label + "_" + pJob_tiledFullPattern->getLabel()))
|
||||
// .string()
|
||||
// + ".png";
|
||||
// // std::cout << "Saving image to:" << screenshotOutputFilePath << std::endl;
|
||||
// polyscope::screenshot(screenshotOutputFilePath, false);
|
||||
// simulationResults_tiledFullPattern_drm.unregister();
|
||||
//#endif
|
||||
|
||||
const std::filesystem::path fullPatternJobFolderPath = std::filesystem::path(
|
||||
scenarioDirectoryPath)
|
||||
.append(patternLabel)
|
||||
.append("SimulationJob");
|
||||
SimulationResults simulationResults_tiledFullPattern_drm;
|
||||
if (std::filesystem::exists(fullResultsFolderPath)) {
|
||||
//Load full pattern results
|
||||
assert(std::filesystem::exists(fullPatternJobFolderPath));
|
||||
simulationResults_tiledFullPattern_drm.load(fullResultsFolderPath,
|
||||
fullPatternJobFolderPath);
|
||||
//#ifdef POLYSCOPE_DEFINED
|
||||
// std::array<double, 3> resultsColor({28.0, 99.0, 227.0});
|
||||
// simulationResults_tiledFullPattern_drm.registerForDrawing(resultsColor);
|
||||
// std::ifstream ifs("CameraSettings.json");
|
||||
// nlohmann::json json;
|
||||
// ifs >> json;
|
||||
// polyscope::view::setCameraFromJson(json.dump(), false);
|
||||
// // polyscope::show();
|
||||
// const std::string cameraJson = polyscope::view::getCameraJson();
|
||||
// std::filesystem::path jsonFilePath("CameraSettings.json");
|
||||
// std::ofstream jsonFile_cameraSettings(jsonFilePath.string());
|
||||
// jsonFile_cameraSettings << cameraJson;
|
||||
// jsonFile_cameraSettings.close();
|
||||
// std::filesystem::create_directories("screenshots");
|
||||
// const std::string screenshotOutputFilePath
|
||||
// = (std::filesystem::current_path()
|
||||
// .append("screenshots")
|
||||
// .append(optimizationResult.label + "_" + pJob_tiledFullPattern->getLabel()))
|
||||
// .string()
|
||||
// + ".png";
|
||||
// // std::cout << "Saving image to:" << screenshotOutputFilePath << std::endl;
|
||||
// polyscope::screenshot(screenshotOutputFilePath, false);
|
||||
// simulationResults_tiledFullPattern_drm.unregister();
|
||||
//#endif
|
||||
simulationResults_tiledFullPattern_drm.converged = true;
|
||||
} else {
|
||||
std::cout << "Drm results not found in:" << fullResultsFolderPath << std::endl;
|
||||
//Full
|
||||
std::cout << "Executing:" << jobLabel << std::endl;
|
||||
DRMSimulationModel drmSimulationModel;
|
||||
simulationResults_tiledFullPattern_drm
|
||||
= drmSimulationModel.executeSimulation(pJob_tiledFullPattern,
|
||||
drmSimulationSettings);
|
||||
simulationResults_tiledFullPattern_drm.setLabelPrefix("DRM");
|
||||
}
|
||||
if (!simulationResults_tiledFullPattern_drm.converged) {
|
||||
std::cerr << "Full pattern simulation failed." << std::endl;
|
||||
std::cerr << "Not saving results" << std::endl;
|
||||
// continue;
|
||||
return;
|
||||
}
|
||||
std::filesystem::create_directories(fullResultsFolderPath);
|
||||
const std::filesystem::path drmResultsOutputPath
|
||||
= std::filesystem::path(scenarioDirectoryPath).append(patternLabel);
|
||||
simulationResults_tiledFullPattern_drm.save(drmResultsOutputPath);
|
||||
|
||||
simulationResults_tiledFullPattern_drm.converged = true;
|
||||
} else {
|
||||
std::cout << "Drm results not found in:" << fullResultsFolderPath << std::endl;
|
||||
//Full
|
||||
std::cout << "Executing:" << jobLabel << std::endl;
|
||||
DRMSimulationModel drmSimulationModel;
|
||||
simulationResults_tiledFullPattern_drm
|
||||
= drmSimulationModel.executeSimulation(pJob_tiledFullPattern, drmSimulationSettings);
|
||||
simulationResults_tiledFullPattern_drm.setLabelPrefix("DRM");
|
||||
}
|
||||
std::filesystem::create_directories(fullResultsFolderPath);
|
||||
const std::filesystem::path drmResultsOutputPath
|
||||
= std::filesystem::path(scenarioDirectoryPath).append(patternLabel);
|
||||
simulationResults_tiledFullPattern_drm.save(drmResultsOutputPath);
|
||||
if (!simulationResults_tiledFullPattern_drm.converged) {
|
||||
std::cerr << "Full pattern simulation failed." << std::endl;
|
||||
std::cerr << "Saved failed simulation to:" << drmResultsOutputPath << std::endl;
|
||||
continue;
|
||||
}
|
||||
LinearSimulationModel linearSimulationModel;
|
||||
SimulationResults simulationResults_tiledReducedPattern
|
||||
= linearSimulationModel.executeSimulation(pJob_tiledReducedPattern);
|
||||
|
||||
LinearSimulationModel linearSimulationModel;
|
||||
SimulationResults simulationResults_tiledReducedPattern
|
||||
= linearSimulationModel.executeSimulation(pJob_tiledReducedPattern);
|
||||
// simulationResults_tiledReducedPattern.registerForDrawing();
|
||||
// simulationResults_tiledFullPattern_drm.registerForDrawing();
|
||||
// polyscope::show();
|
||||
|
||||
// simulationResults_tiledReducedPattern.registerForDrawing();
|
||||
// simulationResults_tiledFullPattern_drm.registerForDrawing();
|
||||
// polyscope::show();
|
||||
//measure distance
|
||||
const double distance_fullDrmToReduced
|
||||
= simulationResults_tiledFullPattern_drm
|
||||
.computeDistance(simulationResults_tiledReducedPattern, fullToReducedViMap);
|
||||
double distance_fullSumOfAllVerts = 0;
|
||||
for (std::pair<size_t, size_t> fullToReducedPair : fullToReducedViMap) {
|
||||
distance_fullSumOfAllVerts += simulationResults_tiledFullPattern_drm
|
||||
.displacements[fullToReducedPair.first]
|
||||
.getTranslation()
|
||||
.norm();
|
||||
}
|
||||
const double distance_normalizedFullDrmToReduced = distance_fullDrmToReduced
|
||||
/ distance_fullSumOfAllVerts;
|
||||
evaluationResults.distances_drm2reduced[jobIndex] = distance_fullDrmToReduced;
|
||||
evaluationResults.distances_normalizedDrm2reduced[jobIndex]
|
||||
= distance_normalizedFullDrmToReduced;
|
||||
}
|
||||
//compute the full2reduced distance
|
||||
const double distance_fullDrmToReduced
|
||||
= simulationResults_tiledFullPattern_drm
|
||||
.computeDistance(simulationResults_tiledReducedPattern, fullToReducedViMap);
|
||||
double distance_fullSumOfAllVerts = 0;
|
||||
for (std::pair<size_t, size_t> fullToReducedPair : fullToReducedViMap) {
|
||||
distance_fullSumOfAllVerts += simulationResults_tiledFullPattern_drm
|
||||
.displacements[fullToReducedPair.first]
|
||||
.getTranslation()
|
||||
.norm();
|
||||
}
|
||||
const double distance_normalizedFullDrmToReduced = distance_fullDrmToReduced
|
||||
/ distance_fullSumOfAllVerts;
|
||||
const int jobIndex = &jobLabel - &scenariosTestSetLabels[0];
|
||||
evaluationResults.distances_drm2reduced[jobIndex] = distance_fullDrmToReduced;
|
||||
evaluationResults.distances_normalizedDrm2reduced[jobIndex]
|
||||
= distance_normalizedFullDrmToReduced;
|
||||
});
|
||||
|
||||
return evaluationResults;
|
||||
}
|
||||
|
|
|
@ -31,13 +31,12 @@ public:
|
|||
std::array<std::string, NumberOfEvaluationScenarios> evaluationScenarioLabels;
|
||||
};
|
||||
ReducedModelEvaluator();
|
||||
static Results evaluateReducedModel(
|
||||
Results evaluateReducedModel(
|
||||
ReducedModelOptimization::Results &optimizationResult,
|
||||
const std::filesystem::path &tileInto_triMesh_filePath,
|
||||
const std::filesystem::path &scenariosDirectoryPath,
|
||||
// const std::filesystem::path &reducedPatternFilePath,
|
||||
const std::filesystem::path &fullPatternTessellatedResultsDirectoryPath);
|
||||
static Results evaluateReducedModel(ReducedModelOptimization::Results &optimizationResult);
|
||||
Results evaluateReducedModel(ReducedModelOptimization::Results &optimizationResult);
|
||||
static void printResultsVertically(const ReducedModelEvaluator::Results &evaluationResults,
|
||||
csvFile &csvOutput);
|
||||
static void printResults(const ReducedModelEvaluator::Results &evaluationResults,
|
||||
|
@ -93,6 +92,126 @@ public:
|
|||
const Settings &settings,
|
||||
csvFile &csvOutput);
|
||||
static void printHeader(const Settings &settings, csvFile &csvOutput);
|
||||
// static double evaluateOptimizationSettings(
|
||||
// const ReducedModelOptimization::Settings &optimizationSettings,
|
||||
// const std::vector<std::shared_ptr<PatternGeometry>> &pPatterns,
|
||||
// std::vector<ReducedModelEvaluator::Results> &patternEvaluationResults);
|
||||
std::shared_ptr<VCGPolyMesh> pTileIntoSurface;
|
||||
inline static constexpr char *tileIntoSurfaceFileContent = R"~(OFF
|
||||
46 66 0
|
||||
-0.0745923 0.03573945 0
|
||||
-0.07464622 0.02191801 0
|
||||
-0.06264956 0.02878203 0
|
||||
-0.08658896 0.02887542 0
|
||||
-0.06270347 0.01496059 0
|
||||
-0.06259564 0.04260346 0
|
||||
-0.08664289 0.01505398 0
|
||||
-0.08653505 0.04269686 0
|
||||
-0.0507068 0.02182462 0
|
||||
-0.07453838 0.04956088 0
|
||||
-0.05065288 0.03564605 0
|
||||
-0.09858564 0.02201139 0
|
||||
-0.09853172 0.03583283 0
|
||||
-0.06254172 0.0564249 0
|
||||
-0.05059896 0.04946748 0
|
||||
-0.08648112 0.0565183 0
|
||||
-0.09847781 0.04965428 0
|
||||
-0.03871013 0.02868864 0
|
||||
-0.07448447 0.06338232 0
|
||||
-0.03865621 0.04251007 0
|
||||
-0.1105284 0.02896881 0
|
||||
-0.1104745 0.04279025 0
|
||||
-0.03876406 0.0148672 0
|
||||
-0.05054504 0.06328891 0
|
||||
-0.0624878 0.07024634 0
|
||||
-0.03860229 0.0563315 0
|
||||
-0.1105823 0.01514738 0
|
||||
-0.08642721 0.07033974 0
|
||||
-0.09842389 0.06347572 0
|
||||
-0.1104206 0.05661169 0
|
||||
-0.07443054 0.07720376 0
|
||||
-0.05049112 0.07711035 0
|
||||
-0.03854837 0.07015293 0
|
||||
-0.06243387 0.08406778 0
|
||||
-0.08637329 0.08416118 0
|
||||
-0.09836997 0.07729716 0
|
||||
-0.1103666 0.07043312 0
|
||||
-0.07437663 0.09102518 0
|
||||
-0.03849445 0.08397438 0
|
||||
-0.0504372 0.0909318 0
|
||||
-0.06237995 0.09788923 0
|
||||
-0.08631937 0.09798261 0
|
||||
-0.09831604 0.09111859 0
|
||||
-0.1103127 0.08425456 0
|
||||
-0.03844052 0.09779582 0
|
||||
-0.1102588 0.09807601 0
|
||||
3 0 1 2
|
||||
3 3 1 0
|
||||
3 4 2 1
|
||||
3 5 0 2
|
||||
3 3 6 1
|
||||
3 3 0 7
|
||||
3 8 2 4
|
||||
3 5 9 0
|
||||
3 10 5 2
|
||||
3 3 11 6
|
||||
3 7 0 9
|
||||
3 12 3 7
|
||||
3 10 2 8
|
||||
3 5 13 9
|
||||
3 10 14 5
|
||||
3 12 11 3
|
||||
3 7 9 15
|
||||
3 12 7 16
|
||||
3 10 8 17
|
||||
3 14 13 5
|
||||
3 18 9 13
|
||||
3 19 14 10
|
||||
3 12 20 11
|
||||
3 18 15 9
|
||||
3 16 7 15
|
||||
3 21 12 16
|
||||
3 22 17 8
|
||||
3 19 10 17
|
||||
3 23 13 14
|
||||
3 18 13 24
|
||||
3 19 25 14
|
||||
3 21 20 12
|
||||
3 26 11 20
|
||||
3 18 27 15
|
||||
3 16 15 28
|
||||
3 21 16 29
|
||||
3 23 24 13
|
||||
3 23 14 25
|
||||
3 30 18 24
|
||||
3 30 27 18
|
||||
3 15 27 28
|
||||
3 29 16 28
|
||||
3 23 31 24
|
||||
3 23 25 32
|
||||
3 30 24 33
|
||||
3 30 34 27
|
||||
3 35 28 27
|
||||
3 29 28 36
|
||||
3 23 32 31
|
||||
3 24 31 33
|
||||
3 30 33 37
|
||||
3 30 37 34
|
||||
3 35 27 34
|
||||
3 35 36 28
|
||||
3 32 38 31
|
||||
3 33 31 39
|
||||
3 40 37 33
|
||||
3 34 37 41
|
||||
3 35 34 42
|
||||
3 35 43 36
|
||||
3 38 39 31
|
||||
3 40 33 39
|
||||
3 34 41 42
|
||||
3 35 42 43
|
||||
3 44 39 38
|
||||
3 45 43 42
|
||||
)~";
|
||||
};
|
||||
|
||||
#endif // REDUCEDMODELEVALUATOR_HPP
|
||||
|
|
Loading…
Reference in New Issue