From ae636c3af50388a0faa000f959569b763371b4d9 Mon Sep 17 00:00:00 2001 From: Iason Date: Tue, 2 Mar 2021 20:32:43 +0200 Subject: [PATCH] Testing the new axial and shear scenarios --- CMakeLists.txt | 20 +++---- src/main.cpp | 4 +- src/reducedmodeloptimizer.cpp | 98 +++++++++++++++++------------------ 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9467c15..9562afd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,14 +38,14 @@ download_project(PROJ MYSOURCES endif() ##Polyscope -#download_project(PROJ POLYSCOPE -# GIT_REPOSITORY https://github.com/nmwsharp/polyscope.git -# GIT_TAG master -# PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/build/external/ -# ${UPDATE_DISCONNECTED_IF_AVAILABLE} -#) -#add_subdirectory(${POLYSCOPE_SOURCE_DIR}) -#add_compile_definitions(POLYSCOPE_DEFINED) +download_project(PROJ POLYSCOPE + GIT_REPOSITORY https://github.com/nmwsharp/polyscope.git + GIT_TAG master + PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/build/external/ + ${UPDATE_DISCONNECTED_IF_AVAILABLE} +) +add_subdirectory(${POLYSCOPE_SOURCE_DIR}) +add_compile_definitions(POLYSCOPE_DEFINED) #dlib download_project(PROJ DLIB @@ -88,5 +88,5 @@ target_include_directories(${PROJECT_NAME} ) link_directories(${MYSOURCES_SOURCE_DIR}/boost_graph/libs) -#target_link_libraries(${PROJECT_NAME} polyscope Eigen3::Eigen matplot dlib::dlib) -target_link_libraries(${PROJECT_NAME} -static Eigen3::Eigen matplot dlib::dlib) +target_link_libraries(${PROJECT_NAME} polyscope Eigen3::Eigen matplot dlib::dlib) +#target_link_libraries(${PROJECT_NAME} -static Eigen3::Eigen matplot dlib::dlib) diff --git a/src/main.cpp b/src/main.cpp index 63bcf7e..068ac64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,8 +52,8 @@ int main(int argc, char *argv[]) { settings_optimization.numberOfFunctionCalls = input_numberOfFunctionCallsDefined ? std::atoi(argv[3]) : 100; settings_optimization.normalizationStrategy = - ReducedModelOptimizer::Settings::NormalizationStrategy::Epsilon; - settings_optimization.normalizationParameter = 0.003; + ReducedModelOptimizer::Settings::NormalizationStrategy::NonNormalized; + settings_optimization.normalizationParameter = 0.0003; settings_optimization.solutionAccuracy = 0.01; // Optimize pair diff --git a/src/reducedmodeloptimizer.cpp b/src/reducedmodeloptimizer.cpp index 4163932..4bb697e 100644 --- a/src/reducedmodeloptimizer.cpp +++ b/src/reducedmodeloptimizer.cpp @@ -784,31 +784,31 @@ ReducedModelOptimizer::createScenarios( //// Axial SimulationScenario scenarioName = SimulationScenario::Axial; // NewMethod - // for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin(); - // viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) { - // if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) { - // CoordType forceDirection(1, 0, 0); - // const auto viPair = *viPairIt; - // nodalForces[viPair.first] = - // Vector6d({forceDirection[0], forceDirection[1], forceDirection[2], - // 0, - // 0, 0}) * - // forceMagnitude * 10; - // fixedVertices[viPair.second] = - // std::unordered_set{0, 1, 2, 3, 4, 5}; - // } - // } - // OldMethod - for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) { - CoordType forceDirection = - (pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP()) - .Normalize(); - nodalForces[viPair.first] = Vector6d({forceDirection[0], forceDirection[1], - forceDirection[2], 0, 0, 0}) * - forceMagnitude * 10; - fixedVertices[viPair.second] = - std::unordered_set{0, 1, 2, 3, 4, 5}; + for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin(); + viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) { + if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) { + CoordType forceDirection(1, 0, 0); + const auto viPair = *viPairIt; + nodalForces[viPair.first] = + Vector6d({forceDirection[0], forceDirection[1], forceDirection[2], 0, + 0, 0}) * + forceMagnitude * 10; + fixedVertices[viPair.second] = + std::unordered_set{0, 1, 2, 3, 4, 5}; + } } + // OldMethod + // for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) { + // CoordType forceDirection = + // (pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP()) + // .Normalize(); + // nodalForces[viPair.first] = Vector6d({forceDirection[0], + // forceDirection[1], + // forceDirection[2], 0, 0, 0}) * + // forceMagnitude * 10; + // fixedVertices[viPair.second] = + // std::unordered_set{0, 1, 2, 3, 4, 5}; + // } scenarios[scenarioName] = std::make_shared( SimulationJob(pMesh, simulationScenarioStrings[scenarioName], fixedVertices, nodalForces, {})); @@ -818,32 +818,32 @@ ReducedModelOptimizer::createScenarios( fixedVertices.clear(); nodalForces.clear(); // NewMethod - // for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin(); - // viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) { - // if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) { - // CoordType forceDirection(0, 1, 0); - // const auto viPair = *viPairIt; - // nodalForces[viPair.first] = - // Vector6d({forceDirection[0], forceDirection[1], forceDirection[2], - // 0, - // 0, 0}) * - // forceMagnitude * 10; - // fixedVertices[viPair.second] = - // std::unordered_set{0, 1, 2, 3, 4, 5}; - // } - // } - // OldMethod - for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) { - CoordType v = - (pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP()) - .Normalize(); - CoordType forceDirection = (v ^ patternPlaneNormal).Normalize(); - nodalForces[viPair.first] = Vector6d({forceDirection[0], forceDirection[1], - forceDirection[2], 0, 0, 0}) * - 0.40 * forceMagnitude; - fixedVertices[viPair.second] = - std::unordered_set{0, 1, 2, 3, 4, 5}; + for (auto viPairIt = m_fullPatternOppositeInterfaceViMap.begin(); + viPairIt != m_fullPatternOppositeInterfaceViMap.end(); viPairIt++) { + if (viPairIt != m_fullPatternOppositeInterfaceViMap.begin()) { + CoordType forceDirection(0, 1, 0); + const auto viPair = *viPairIt; + nodalForces[viPair.first] = + Vector6d({forceDirection[0], forceDirection[1], forceDirection[2], 0, + 0, 0}) * + forceMagnitude * 10; + fixedVertices[viPair.second] = + std::unordered_set{0, 1, 2, 3, 4, 5}; + } } + // OldMethod + // for (const auto &viPair : m_fullPatternOppositeInterfaceViMap) { + // CoordType v = + // (pMesh->vert[viPair.first].cP() - pMesh->vert[viPair.second].cP()) + // .Normalize(); + // CoordType forceDirection = (v ^ patternPlaneNormal).Normalize(); + // nodalForces[viPair.first] = Vector6d({forceDirection[0], + // forceDirection[1], + // forceDirection[2], 0, 0, 0}) * + // 0.40 * forceMagnitude; + // fixedVertices[viPair.second] = + // std::unordered_set{0, 1, 2, 3, 4, 5}; + // } scenarios[scenarioName] = std::make_shared( SimulationJob(pMesh, simulationScenarioStrings[scenarioName], fixedVertices, nodalForces, {}));