From 0a0a1ad547b7be29c15f69ee5c4261e2ae457430 Mon Sep 17 00:00:00 2001 From: John Dupuy Date: Thu, 28 Sep 2023 13:30:50 -0500 Subject: [PATCH] fixes str.find bug and cmake files --- CMakeLists.txt | 12 +++++------- MbDCode/CMakeLists.txt | 8 +------- MbDCode/CREATE.h | 6 +++--- MbDCode/MbDCode.cpp | 10 +++++----- MbDCode/PosICNewtonRaphson.cpp | 4 ++-- MbDCode/SystemNewtonRaphson.cpp | 4 ++-- MbDCode/VelSolver.cpp | 4 ++-- 7 files changed, 20 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cec7723..74cf91f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,7 @@ -cmake_minimum_required(VERSION 3.10) - -project(MbDCodeLib) - -add_executable(MbDCode MbDCode/MbDCode.cpp) -add_subdirectory(MbDCode) - +cmake_minimum_required(VERSION 3.26) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) + +# add_library(some_target main.cpp) +add_executable(ondsel-solver MbDCode/MbDCode.cpp) +add_subdirectory(MbDCode) diff --git a/MbDCode/CMakeLists.txt b/MbDCode/CMakeLists.txt index c6bb15f..85c099a 100644 --- a/MbDCode/CMakeLists.txt +++ b/MbDCode/CMakeLists.txt @@ -1,8 +1,4 @@ -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -add_executable(new_target - MbDCode.cpp +target_sources(ondsel-solver PUBLIC Abs.cpp AbsConstraint.cpp AccICKineNewtonRaphson.cpp @@ -270,5 +266,3 @@ add_executable(new_target ZTranslation.cpp ASMTAssembly.cpp ) - - diff --git a/MbDCode/CREATE.h b/MbDCode/CREATE.h index 6d49f98..67bdf9a 100644 --- a/MbDCode/CREATE.h +++ b/MbDCode/CREATE.h @@ -71,7 +71,7 @@ namespace MbD { static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axis) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axis)).name(); - if (str.find("AtPointConstraintIJ") >= 0) { + if (str.find("AtPointConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axis); } @@ -79,7 +79,7 @@ namespace MbD { inst = std::make_shared(frmi, frmj, axis); } } // "class MbD::Tran - else if(str.find("TranslationConstraintIJ") >= 0) { + else if(str.find("TranslationConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axis); } @@ -98,7 +98,7 @@ namespace MbD { static std::shared_ptr ConstraintWith(std::shared_ptr frmi, std::shared_ptr frmj, int axisi, int axisj) { std::shared_ptr inst; std::string str = typeid(T(frmi, frmj, axisi, axisj)).name(); - if (str.find("DirectionCosineConstraintIJ") >= 0) { + if (str.find("DirectionCosineConstraintIJ") != std::string::npos) { if (std::dynamic_pointer_cast(frmi)) { inst = std::make_shared(frmi, frmj, axisi, axisj); } diff --git a/MbDCode/MbDCode.cpp b/MbDCode/MbDCode.cpp index 1564d30..27d0df2 100644 --- a/MbDCode/MbDCode.cpp +++ b/MbDCode/MbDCode.cpp @@ -35,11 +35,11 @@ int main() //ASMTAssembly::runFile("fourbot.asmt"); //ASMTAssembly::runFile("wobpump.asmt"); -// auto cadSystem = std::make_shared(); -// cadSystem->runOndselDoublePendulum(); - ////cadSystem->runOndselPiston(); - //cadSystem->runPiston(); - //runSpMat(); + auto cadSystem = std::make_shared(); + cadSystem->runOndselDoublePendulum(); + cadSystem->runOndselPiston(); + cadSystem->runPiston(); + runSpMat(); } void runSpMat() { diff --git a/MbDCode/PosICNewtonRaphson.cpp b/MbDCode/PosICNewtonRaphson.cpp index f8b86f6..b894656 100644 --- a/MbDCode/PosICNewtonRaphson.cpp +++ b/MbDCode/PosICNewtonRaphson.cpp @@ -103,13 +103,13 @@ void PosICNewtonRaphson::handleSingularMatrix() } else { std::string str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvMarkoFast") >= 0) { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvPrecise") >= 0) { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { this->lookForRedundantConstraints(); matrixSolver = this->matrixSolverClassNew(); } diff --git a/MbDCode/SystemNewtonRaphson.cpp b/MbDCode/SystemNewtonRaphson.cpp index b05aa63..d569297 100644 --- a/MbDCode/SystemNewtonRaphson.cpp +++ b/MbDCode/SystemNewtonRaphson.cpp @@ -52,13 +52,13 @@ void SystemNewtonRaphson::basicSolveEquations() void SystemNewtonRaphson::handleSingularMatrix() { std::string str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvMarkoFast") >= 0) { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvPrecise") >= 0) { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { str = "MbD: Singular Matrix Error. "; system->logString(str); matrixSolver = this->matrixSolverClassNew(); diff --git a/MbDCode/VelSolver.cpp b/MbDCode/VelSolver.cpp index d22fe6c..e85d4db 100644 --- a/MbDCode/VelSolver.cpp +++ b/MbDCode/VelSolver.cpp @@ -25,13 +25,13 @@ void VelSolver::basicSolveEquations() void VelSolver::handleSingularMatrix() { std::string str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvMarkoFast") >= 0) { + if (str.find("GESpMatParPvMarkoFast") != std::string::npos) { matrixSolver = CREATE::With(); this->solveEquations(); } else { str = typeid(*matrixSolver).name(); - if (str.find("GESpMatParPvPrecise") >= 0) { + if (str.find("GESpMatParPvPrecise") != std::string::npos) { this->logSingularMatrixMessage(); matrixSolver = this->matrixSolverClassNew(); }