From 02870d97c9988ec81bdab8a5df177b2fd2c35d93 Mon Sep 17 00:00:00 2001 From: Aik-Siong Koh Date: Mon, 15 Jul 2024 12:48:08 -0600 Subject: [PATCH] Gtest added --- CMakeLists.txt | 3 +- OndselSolver/ASMTAllowRotation.cpp | 2 +- OndselSolver/ASMTAllowRotation.h | 2 +- OndselSolver/ASMTAssembly.cpp | 28 ++-- OndselSolver/ASMTAssembly.h | 28 ++-- OndselSolver/ASMTItem.cpp | 27 ++- OndselSolver/ASMTItem.h | 23 ++- OndselSolver/ASMTItemIJ.cpp | 4 +- OndselSolver/ASMTItemIJ.h | 4 +- OndselSolver/ASMTLimit.cpp | 8 +- OndselSolver/ASMTLimit.h | 8 +- OndselSolver/ASMTRefPoint.cpp | 2 +- OndselSolver/ASMTRefPoint.h | 2 +- OndselSolver/ASMTRotationalMotion.cpp | 4 +- OndselSolver/ASMTRotationalMotion.h | 4 +- OndselSolver/ASMTTime.cpp | 2 +- OndselSolver/AbsConstraint.cpp | 2 +- OndselSolver/AbsConstraint.h | 2 +- OndselSolver/AllowZRotation.cpp | 2 +- OndselSolver/AllowZRotation.h | 2 +- OndselSolver/AngleJoint.cpp | 2 +- OndselSolver/AngleJoint.h | 2 +- OndselSolver/AtPointJoint.cpp | 2 +- OndselSolver/AtPointJoint.h | 2 +- OndselSolver/BasicIntegrator.cpp | 2 +- OndselSolver/BasicIntegrator.h | 2 +- OndselSolver/CADSystem.cpp | 4 +- OndselSolver/CADSystem.h | 2 +- OndselSolver/CMakeLists.txt | 2 +- OndselSolver/CREATE.h | 2 +- OndselSolver/CartesianFrame.cpp | 2 +- OndselSolver/CartesianFrame.h | 2 +- OndselSolver/CompoundJoint.cpp | 2 +- OndselSolver/CompoundJoint.h | 2 +- OndselSolver/ConstantVelocityJoint.cpp | 2 +- OndselSolver/ConstantVelocityJoint.h | 2 +- OndselSolver/Constraint.cpp | 2 +- OndselSolver/Constraint.h | 2 +- OndselSolver/ConstraintSet.cpp | 2 +- OndselSolver/ConstraintSet.h | 2 +- OndselSolver/CylSphJoint.cpp | 2 +- OndselSolver/CylSphJoint.h | 2 +- OndselSolver/CylindricalJoint.cpp | 2 +- OndselSolver/CylindricalJoint.h | 2 +- OndselSolver/EndFramec.cpp | 2 +- OndselSolver/EndFramec.h | 2 +- OndselSolver/EndFrameqc.cpp | 2 +- OndselSolver/EndFrameqc.h | 2 +- OndselSolver/EndFrameqct.cpp | 4 +- OndselSolver/EndFrameqct.h | 2 +- OndselSolver/EndFrameqct2.cpp | 4 +- OndselSolver/EndFrameqct2.h | 2 +- OndselSolver/EulerConstraint.cpp | 2 +- OndselSolver/EulerConstraint.h | 2 +- OndselSolver/ExternalSystem.cpp | 2 +- OndselSolver/ExternalSystem.h | 2 +- OndselSolver/FixedJoint.cpp | 2 +- OndselSolver/FixedJoint.h | 2 +- OndselSolver/FullMotion.cpp | 2 +- OndselSolver/FullMotion.h | 2 +- OndselSolver/FunctionX.cpp | 5 +- OndselSolver/GESpMatParPvPrecise.cpp | 20 +++ OndselSolver/GESpMatParPvPrecise.h | 1 + OndselSolver/GearJoint.cpp | 2 +- OndselSolver/GearJoint.h | 2 +- OndselSolver/ICKineIntegrator.cpp | 2 +- OndselSolver/InLineJoint.cpp | 2 +- OndselSolver/InLineJoint.h | 2 +- OndselSolver/InPlaneJoint.cpp | 2 +- OndselSolver/InPlaneJoint.h | 2 +- OndselSolver/IntegratorInterface.cpp | 2 +- OndselSolver/IntegratorInterface.h | 2 +- OndselSolver/Item.cpp | 19 +-- OndselSolver/Item.h | 10 +- OndselSolver/ItemIJ.cpp | 2 +- OndselSolver/ItemIJ.h | 2 +- OndselSolver/Joint.cpp | 2 +- OndselSolver/Joint.h | 2 +- OndselSolver/KineIntegrator.cpp | 2 +- OndselSolver/LineInPlaneJoint.cpp | 2 +- OndselSolver/LineInPlaneJoint.h | 2 +- OndselSolver/MarkerFrame.cpp | 2 +- OndselSolver/MarkerFrame.h | 2 +- OndselSolver/MatrixSolver.cpp | 4 +- OndselSolver/MatrixSolver.h | 4 +- OndselSolver/NoRotationJoint.cpp | 2 +- OndselSolver/NoRotationJoint.h | 2 +- OndselSolver/Orientation.cpp | 2 +- OndselSolver/Orientation.h | 2 +- OndselSolver/ParallelAxesJoint.cpp | 2 +- OndselSolver/ParallelAxesJoint.h | 2 +- OndselSolver/Part.cpp | 2 +- OndselSolver/Part.h | 2 +- OndselSolver/PartFrame.cpp | 4 +- OndselSolver/PartFrame.h | 4 +- OndselSolver/PerpendicularJoint.cpp | 2 +- OndselSolver/PerpendicularJoint.h | 2 +- OndselSolver/PlanarJoint.cpp | 2 +- OndselSolver/PlanarJoint.h | 2 +- OndselSolver/PointInLineJoint.cpp | 2 +- OndselSolver/PointInLineJoint.h | 2 +- OndselSolver/PointInPlaneJoint.cpp | 2 +- OndselSolver/PointInPlaneJoint.h | 2 +- OndselSolver/PosICKineNewtonRaphson.cpp | 2 +- OndselSolver/PrescribedMotion.cpp | 2 +- OndselSolver/PrescribedMotion.h | 2 +- OndselSolver/QuasiIntegrator.cpp | 4 +- OndselSolver/QuasiIntegrator.h | 2 +- OndselSolver/RackPinJoint.cpp | 2 +- OndselSolver/RackPinJoint.h | 2 +- OndselSolver/RevCylJoint.cpp | 2 +- OndselSolver/RevCylJoint.h | 2 +- OndselSolver/RevRevJoint.cpp | 2 +- OndselSolver/RevRevJoint.h | 2 +- OndselSolver/RevoluteJoint.cpp | 2 +- OndselSolver/RevoluteJoint.h | 2 +- OndselSolver/ScrewJoint.cpp | 2 +- OndselSolver/ScrewJoint.h | 2 +- OndselSolver/Solver.cpp | 8 +- OndselSolver/Solver.h | 3 +- OndselSolver/SparseMatrix.h | 3 +- OndselSolver/SphSphJoint.cpp | 2 +- OndselSolver/SphSphJoint.h | 2 +- OndselSolver/SphericalJoint.cpp | 2 +- OndselSolver/SphericalJoint.h | 2 +- OndselSolver/Sum.cpp | 2 +- OndselSolver/Sum.h | 2 +- OndselSolver/{Time.h => SymTime.h} | 0 OndselSolver/SymbolicParser.cpp | 12 +- OndselSolver/SymbolicParser.h | 12 +- OndselSolver/System.cpp | 6 +- OndselSolver/System.h | 4 +- OndselSolver/SystemSolver.cpp | 2 +- OndselSolver/SystemSolver.h | 2 +- OndselSolver/Time.cpp | 2 +- OndselSolver/Translation.cpp | 2 +- OndselSolver/Translation.h | 2 +- OndselSolver/TranslationalJoint.cpp | 2 +- OndselSolver/TranslationalJoint.h | 2 +- OndselSolver/UniversalJoint.cpp | 2 +- OndselSolver/UniversalJoint.h | 2 +- OndselSolver/Variable.cpp | 4 +- OndselSolver/Variable.h | 4 +- OndselSolver/VelKineSolver.cpp | 2 +- OndselSolver/ZRotation.cpp | 2 +- OndselSolver/ZRotation.h | 2 +- OndselSolver/ZTranslation.cpp | 2 +- OndselSolver/ZTranslation.h | 2 +- OndselSolverMain/OndselSolver.cpp | 65 +++----- ...aggingBackhoe.log => draggingBackhoe1.log} | 0 ...agBackhoe.asmt => runPreDragBackhoe1.asmt} | 0 tests/test.cpp | 157 +++++++++++++++++- 152 files changed, 430 insertions(+), 304 deletions(-) rename OndselSolver/{Time.h => SymTime.h} (100%) rename testapp/{draggingBackhoe.log => draggingBackhoe1.log} (100%) rename testapp/{runPreDragBackhoe.asmt => runPreDragBackhoe1.asmt} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 612713e..6059710 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,10 +15,11 @@ ELSE() set( ONDSELSOLVER_BUILD_SHARED OFF ) ENDIF () +add_compile_definitions(TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/testapp") add_subdirectory(OndselSolver) add_subdirectory(OndselSolverMain) include(CTest) enable_testing() add_subdirectory(tests) - +target_compile_definitions(test_run PUBLIC TEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/testapp") set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/OndselSolverMain PROPERTY VS_STARTUP_PROJECT OndselSolverMain) \ No newline at end of file diff --git a/OndselSolver/ASMTAllowRotation.cpp b/OndselSolver/ASMTAllowRotation.cpp index 643cf84..91556b5 100644 --- a/OndselSolver/ASMTAllowRotation.cpp +++ b/OndselSolver/ASMTAllowRotation.cpp @@ -55,7 +55,7 @@ std::shared_ptr MbD::ASMTAllowRotation::mbdClassNew() return AllowZRotation::With(); } -void MbD::ASMTAllowRotation::setMotionJoint(std::string motionJoint) +void MbD::ASMTAllowRotation::setMotionJoint(const std::string& motionJoint) { (void) motionJoint; } diff --git a/OndselSolver/ASMTAllowRotation.h b/OndselSolver/ASMTAllowRotation.h index 44885a8..b71a46b 100644 --- a/OndselSolver/ASMTAllowRotation.h +++ b/OndselSolver/ASMTAllowRotation.h @@ -20,7 +20,7 @@ namespace MbD { void readMotionJoint(std::vector& lines); void initMarkers() override; std::shared_ptr mbdClassNew() override; - void setMotionJoint(std::string motionJoint); + void setMotionJoint(const std::string& motionJoint); void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; diff --git a/OndselSolver/ASMTAssembly.cpp b/OndselSolver/ASMTAssembly.cpp index 0301ba9..f151b3b 100644 --- a/OndselSolver/ASMTAssembly.cpp +++ b/OndselSolver/ASMTAssembly.cpp @@ -355,7 +355,7 @@ void MbD::ASMTAssembly::runSinglePendulum() assembly->runKINEMATIC(); } -std::shared_ptr MbD::ASMTAssembly::assemblyFromFile(const char* fileName) +std::shared_ptr MbD::ASMTAssembly::assemblyFromFile(const std::string& fileName) { std::filesystem::path currentPath = std::filesystem::current_path(); std::cout << "Current directory: " << currentPath << std::endl; @@ -380,7 +380,7 @@ std::shared_ptr MbD::ASMTAssembly::assemblyFromFile(const char* fi return assembly; } -void MbD::ASMTAssembly::runFile(const char* fileName) +void MbD::ASMTAssembly::runFile(const std::string& fileName) { std::ifstream stream(fileName); if (stream.fail()) { @@ -538,7 +538,7 @@ void MbD::ASMTAssembly::runDraggingTest3() rotMat = rotPart->rotationMatrix; } -void MbD::ASMTAssembly::readWriteFile(const char* fileName) +void MbD::ASMTAssembly::readWriteFile(const std::string& fileName) { std::ifstream stream(fileName); if (stream.fail()) { @@ -575,7 +575,7 @@ ASMTAssembly* MbD::ASMTAssembly::root() return this; } -void MbD::ASMTAssembly::setNotes(std::string str) +void MbD::ASMTAssembly::setNotes(const std::string& str) { notes = str; } @@ -1044,7 +1044,7 @@ void MbD::ASMTAssembly::readMotionSeries(std::vector& lines) motion->readMotionSeries(lines); } -void MbD::ASMTAssembly::runDraggingLog(const char* fileName) +void MbD::ASMTAssembly::runDraggingLog(const std::string& fileName) { std::ifstream stream(fileName); if (stream.fail()) { @@ -1274,7 +1274,7 @@ void MbD::ASMTAssembly::createMbD(std::shared_ptr mbdSys, std::shared_pt // animationParameters = nullptr; } -void MbD::ASMTAssembly::outputFile(std::string filename) +void MbD::ASMTAssembly::outputFile(const std::string& filename) { std::ofstream os(filename); os << std::setprecision(std::numeric_limits::max_digits10); @@ -1462,7 +1462,7 @@ MbD::ASMTAssembly::spatialContainerAt(std::shared_ptr self, return part; } -std::shared_ptr MbD::ASMTAssembly::partAt(std::string& longname) const +std::shared_ptr MbD::ASMTAssembly::partAt(const std::string& longname) const { for (auto& part : *parts) { if (part->fullName("") == longname) { @@ -1472,7 +1472,7 @@ std::shared_ptr MbD::ASMTAssembly::partAt(std::string& longname) const return nullptr; } -std::shared_ptr MbD::ASMTAssembly::markerAt(std::string& longname) const +std::shared_ptr MbD::ASMTAssembly::markerAt(const std::string& longname) const { for (auto& refPoint : *refPoints) { for (auto& marker : *refPoint->markers) { @@ -1493,7 +1493,7 @@ std::shared_ptr MbD::ASMTAssembly::markerAt(std::string& longname) c return nullptr; } -std::shared_ptr MbD::ASMTAssembly::jointAt(std::string& longname) const +std::shared_ptr MbD::ASMTAssembly::jointAt(const std::string& longname) const { auto it = std::find_if(joints->begin(), joints->end(), [&](const std::shared_ptr& jt) { @@ -1503,7 +1503,7 @@ std::shared_ptr MbD::ASMTAssembly::jointAt(std::string& longname) con return joint; } -std::shared_ptr MbD::ASMTAssembly::motionAt(std::string& longname) const +std::shared_ptr MbD::ASMTAssembly::motionAt(const std::string& longname) const { auto it = std::find_if(motions->begin(), motions->end(), [&](const std::shared_ptr& mt) { @@ -1513,7 +1513,7 @@ std::shared_ptr MbD::ASMTAssembly::motionAt(std::string& longname) c return motion; } -std::shared_ptr MbD::ASMTAssembly::forceTorqueAt(std::string& longname) const +std::shared_ptr MbD::ASMTAssembly::forceTorqueAt(const std::string& longname) const { auto it = std::find_if(forcesTorques->begin(), forcesTorques->end(), @@ -1625,7 +1625,7 @@ void MbD::ASMTAssembly::setSimulationParameters( parameters->owner = this; } -std::shared_ptr MbD::ASMTAssembly::partNamed(std::string partName) const +std::shared_ptr MbD::ASMTAssembly::partNamed(const std::string& partName) const { auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr& prt) { return prt->fullName("") == partName; @@ -1634,7 +1634,7 @@ std::shared_ptr MbD::ASMTAssembly::partNamed(std::string partName) con return part; } -std::shared_ptr MbD::ASMTAssembly::partPartialNamed(std::string partialName) const +std::shared_ptr MbD::ASMTAssembly::partPartialNamed(const std::string& partialName) const { auto it = std::find_if(parts->begin(), parts->end(), [&](const std::shared_ptr& prt) { auto fullName = prt->fullName(""); @@ -1744,7 +1744,7 @@ void MbD::ASMTAssembly::storeOnTimeSeries(std::ofstream& os) } } -void MbD::ASMTAssembly::setFilename(std::string str) +void MbD::ASMTAssembly::setFilename(const std::string& str) { std::stringstream ss; ss << "FileName = " << str << std::endl; diff --git a/OndselSolver/ASMTAssembly.h b/OndselSolver/ASMTAssembly.h index d50172a..4179565 100644 --- a/OndselSolver/ASMTAssembly.h +++ b/OndselSolver/ASMTAssembly.h @@ -38,8 +38,8 @@ namespace MbD { static void runSinglePendulumSuperSimplified2(); static void runSinglePendulumSimplified(); static void runSinglePendulum(); - static std::shared_ptr assemblyFromFile(const char* chars); - static void runFile(const char* chars); + static std::shared_ptr assemblyFromFile(const std::string& fileName); + static void runFile(const std::string& chars); static void runDraggingLogTest(); static void runDraggingLogTest2(); static void runDraggingLogTest3(); @@ -47,10 +47,10 @@ namespace MbD { static void runDraggingTest2(); static void runDraggingTest3(); - static void readWriteFile(const char* chars); + static void readWriteFile(const std::string& chars); void initialize() override; ASMTAssembly* root() override; - void setNotes(std::string str); + void setNotes(const std::string& str); void parseASMT(std::vector& lines) override; void readNotes(std::vector& lines); void readParts(std::vector& lines); @@ -75,7 +75,7 @@ namespace MbD { void readJointSeries(std::vector& lines); void readMotionSeriesMany(std::vector& lines); void readMotionSeries(std::vector& lines); - void runDraggingLog(const char* chars); + void runDraggingLog(const std::string& chars); void outputFor(AnalysisType type); void preMbDrun(std::shared_ptr mbdSys); @@ -89,7 +89,7 @@ namespace MbD { std::shared_ptr>>markerMap() const; void deleteMbD() override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void outputFile(std::string filename); + void outputFile(const std::string& filename); void storeOnLevel(std::ofstream& os, size_t level) override; /* This function performs a one shot solve of the assembly.*/ @@ -102,11 +102,11 @@ namespace MbD { void runKINEMATIC(); void initprincipalMassMarker(); std::shared_ptr spatialContainerAt(std::shared_ptr self, std::string& longname) const; - std::shared_ptr partAt(std::string& longname) const; - std::shared_ptr markerAt(std::string& longname) const; - std::shared_ptr jointAt(std::string& longname) const; - std::shared_ptr motionAt(std::string& longname) const; - std::shared_ptr forceTorqueAt(std::string& longname) const; + std::shared_ptr partAt(const std::string& longname) const; + std::shared_ptr markerAt(const std::string& longname) const; + std::shared_ptr jointAt(const std::string& longname) const; + std::shared_ptr motionAt(const std::string& longname) const; + std::shared_ptr forceTorqueAt(const std::string& longname) const; FColDsptr vOcmO() override; FColDsptr omeOpO() override; std::shared_ptr geoTime() const; @@ -119,8 +119,8 @@ namespace MbD { void addLimit(std::shared_ptr limit); void setConstantGravity(std::shared_ptr constantGravity); void setSimulationParameters(std::shared_ptr simulationParameters); - std::shared_ptr partNamed(std::string partName) const; - std::shared_ptr partPartialNamed(std::string partialName) const; + std::shared_ptr partNamed(const std::string& partName) const; + std::shared_ptr partPartialNamed(const std::string& partialName) const; void storeOnLevelNotes(std::ofstream& os, size_t level); void storeOnLevelParts(std::ofstream& os, size_t level); void storeOnLevelKinematicIJs(std::ofstream& os, size_t level); @@ -131,7 +131,7 @@ namespace MbD { void storeOnLevelLimits(std::ofstream& os, size_t level); void storeOnLevelGeneralConstraintSets(std::ofstream& os, size_t level); void storeOnTimeSeries(std::ofstream& os) override; - void setFilename(std::string filename); + void setFilename(const std::string& filename); void setDebug(bool todebug); std::string filename = ""; diff --git a/OndselSolver/ASMTItem.cpp b/OndselSolver/ASMTItem.cpp index de44e93..ffcb754 100644 --- a/OndselSolver/ASMTItem.cpp +++ b/OndselSolver/ASMTItem.cpp @@ -46,7 +46,7 @@ std::string MbD::ASMTItem::classname() return answer; } -void MbD::ASMTItem::setName(std::string str) +void MbD::ASMTItem::setName(const std::string& str) { name = str; } @@ -72,7 +72,7 @@ std::string MbD::ASMTItem::readStringOffTop(std::vector& args) return str; } -FRowDsptr MbD::ASMTItem::readRowOfDoubles(std::string& line) +FRowDsptr MbD::ASMTItem::readRowOfDoubles(const std::string& line) { std::istringstream iss(line); auto readRowOfDoubles = std::make_shared>(); @@ -89,7 +89,7 @@ FRowDsptr MbD::ASMTItem::readRowOfDoublesOffTop(std::vector& lines) return readRowOfDoubles(str); } -FColDsptr MbD::ASMTItem::readColumnOfDoubles(std::string& line) +FColDsptr MbD::ASMTItem::readColumnOfDoubles(const std::string& line) { std::istringstream iss(line); auto readColumnOfDoubles = std::make_shared>(); @@ -106,7 +106,7 @@ FColDsptr MbD::ASMTItem::readColumnOfDoublesOffTop(std::vector& lin return readColumnOfDoubles(str); } -double MbD::ASMTItem::readDouble(std::string& line) +double MbD::ASMTItem::readDouble(const std::string& line) { std::istringstream iss(line); double d; @@ -114,7 +114,7 @@ double MbD::ASMTItem::readDouble(std::string& line) return d; } -int MbD::ASMTItem::readInt(std::string& line) +int MbD::ASMTItem::readInt(const std::string& line) { std::istringstream iss(line); int i; @@ -122,7 +122,7 @@ int MbD::ASMTItem::readInt(std::string& line) return i; } -size_t MbD::ASMTItem::readSize_t(std::string& line) +size_t MbD::ASMTItem::readSize_t(const std::string& line) { std::istringstream iss(line); size_t i; @@ -130,7 +130,7 @@ size_t MbD::ASMTItem::readSize_t(std::string& line) return i; } -bool MbD::ASMTItem::readBool(std::string& line) +bool MbD::ASMTItem::readBool(const std::string& line) { if (line.find("true") != std::string::npos) { @@ -146,7 +146,7 @@ bool MbD::ASMTItem::readBool(std::string& line) } } -std::string MbD::ASMTItem::readString(std::string& line) +std::string MbD::ASMTItem::readString(const std::string& line) { std::string str = line; str.erase(str.begin(), std::find_if(str.begin(), str.end(), [](unsigned char ch) { return !std::isspace(ch); })); @@ -161,7 +161,7 @@ void MbD::ASMTItem::readName(std::vector& lines) lines.erase(lines.begin()); } -std::string MbD::ASMTItem::fullName(std::string partialName) +std::string MbD::ASMTItem::fullName(const std::string& partialName) { std::string longerName = "/" + name + partialName; if (owner == nullptr) { @@ -172,7 +172,7 @@ std::string MbD::ASMTItem::fullName(std::string partialName) } } -void MbD::ASMTItem::readDoublesInto(std::string& str, std::string label, FRowDsptr& row) +void MbD::ASMTItem::readDoublesInto(std::string str, std::string label, FRowDsptr& row) { auto pos = str.find(label); assert(pos != std::string::npos); @@ -289,12 +289,7 @@ void MbD::ASMTItem::storeOnTimeSeries(std::ofstream&) assert(false); } -void MbD::ASMTItem::logString(std::string& str) +void MbD::ASMTItem::logString(const std::string& str) { std::cout << str << std::endl; } - -void MbD::ASMTItem::logString(const char* chars) -{ - std::cout << chars << std::endl; -} diff --git a/OndselSolver/ASMTItem.h b/OndselSolver/ASMTItem.h index 6ec2b20..b6551e5 100644 --- a/OndselSolver/ASMTItem.h +++ b/OndselSolver/ASMTItem.h @@ -28,22 +28,22 @@ namespace MbD { virtual void initialize(); void noop(); virtual std::string classname(); - void setName(std::string str); + void setName(const std::string& str); virtual void parseASMT(std::vector& lines); std::string popOffTop(std::vector& lines); std::string readStringOffTop(std::vector& lines); - FRowDsptr readRowOfDoubles(std::string& line); + FRowDsptr readRowOfDoubles(const std::string& line); FRowDsptr readRowOfDoublesOffTop(std::vector& lines); - FColDsptr readColumnOfDoubles(std::string& line); + FColDsptr readColumnOfDoubles(const std::string& line); FColDsptr readColumnOfDoublesOffTop(std::vector& lines); - double readDouble(std::string& line); - int readInt(std::string& line); - size_t readSize_t(std::string& line); - bool readBool(std::string& line); - std::string readString(std::string& line); + double readDouble(const std::string& line); + int readInt(const std::string& line); + size_t readSize_t(const std::string& line); + bool readBool(const std::string& line); + std::string readString(const std::string& line); void readName(std::vector& lines); - virtual std::string fullName(std::string partialName); - void readDoublesInto(std::string& str, std::string label, FRowDsptr& row); + virtual std::string fullName(const std::string& partialName); + void readDoublesInto(std::string str, std::string label, FRowDsptr& row); virtual void deleteMbD(); virtual void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits); virtual void updateFromMbD(); @@ -63,8 +63,7 @@ namespace MbD { virtual void storeOnLevelArray(std::ofstream& os, size_t level, std::vector array); virtual void storeOnLevelName(std::ofstream& os, size_t level); virtual void storeOnTimeSeries(std::ofstream& os); - void logString(std::string& str); - void logString(const char* chars); + void logString(const std::string& str); std::string name; ASMTItem* owner = nullptr; diff --git a/OndselSolver/ASMTItemIJ.cpp b/OndselSolver/ASMTItemIJ.cpp index 19ad421..89968d9 100644 --- a/OndselSolver/ASMTItemIJ.cpp +++ b/OndselSolver/ASMTItemIJ.cpp @@ -35,12 +35,12 @@ void MbD::ASMTItemIJ::initialize() tzs = std::make_shared>(); } -void MbD::ASMTItemIJ::setMarkerI(std::string mkrI) +void MbD::ASMTItemIJ::setMarkerI(const std::string& mkrI) { markerI = mkrI; } -void MbD::ASMTItemIJ::setMarkerJ(std::string mkrJ) +void MbD::ASMTItemIJ::setMarkerJ(const std::string& mkrJ) { markerJ = mkrJ; } diff --git a/OndselSolver/ASMTItemIJ.h b/OndselSolver/ASMTItemIJ.h index 065acef..5cdbcc4 100644 --- a/OndselSolver/ASMTItemIJ.h +++ b/OndselSolver/ASMTItemIJ.h @@ -17,8 +17,8 @@ namespace MbD { public: ASMTItemIJ(); void initialize() override; - void setMarkerI(std::string mkrI); - void setMarkerJ(std::string mkrJ); + void setMarkerI(const std::string& mkrI); + void setMarkerJ(const std::string& mkrJ); void readMarkerI(std::vector& lines); void readMarkerJ(std::vector& lines); void readFXonIs(std::vector& lines); diff --git a/OndselSolver/ASMTLimit.cpp b/OndselSolver/ASMTLimit.cpp index e8f6728..5952c92 100644 --- a/OndselSolver/ASMTLimit.cpp +++ b/OndselSolver/ASMTLimit.cpp @@ -95,22 +95,22 @@ void MbD::ASMTLimit::createMbD(std::shared_ptr mbdSys, std::shared_ptrtol = geotol->getValue(); } -void MbD::ASMTLimit::setmotionJoint(std::string _motionJoint) +void MbD::ASMTLimit::setmotionJoint(const std::string& _motionJoint) { motionJoint = _motionJoint; } -void MbD::ASMTLimit::settype(std::string _type) +void MbD::ASMTLimit::settype(const std::string& _type) { type = _type; } -void MbD::ASMTLimit::setlimit(std::string _limit) +void MbD::ASMTLimit::setlimit(const std::string& _limit) { limit = _limit; } -void MbD::ASMTLimit::settol(std::string _tol) +void MbD::ASMTLimit::settol(const std::string& _tol) { tol = _tol; } diff --git a/OndselSolver/ASMTLimit.h b/OndselSolver/ASMTLimit.h index 83bdcd4..d8f4df8 100644 --- a/OndselSolver/ASMTLimit.h +++ b/OndselSolver/ASMTLimit.h @@ -24,10 +24,10 @@ namespace MbD { void readTol(std::vector& lines); void parseASMT(std::vector& lines) override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; - void setmotionJoint(std::string _motionJoint); - void settype(std::string _type); - void setlimit(std::string _limit); - void settol(std::string _tol); + void setmotionJoint(const std::string& _motionJoint); + void settype(const std::string& _type); + void setlimit(const std::string& _limit); + void settol(const std::string& _tol); std::string motionJoint, type, limit, tol; diff --git a/OndselSolver/ASMTRefPoint.cpp b/OndselSolver/ASMTRefPoint.cpp index 3adc1c1..e86b853 100644 --- a/OndselSolver/ASMTRefPoint.cpp +++ b/OndselSolver/ASMTRefPoint.cpp @@ -19,7 +19,7 @@ void MbD::ASMTRefPoint::parseASMT(std::vector& lines) readMarkers(lines); } -std::string MbD::ASMTRefPoint::fullName(std::string partialName) +std::string MbD::ASMTRefPoint::fullName(const std::string& partialName) { return owner->fullName(partialName); } diff --git a/OndselSolver/ASMTRefPoint.h b/OndselSolver/ASMTRefPoint.h index 72eacaf..19e6c7c 100644 --- a/OndselSolver/ASMTRefPoint.h +++ b/OndselSolver/ASMTRefPoint.h @@ -18,7 +18,7 @@ namespace MbD { // public: void parseASMT(std::vector& lines) override; - std::string fullName(std::string partialName) override; + std::string fullName(const std::string& partialName) override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; void storeOnLevel(std::ofstream& os, size_t level) override; diff --git a/OndselSolver/ASMTRotationalMotion.cpp b/OndselSolver/ASMTRotationalMotion.cpp index 0b681e7..2d29a4b 100644 --- a/OndselSolver/ASMTRotationalMotion.cpp +++ b/OndselSolver/ASMTRotationalMotion.cpp @@ -89,12 +89,12 @@ std::shared_ptr MbD::ASMTRotationalMotion::mbdClassNew() return CREATE::With(); } -void MbD::ASMTRotationalMotion::setMotionJoint(std::string str) +void MbD::ASMTRotationalMotion::setMotionJoint(const std::string& str) { motionJoint = str; } -void MbD::ASMTRotationalMotion::setRotationZ(std::string rotZ) +void MbD::ASMTRotationalMotion::setRotationZ(const std::string& rotZ) { rotationZ = rotZ; } diff --git a/OndselSolver/ASMTRotationalMotion.h b/OndselSolver/ASMTRotationalMotion.h index f8019a9..08209af 100644 --- a/OndselSolver/ASMTRotationalMotion.h +++ b/OndselSolver/ASMTRotationalMotion.h @@ -23,8 +23,8 @@ namespace MbD { void initMarkers() override; void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; std::shared_ptr mbdClassNew() override; - void setMotionJoint(std::string motionJoint); - void setRotationZ(std::string rotZ); + void setMotionJoint(const std::string& motionJoint); + void setRotationZ(const std::string& rotZ); void storeOnLevel(std::ofstream& os, size_t level) override; void storeOnTimeSeries(std::ofstream& os) override; diff --git a/OndselSolver/ASMTTime.cpp b/OndselSolver/ASMTTime.cpp index aca06e7..ec01ebf 100644 --- a/OndselSolver/ASMTTime.cpp +++ b/OndselSolver/ASMTTime.cpp @@ -9,7 +9,7 @@ #include #include "ASMTTime.h" -#include "Time.h" +#include "SymTime.h" #include "Constant.h" #include "Product.h" diff --git a/OndselSolver/AbsConstraint.cpp b/OndselSolver/AbsConstraint.cpp index ca50d41..7eebc71 100644 --- a/OndselSolver/AbsConstraint.cpp +++ b/OndselSolver/AbsConstraint.cpp @@ -13,7 +13,7 @@ using namespace MbD; // //AbsConstraint::AbsConstraint() {} // -//AbsConstraint::AbsConstraint(const char* str) : Constraint(str) {} +//AbsConstraint::AbsConstraint(const std::string& str) : Constraint(str) {} AbsConstraint::AbsConstraint(size_t i) { diff --git a/OndselSolver/AbsConstraint.h b/OndselSolver/AbsConstraint.h index eed9beb..81a6549 100644 --- a/OndselSolver/AbsConstraint.h +++ b/OndselSolver/AbsConstraint.h @@ -15,7 +15,7 @@ namespace MbD { //axis iqXminusOnePlusAxis public: //AbsConstraint(); - //AbsConstraint(const char* str); + //AbsConstraint(const std::string& str); AbsConstraint(size_t axis); void calcPostDynCorrectorIteration() override; diff --git a/OndselSolver/AllowZRotation.cpp b/OndselSolver/AllowZRotation.cpp index 641fa43..a74d62c 100644 --- a/OndselSolver/AllowZRotation.cpp +++ b/OndselSolver/AllowZRotation.cpp @@ -22,7 +22,7 @@ MbD::AllowZRotation::AllowZRotation() //Do nothing. } -MbD::AllowZRotation::AllowZRotation(const char* str) : PrescribedMotion(str) +MbD::AllowZRotation::AllowZRotation(const std::string& str) : PrescribedMotion(str) { //Do nothing. } diff --git a/OndselSolver/AllowZRotation.h b/OndselSolver/AllowZRotation.h index b371234..8820ad1 100644 --- a/OndselSolver/AllowZRotation.h +++ b/OndselSolver/AllowZRotation.h @@ -16,7 +16,7 @@ namespace MbD { // public: AllowZRotation(); - AllowZRotation(const char* str); + AllowZRotation(const std::string& str); static std::shared_ptr With(); void initializeGlobally() override; void postPosIC() override; diff --git a/OndselSolver/AngleJoint.cpp b/OndselSolver/AngleJoint.cpp index 8387f57..c84161b 100644 --- a/OndselSolver/AngleJoint.cpp +++ b/OndselSolver/AngleJoint.cpp @@ -17,7 +17,7 @@ MbD::AngleJoint::AngleJoint() { } -MbD::AngleJoint::AngleJoint(const char* str) : Joint(str) +MbD::AngleJoint::AngleJoint(const std::string& str) : Joint(str) { } diff --git a/OndselSolver/AngleJoint.h b/OndselSolver/AngleJoint.h index 146713c..1828ea4 100644 --- a/OndselSolver/AngleJoint.h +++ b/OndselSolver/AngleJoint.h @@ -16,7 +16,7 @@ namespace MbD { //theIzJz public: AngleJoint(); - AngleJoint(const char* str); + AngleJoint(const std::string& str); void initializeGlobally() override; double theIzJz = 0.0; diff --git a/OndselSolver/AtPointJoint.cpp b/OndselSolver/AtPointJoint.cpp index 03205b8..5726695 100644 --- a/OndselSolver/AtPointJoint.cpp +++ b/OndselSolver/AtPointJoint.cpp @@ -16,7 +16,7 @@ MbD::AtPointJoint::AtPointJoint() { } -MbD::AtPointJoint::AtPointJoint(const char* str) : Joint(str) +MbD::AtPointJoint::AtPointJoint(const std::string& str) : Joint(str) { } diff --git a/OndselSolver/AtPointJoint.h b/OndselSolver/AtPointJoint.h index e27547e..8651ba2 100644 --- a/OndselSolver/AtPointJoint.h +++ b/OndselSolver/AtPointJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: AtPointJoint(); - AtPointJoint(const char* str); + AtPointJoint(const std::string& str); void createAtPointConstraints(); diff --git a/OndselSolver/BasicIntegrator.cpp b/OndselSolver/BasicIntegrator.cpp index a897732..5bbe0bc 100644 --- a/OndselSolver/BasicIntegrator.cpp +++ b/OndselSolver/BasicIntegrator.cpp @@ -88,7 +88,7 @@ void BasicIntegrator::initialize() opBDF->timeNodes = tpast; } -void BasicIntegrator::logString(std::string& str) +void BasicIntegrator::logString(const std::string& str) { system->logString(str); } diff --git a/OndselSolver/BasicIntegrator.h b/OndselSolver/BasicIntegrator.h index 88f2b3f..9a9aa2d 100644 --- a/OndselSolver/BasicIntegrator.h +++ b/OndselSolver/BasicIntegrator.h @@ -38,7 +38,7 @@ namespace MbD { void selectOrder() override; void subsequentSteps() override; void setSystem(Solver* sys) override; - void logString(std::string& str) override; + void logString(const std::string& str) override; virtual void setorder(size_t o); virtual void settnew(double t); diff --git a/OndselSolver/CADSystem.cpp b/OndselSolver/CADSystem.cpp index ce70dc8..22b3014 100644 --- a/OndselSolver/CADSystem.cpp +++ b/OndselSolver/CADSystem.cpp @@ -22,7 +22,7 @@ #include "Part.h" #include "MarkerFrame.h" #include "PartFrame.h" -#include "Time.h" +#include "SymTime.h" #include "StateData.h" #include "EulerParameters.h" @@ -40,7 +40,7 @@ void CADSystem::outputFor(AnalysisType) }); } -void CADSystem::logString(std::string& str) +void CADSystem::logString(const std::string& str) { std::cout << str << std::endl; } diff --git a/OndselSolver/CADSystem.h b/OndselSolver/CADSystem.h index 697467e..407c56d 100644 --- a/OndselSolver/CADSystem.h +++ b/OndselSolver/CADSystem.h @@ -25,7 +25,7 @@ namespace MbD { } void outputFor(AnalysisType type); - void logString(std::string& str); + void logString(const std::string& str); void logString(double value); void runOndselSinglePendulum(); void runOndselDoublePendulum(); diff --git a/OndselSolver/CMakeLists.txt b/OndselSolver/CMakeLists.txt index 9bbeea5..8e78a85 100644 --- a/OndselSolver/CMakeLists.txt +++ b/OndselSolver/CMakeLists.txt @@ -610,7 +610,7 @@ set(ONDSELSOLVER_HEADERS System.h SystemNewtonRaphson.h SystemSolver.h - Time.h + SymTime.h TooManyTriesError.h TooSmallStepSizeError.h Translation.h diff --git a/OndselSolver/CREATE.h b/OndselSolver/CREATE.h index 36b9ce3..22fe226 100644 --- a/OndselSolver/CREATE.h +++ b/OndselSolver/CREATE.h @@ -23,7 +23,7 @@ namespace MbD { template class CREATE { public: - static std::shared_ptr With(const char* name) { + static std::shared_ptr With(const std::string& name) { auto inst = std::make_shared(name); inst->initialize(); return inst; diff --git a/OndselSolver/CartesianFrame.cpp b/OndselSolver/CartesianFrame.cpp index 5762847..dda04e6 100644 --- a/OndselSolver/CartesianFrame.cpp +++ b/OndselSolver/CartesianFrame.cpp @@ -14,7 +14,7 @@ CartesianFrame::CartesianFrame() { } -CartesianFrame::CartesianFrame(const char* str) : Item(str) +CartesianFrame::CartesianFrame(const std::string& str) : Item(str) { } diff --git a/OndselSolver/CartesianFrame.h b/OndselSolver/CartesianFrame.h index d255d10..cedaa49 100644 --- a/OndselSolver/CartesianFrame.h +++ b/OndselSolver/CartesianFrame.h @@ -15,7 +15,7 @@ namespace MbD { { public: CartesianFrame(); - CartesianFrame(const char* str); + CartesianFrame(const std::string& str); void initialize() override; }; } diff --git a/OndselSolver/CompoundJoint.cpp b/OndselSolver/CompoundJoint.cpp index 4df7549..041a0ef 100644 --- a/OndselSolver/CompoundJoint.cpp +++ b/OndselSolver/CompoundJoint.cpp @@ -14,6 +14,6 @@ MbD::CompoundJoint::CompoundJoint() { } -MbD::CompoundJoint::CompoundJoint(const char* str) : Joint(str) +MbD::CompoundJoint::CompoundJoint(const std::string& str) : Joint(str) { } diff --git a/OndselSolver/CompoundJoint.h b/OndselSolver/CompoundJoint.h index 96e49bc..3dc988e 100644 --- a/OndselSolver/CompoundJoint.h +++ b/OndselSolver/CompoundJoint.h @@ -16,7 +16,7 @@ namespace MbD { //distanceIJ public: CompoundJoint(); - CompoundJoint(const char* str); + CompoundJoint(const std::string& str); double distanceIJ = 0.0; }; diff --git a/OndselSolver/ConstantVelocityJoint.cpp b/OndselSolver/ConstantVelocityJoint.cpp index 23363e8..3c2123e 100644 --- a/OndselSolver/ConstantVelocityJoint.cpp +++ b/OndselSolver/ConstantVelocityJoint.cpp @@ -18,7 +18,7 @@ MbD::ConstantVelocityJoint::ConstantVelocityJoint() { } -MbD::ConstantVelocityJoint::ConstantVelocityJoint(const char* str) : AtPointJoint(str) +MbD::ConstantVelocityJoint::ConstantVelocityJoint(const std::string& str) : AtPointJoint(str) { } // diff --git a/OndselSolver/ConstantVelocityJoint.h b/OndselSolver/ConstantVelocityJoint.h index fabe383..a2a1564 100644 --- a/OndselSolver/ConstantVelocityJoint.h +++ b/OndselSolver/ConstantVelocityJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: ConstantVelocityJoint(); - ConstantVelocityJoint(const char* str); + ConstantVelocityJoint(const std::string& str); //void initializeLocally() override; void initializeGlobally() override; void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override; diff --git a/OndselSolver/Constraint.cpp b/OndselSolver/Constraint.cpp index 9ce4d86..3b461be 100644 --- a/OndselSolver/Constraint.cpp +++ b/OndselSolver/Constraint.cpp @@ -20,7 +20,7 @@ Constraint::Constraint() : Item() aConstant = 0.0; } -Constraint::Constraint(const char* str) : Item(str) +Constraint::Constraint(const std::string& str) : Item(str) { } diff --git a/OndselSolver/Constraint.h b/OndselSolver/Constraint.h index 9365b0b..119b627 100644 --- a/OndselSolver/Constraint.h +++ b/OndselSolver/Constraint.h @@ -19,7 +19,7 @@ namespace MbD { //iG aG lam mu lamDeriv owner public: Constraint(); - Constraint(const char* str); + Constraint(const std::string& str); void initialize() override; virtual void addToJointForceI(FColDsptr col); diff --git a/OndselSolver/ConstraintSet.cpp b/OndselSolver/ConstraintSet.cpp index c9c6f10..5fad7dc 100644 --- a/OndselSolver/ConstraintSet.cpp +++ b/OndselSolver/ConstraintSet.cpp @@ -11,7 +11,7 @@ MbD::ConstraintSet::ConstraintSet() { } -MbD::ConstraintSet::ConstraintSet(const char* str) : ItemIJ(str) +MbD::ConstraintSet::ConstraintSet(const std::string& str) : ItemIJ(str) { } diff --git a/OndselSolver/ConstraintSet.h b/OndselSolver/ConstraintSet.h index 777ddf6..d75968d 100644 --- a/OndselSolver/ConstraintSet.h +++ b/OndselSolver/ConstraintSet.h @@ -18,7 +18,7 @@ namespace MbD { // public: ConstraintSet(); - ConstraintSet(const char* str); + ConstraintSet(const std::string& str); void constraintsDo(const std::function )>& f); void initialize() override; void initializeGlobally() override; diff --git a/OndselSolver/CylSphJoint.cpp b/OndselSolver/CylSphJoint.cpp index 389cc7d..d4a6b07 100644 --- a/OndselSolver/CylSphJoint.cpp +++ b/OndselSolver/CylSphJoint.cpp @@ -17,7 +17,7 @@ MbD::CylSphJoint::CylSphJoint() { } -MbD::CylSphJoint::CylSphJoint(const char* str) : CompoundJoint(str) +MbD::CylSphJoint::CylSphJoint(const std::string& str) : CompoundJoint(str) { } diff --git a/OndselSolver/CylSphJoint.h b/OndselSolver/CylSphJoint.h index 5c17675..4e9457e 100644 --- a/OndselSolver/CylSphJoint.h +++ b/OndselSolver/CylSphJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: CylSphJoint(); - CylSphJoint(const char* str); + CylSphJoint(const std::string& str); void initializeGlobally() override; diff --git a/OndselSolver/CylindricalJoint.cpp b/OndselSolver/CylindricalJoint.cpp index 8649524..b101bb8 100644 --- a/OndselSolver/CylindricalJoint.cpp +++ b/OndselSolver/CylindricalJoint.cpp @@ -18,7 +18,7 @@ CylindricalJoint::CylindricalJoint() { } -CylindricalJoint::CylindricalJoint(const char* str) : InLineJoint(str) +CylindricalJoint::CylindricalJoint(const std::string& str) : InLineJoint(str) { } diff --git a/OndselSolver/CylindricalJoint.h b/OndselSolver/CylindricalJoint.h index 6c234fb..4601599 100644 --- a/OndselSolver/CylindricalJoint.h +++ b/OndselSolver/CylindricalJoint.h @@ -16,7 +16,7 @@ namespace MbD { //frmI frmJ constraints friction public: CylindricalJoint(); - CylindricalJoint(const char* str); + CylindricalJoint(const std::string& str); void initializeGlobally() override; }; } diff --git a/OndselSolver/EndFramec.cpp b/OndselSolver/EndFramec.cpp index cde2b42..660fb9b 100644 --- a/OndselSolver/EndFramec.cpp +++ b/OndselSolver/EndFramec.cpp @@ -19,7 +19,7 @@ using namespace MbD; EndFramec::EndFramec() { } -EndFramec::EndFramec(const char* str) : CartesianFrame(str) { +EndFramec::EndFramec(const std::string& str) : CartesianFrame(str) { } FMatDsptr MbD::EndFramec::aAeO() diff --git a/OndselSolver/EndFramec.h b/OndselSolver/EndFramec.h index 740150a..f33a5dc 100644 --- a/OndselSolver/EndFramec.h +++ b/OndselSolver/EndFramec.h @@ -23,7 +23,7 @@ namespace MbD { //markerFrame rOeO aAOe public: EndFramec(); - EndFramec(const char* str); + EndFramec(const std::string& str); FMatDsptr aAeO(); System* root() override; diff --git a/OndselSolver/EndFrameqc.cpp b/OndselSolver/EndFrameqc.cpp index 27f79a8..a45f415 100644 --- a/OndselSolver/EndFrameqc.cpp +++ b/OndselSolver/EndFrameqc.cpp @@ -20,7 +20,7 @@ using namespace MbD; EndFrameqc::EndFrameqc() { } -EndFrameqc::EndFrameqc(const char* str) : EndFramec(str) { +EndFrameqc::EndFrameqc(const std::string& str) : EndFramec(str) { } void EndFrameqc::initialize() diff --git a/OndselSolver/EndFrameqc.h b/OndselSolver/EndFrameqc.h index 8447102..7efb62c 100644 --- a/OndselSolver/EndFrameqc.h +++ b/OndselSolver/EndFrameqc.h @@ -21,7 +21,7 @@ namespace MbD { //prOeOpE pprOeOpEpE pAOepE ppAOepEpE public: EndFrameqc(); - EndFrameqc(const char* str); + EndFrameqc(const std::string& str); void initialize() override; void initializeGlobally() override; void initEndFrameqct() override; diff --git a/OndselSolver/EndFrameqct.cpp b/OndselSolver/EndFrameqct.cpp index 23336aa..a898d2e 100644 --- a/OndselSolver/EndFrameqct.cpp +++ b/OndselSolver/EndFrameqct.cpp @@ -10,7 +10,7 @@ #include "MarkerFrame.h" #include "System.h" #include "Symbolic.h" -#include "Time.h" +#include "SymTime.h" #include "EulerParameters.h" #include "CREATE.h" #include "EulerAngleszxz.h" @@ -22,7 +22,7 @@ using namespace MbD; EndFrameqct::EndFrameqct() { } -EndFrameqct::EndFrameqct(const char* str) : EndFrameqc(str) { +EndFrameqct::EndFrameqct(const std::string& str) : EndFrameqc(str) { } void EndFrameqct::initialize() diff --git a/OndselSolver/EndFrameqct.h b/OndselSolver/EndFrameqct.h index 415069e..924a834 100644 --- a/OndselSolver/EndFrameqct.h +++ b/OndselSolver/EndFrameqct.h @@ -21,7 +21,7 @@ namespace MbD { //rmem prmempt pprmemptpt aAme pAmept ppAmeptpt prOeOpt pprOeOpEpt pprOeOptpt pAOept ppAOepEpt ppAOeptpt public: EndFrameqct(); - EndFrameqct(const char* str); + EndFrameqct(const std::string& str); void initialize() override; void initializeLocally() override; void initializeGlobally() override; diff --git a/OndselSolver/EndFrameqct2.cpp b/OndselSolver/EndFrameqct2.cpp index 3f9a86b..e9eb667 100644 --- a/OndselSolver/EndFrameqct2.cpp +++ b/OndselSolver/EndFrameqct2.cpp @@ -10,7 +10,7 @@ #include "MarkerFrame.h" #include "System.h" #include "Symbolic.h" -#include "Time.h" +#include "SymTime.h" #include "EulerParameters.h" #include "CREATE.h" #include "EulerAngleszxz.h" @@ -22,7 +22,7 @@ using namespace MbD; EndFrameqct2::EndFrameqct2() { } -EndFrameqct2::EndFrameqct2(const char* str) : EndFrameqct(str) { +EndFrameqct2::EndFrameqct2(const std::string& str) : EndFrameqct(str) { } void EndFrameqct2::initpPhiThePsiptBlks() diff --git a/OndselSolver/EndFrameqct2.h b/OndselSolver/EndFrameqct2.h index 53c9cd1..9cc2bd4 100644 --- a/OndselSolver/EndFrameqct2.h +++ b/OndselSolver/EndFrameqct2.h @@ -22,7 +22,7 @@ namespace MbD { // public: EndFrameqct2(); - EndFrameqct2(const char* str); + EndFrameqct2(const std::string& str); void initpPhiThePsiptBlks() override; void initppPhiThePsiptptBlks() override; void evalAme() override; diff --git a/OndselSolver/EulerConstraint.cpp b/OndselSolver/EulerConstraint.cpp index bce236b..7ef6b73 100644 --- a/OndselSolver/EulerConstraint.cpp +++ b/OndselSolver/EulerConstraint.cpp @@ -17,7 +17,7 @@ EulerConstraint::EulerConstraint() } -EulerConstraint::EulerConstraint(const char* str) : Constraint(str) +EulerConstraint::EulerConstraint(const std::string& str) : Constraint(str) { } diff --git a/OndselSolver/EulerConstraint.h b/OndselSolver/EulerConstraint.h index c71a021..2e6cdcc 100644 --- a/OndselSolver/EulerConstraint.h +++ b/OndselSolver/EulerConstraint.h @@ -20,7 +20,7 @@ namespace MbD { //pGpE iqE public: EulerConstraint(); - EulerConstraint(const char* str); + EulerConstraint(const std::string& str); void initialize() override; void calcPostDynCorrectorIteration() override; void useEquationNumbers() override; diff --git a/OndselSolver/ExternalSystem.cpp b/OndselSolver/ExternalSystem.cpp index 399b763..690d8f3 100644 --- a/OndselSolver/ExternalSystem.cpp +++ b/OndselSolver/ExternalSystem.cpp @@ -59,7 +59,7 @@ void MbD::ExternalSystem::outputFor(AnalysisType type) } } -void MbD::ExternalSystem::logString(std::string& str) +void MbD::ExternalSystem::logString(const std::string& str) { std::cout << str << std::endl; } diff --git a/OndselSolver/ExternalSystem.h b/OndselSolver/ExternalSystem.h index 65730ec..39d4cad 100644 --- a/OndselSolver/ExternalSystem.h +++ b/OndselSolver/ExternalSystem.h @@ -29,7 +29,7 @@ namespace MbD { void preMbDrunDragStep(std::shared_ptr mbdSys, std::shared_ptr>> dragParts); void updateFromMbD(); void outputFor(AnalysisType type); - void logString(std::string& str); + void logString(const std::string& str); void logString(double value); void runOndselPiston(); void runPiston(); diff --git a/OndselSolver/FixedJoint.cpp b/OndselSolver/FixedJoint.cpp index a193bc1..8a42bb0 100644 --- a/OndselSolver/FixedJoint.cpp +++ b/OndselSolver/FixedJoint.cpp @@ -16,7 +16,7 @@ MbD::FixedJoint::FixedJoint() { } -MbD::FixedJoint::FixedJoint(const char* str) : AtPointJoint(str) +MbD::FixedJoint::FixedJoint(const std::string& str) : AtPointJoint(str) { } diff --git a/OndselSolver/FixedJoint.h b/OndselSolver/FixedJoint.h index 5bd9159..17643b4 100644 --- a/OndselSolver/FixedJoint.h +++ b/OndselSolver/FixedJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: FixedJoint(); - FixedJoint(const char* str); + FixedJoint(const std::string& str); void initializeGlobally() override; diff --git a/OndselSolver/FullMotion.cpp b/OndselSolver/FullMotion.cpp index 71caf9d..a67ca70 100644 --- a/OndselSolver/FullMotion.cpp +++ b/OndselSolver/FullMotion.cpp @@ -16,7 +16,7 @@ MbD::FullMotion::FullMotion() { } -MbD::FullMotion::FullMotion(const char*) +MbD::FullMotion::FullMotion(const std::string&) { } diff --git a/OndselSolver/FullMotion.h b/OndselSolver/FullMotion.h index 1fe9cf3..50ca411 100644 --- a/OndselSolver/FullMotion.h +++ b/OndselSolver/FullMotion.h @@ -19,7 +19,7 @@ namespace MbD { //frIJI fangIJJ public: FullMotion(); - FullMotion(const char* str); + FullMotion(const std::string& str); void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override; void initializeGlobally() override; void initMotions() override; diff --git a/OndselSolver/FunctionX.cpp b/OndselSolver/FunctionX.cpp index 461653c..8126c69 100644 --- a/OndselSolver/FunctionX.cpp +++ b/OndselSolver/FunctionX.cpp @@ -26,10 +26,9 @@ void MbD::FunctionX::arguments(Symsptr args) xx = arguments->terms->front(); } -Symsptr MbD::FunctionX::copyWith(Symsptr) +Symsptr MbD::FunctionX::copyWith(Symsptr self) { - assert(false); - return Symsptr(); + return self; } Symsptr MbD::FunctionX::expandUntil(Symsptr sptr, std::shared_ptr> set) diff --git a/OndselSolver/GESpMatParPvPrecise.cpp b/OndselSolver/GESpMatParPvPrecise.cpp index bd10eb1..f2edc56 100644 --- a/OndselSolver/GESpMatParPvPrecise.cpp +++ b/OndselSolver/GESpMatParPvPrecise.cpp @@ -10,6 +10,7 @@ #include "GESpMatParPvPrecise.h" #include "SingularMatrixError.h" +#include "CREATE.h" using namespace MbD; @@ -104,3 +105,22 @@ void GESpMatParPvPrecise::preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr f rowOrder->at(i) = i; } } + +void MbD::GESpMatParPvPrecise::runSpMat() +{ + auto spMat = std::make_shared>(3, 3); + spMat->atijput(0, 0, 1.0); + spMat->atijput(0, 1, 1.0); + spMat->atijput(1, 0, 1.0); + spMat->atijput(1, 1, 1.0); + spMat->atijput(1, 2, 1.0); + spMat->atijput(2, 1, 1.0); + spMat->atijput(2, 2, 1.0); + auto fullCol = std::make_shared>(3); + fullCol->atiput(0, 1.0); + fullCol->atiput(1, 2.0); + fullCol->atiput(2, 3.0); + auto matSolver = CREATE::With(); + auto answer = matSolver->solvewithsaveOriginal(spMat, fullCol, true); + auto aAx = spMat->timesFullColumn(answer); +} diff --git a/OndselSolver/GESpMatParPvPrecise.h b/OndselSolver/GESpMatParPvPrecise.h index 17db611..9c9172e 100644 --- a/OndselSolver/GESpMatParPvPrecise.h +++ b/OndselSolver/GESpMatParPvPrecise.h @@ -17,6 +17,7 @@ namespace MbD { public: void doPivoting(size_t p) override; void preSolvewithsaveOriginal(SpMatDsptr spMat, FColDsptr fullCol, bool saveOriginal) override; + static void runSpMat(); }; } diff --git a/OndselSolver/GearJoint.cpp b/OndselSolver/GearJoint.cpp index 687a3fb..1e3a855 100644 --- a/OndselSolver/GearJoint.cpp +++ b/OndselSolver/GearJoint.cpp @@ -17,7 +17,7 @@ MbD::GearJoint::GearJoint() { } -MbD::GearJoint::GearJoint(const char*) +MbD::GearJoint::GearJoint(const std::string&) { } // diff --git a/OndselSolver/GearJoint.h b/OndselSolver/GearJoint.h index cbf285e..ffedb6d 100644 --- a/OndselSolver/GearJoint.h +++ b/OndselSolver/GearJoint.h @@ -16,7 +16,7 @@ namespace MbD { //radiusI radiusJ aConstant public: GearJoint(); - GearJoint(const char* str); + GearJoint(const std::string& str); //void initializeLocally() override; void initializeGlobally() override; diff --git a/OndselSolver/ICKineIntegrator.cpp b/OndselSolver/ICKineIntegrator.cpp index 037b025..1fdfcd4 100644 --- a/OndselSolver/ICKineIntegrator.cpp +++ b/OndselSolver/ICKineIntegrator.cpp @@ -30,7 +30,7 @@ void ICKineIntegrator::selectOrder() void ICKineIntegrator::preRun() { - system->Solver::logString("MbD: Starting quasi kinematic analysis."); + system->logString("MbD: Starting quasi kinematic analysis."); QuasiIntegrator::preRun(); } diff --git a/OndselSolver/InLineJoint.cpp b/OndselSolver/InLineJoint.cpp index 31f9fab..c30396b 100644 --- a/OndselSolver/InLineJoint.cpp +++ b/OndselSolver/InLineJoint.cpp @@ -13,7 +13,7 @@ MbD::InLineJoint::InLineJoint() { } -MbD::InLineJoint::InLineJoint(const char*) +MbD::InLineJoint::InLineJoint(const std::string&) { } diff --git a/OndselSolver/InLineJoint.h b/OndselSolver/InLineJoint.h index 334b449..e8957d7 100644 --- a/OndselSolver/InLineJoint.h +++ b/OndselSolver/InLineJoint.h @@ -16,7 +16,7 @@ namespace MbD { //Abstract class. Create subclasses only. public: InLineJoint(); - InLineJoint(const char* str); + InLineJoint(const std::string& str); virtual void initializeGlobally() = 0; //To prevent instantiation of this class void createInLineConstraints(); diff --git a/OndselSolver/InPlaneJoint.cpp b/OndselSolver/InPlaneJoint.cpp index 0105a93..7c7feba 100644 --- a/OndselSolver/InPlaneJoint.cpp +++ b/OndselSolver/InPlaneJoint.cpp @@ -13,7 +13,7 @@ MbD::InPlaneJoint::InPlaneJoint() { } -MbD::InPlaneJoint::InPlaneJoint(const char*) +MbD::InPlaneJoint::InPlaneJoint(const std::string&) { } diff --git a/OndselSolver/InPlaneJoint.h b/OndselSolver/InPlaneJoint.h index a85ffa6..70a9e80 100644 --- a/OndselSolver/InPlaneJoint.h +++ b/OndselSolver/InPlaneJoint.h @@ -16,7 +16,7 @@ namespace MbD { //offset public: InPlaneJoint(); - InPlaneJoint(const char* str); + InPlaneJoint(const std::string& str); virtual void initializeGlobally() = 0; //To prevent instantiation of this class void createInPlaneConstraint(); diff --git a/OndselSolver/IntegratorInterface.cpp b/OndselSolver/IntegratorInterface.cpp index c7727e8..af6b3a0 100644 --- a/OndselSolver/IntegratorInterface.cpp +++ b/OndselSolver/IntegratorInterface.cpp @@ -30,7 +30,7 @@ void IntegratorInterface::setSystem(Solver* sys) system = static_cast(sys); } -void IntegratorInterface::logString(std::string& str) +void IntegratorInterface::logString(const std::string& str) { system->logString(str); } diff --git a/OndselSolver/IntegratorInterface.h b/OndselSolver/IntegratorInterface.h index a7f33c7..77a801f 100644 --- a/OndselSolver/IntegratorInterface.h +++ b/OndselSolver/IntegratorInterface.h @@ -24,7 +24,7 @@ namespace MbD { virtual void checkForDiscontinuity() = 0; void setSystem(Solver* sys) override; - void logString(std::string& str) override; + void logString(const std::string& str) override; void run() override; size_t orderMax(); virtual void incrementTime(double tnew); diff --git a/OndselSolver/Item.cpp b/OndselSolver/Item.cpp index 67713bc..4435d5d 100644 --- a/OndselSolver/Item.cpp +++ b/OndselSolver/Item.cpp @@ -24,7 +24,7 @@ Item::Item() { name = std::to_string(nanoseconds); } -Item::Item(const char* str) : name(str) +Item::Item(const std::string& str) : name(str) { } @@ -377,11 +377,6 @@ void Item::fillVelICJacob(SpMatDsptr) { } -void MbD::Item::getString(std::string) -{ - assert(false); -} - void Item::setqsudotlam(FColDsptr) { } @@ -549,23 +544,17 @@ void Item::useEquationNumbers() { } -void Item::logString(std::string& str) +void Item::logString(const std::string& str) { this->root()->logString(str); } -void Item::logString(const char* chars) -{ - std::string str = chars; - this->logString(str); -} - -void MbD::Item::logStringwithArgument(const char*, const char*) +void MbD::Item::logStringwithArgument(const std::string&, const std::string&) { assert(false); } -void MbD::Item::logStringwithArguments(const char*, std::shared_ptr>) +void MbD::Item::logStringwithArguments(const std::string&, std::shared_ptr>) { assert(false); } diff --git a/OndselSolver/Item.h b/OndselSolver/Item.h index 4ef7158..ff6e50e 100644 --- a/OndselSolver/Item.h +++ b/OndselSolver/Item.h @@ -27,7 +27,7 @@ namespace MbD { //name public: Item(); - Item(const char* str); + Item(const std::string& str); virtual ~Item() {} virtual System* root(); void noop(); @@ -73,7 +73,6 @@ namespace MbD { virtual void fillStaticJacob(FMatDsptr mat); virtual void fillVelICError(FColDsptr col); virtual void fillVelICJacob(SpMatDsptr mat); - virtual void getString(std::string str); virtual void initialize(); virtual void initializeGlobally(); virtual void initializeLocally(); @@ -81,10 +80,9 @@ namespace MbD { virtual bool isJointTorque(); virtual bool isKinedotIJ(); virtual bool isKineIJ(); - virtual void logString(std::string& str); - void logString(const char* chars); - virtual void logStringwithArgument(const char* chars, const char* chars1); - virtual void logStringwithArguments(const char* chars, std::shared_ptr> arrayOfChars); + virtual void logString(const std::string& str); + virtual void logStringwithArgument(const std::string& chars, const std::string& chars1); + virtual void logStringwithArguments(const std::string& chars, std::shared_ptr> arrayOfChars); virtual void normalImpulse(double imp); virtual void postAccIC(); virtual void postAccICIteration(); diff --git a/OndselSolver/ItemIJ.cpp b/OndselSolver/ItemIJ.cpp index ce5e8f2..5008085 100644 --- a/OndselSolver/ItemIJ.cpp +++ b/OndselSolver/ItemIJ.cpp @@ -6,7 +6,7 @@ MbD::ItemIJ::ItemIJ() { } -MbD::ItemIJ::ItemIJ(const char* str) : Item(str) +MbD::ItemIJ::ItemIJ(const std::string& str) : Item(str) { } diff --git a/OndselSolver/ItemIJ.h b/OndselSolver/ItemIJ.h index 9f3fd5d..64819af 100644 --- a/OndselSolver/ItemIJ.h +++ b/OndselSolver/ItemIJ.h @@ -19,7 +19,7 @@ namespace MbD { // public: ItemIJ(); - ItemIJ(const char* str); + ItemIJ(const std::string& str); ItemIJ(EndFrmsptr frmi, EndFrmsptr frmj); virtual void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ); diff --git a/OndselSolver/Joint.cpp b/OndselSolver/Joint.cpp index 786c195..80de74f 100644 --- a/OndselSolver/Joint.cpp +++ b/OndselSolver/Joint.cpp @@ -26,7 +26,7 @@ Joint::Joint() { } -Joint::Joint(const char* str) : ConstraintSet(str) { +Joint::Joint(const std::string& str) : ConstraintSet(str) { } diff --git a/OndselSolver/Joint.h b/OndselSolver/Joint.h index b0b425c..765430c 100644 --- a/OndselSolver/Joint.h +++ b/OndselSolver/Joint.h @@ -24,7 +24,7 @@ namespace MbD { //frmI frmJ constraints friction public: Joint(); - Joint(const char* str); + Joint(const std::string& str); virtual ~Joint() {} void initializeLocally() override; diff --git a/OndselSolver/KineIntegrator.cpp b/OndselSolver/KineIntegrator.cpp index 072cac1..709d8b1 100644 --- a/OndselSolver/KineIntegrator.cpp +++ b/OndselSolver/KineIntegrator.cpp @@ -16,7 +16,7 @@ using namespace MbD; void KineIntegrator::preRun() { - system->Solver::logString("MbD: Starting kinematic analysis."); + system->logString("MbD: Starting kinematic analysis."); QuasiIntegrator::preRun(); } diff --git a/OndselSolver/LineInPlaneJoint.cpp b/OndselSolver/LineInPlaneJoint.cpp index a6c71e6..5cf740e 100644 --- a/OndselSolver/LineInPlaneJoint.cpp +++ b/OndselSolver/LineInPlaneJoint.cpp @@ -16,7 +16,7 @@ MbD::LineInPlaneJoint::LineInPlaneJoint() { } -MbD::LineInPlaneJoint::LineInPlaneJoint(const char*) +MbD::LineInPlaneJoint::LineInPlaneJoint(const std::string&) { } diff --git a/OndselSolver/LineInPlaneJoint.h b/OndselSolver/LineInPlaneJoint.h index cb03d20..1c24358 100644 --- a/OndselSolver/LineInPlaneJoint.h +++ b/OndselSolver/LineInPlaneJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: LineInPlaneJoint(); - LineInPlaneJoint(const char* str); + LineInPlaneJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/MarkerFrame.cpp b/OndselSolver/MarkerFrame.cpp index ad39e72..c0a2d19 100644 --- a/OndselSolver/MarkerFrame.cpp +++ b/OndselSolver/MarkerFrame.cpp @@ -21,7 +21,7 @@ MarkerFrame::MarkerFrame() { } -MarkerFrame::MarkerFrame(const char* str) : CartesianFrame(str) { +MarkerFrame::MarkerFrame(const std::string& str) : CartesianFrame(str) { } System* MarkerFrame::root() diff --git a/OndselSolver/MarkerFrame.h b/OndselSolver/MarkerFrame.h index 9b253a6..779e445 100644 --- a/OndselSolver/MarkerFrame.h +++ b/OndselSolver/MarkerFrame.h @@ -28,7 +28,7 @@ namespace MbD { //partFrame rpmp aApm rOmO aAOm prOmOpE pAOmpE pprOmOpEpE ppAOmpEpE endFrames public: MarkerFrame(); - MarkerFrame(const char* str); + MarkerFrame(const std::string& str); System* root() override; void initialize() override; void setPartFrame(PartFrame* partFrm); diff --git a/OndselSolver/MatrixSolver.cpp b/OndselSolver/MatrixSolver.cpp index f21b560..0dec2a4 100644 --- a/OndselSolver/MatrixSolver.cpp +++ b/OndselSolver/MatrixSolver.cpp @@ -70,12 +70,12 @@ void MatrixSolver::findScalingsForRowRange(size_t begin, size_t end) } } -void MatrixSolver::throwSingularMatrixError(const char* chars) +void MatrixSolver::throwSingularMatrixError(const std::string& chars) { throw SingularMatrixError(chars); } -void MatrixSolver::throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos) +void MatrixSolver::throwSingularMatrixError(const std::string& chars, std::shared_ptr> redunEqnNos) { throw SingularMatrixError(chars, redunEqnNos); } diff --git a/OndselSolver/MatrixSolver.h b/OndselSolver/MatrixSolver.h index 0bb99fa..8438cac 100644 --- a/OndselSolver/MatrixSolver.h +++ b/OndselSolver/MatrixSolver.h @@ -38,8 +38,8 @@ namespace MbD { virtual void postSolve() = 0; virtual void findScalingsForRowRange(size_t begin, size_t end); virtual double getmatrixArowimaxMagnitude(size_t i) = 0; - void throwSingularMatrixError(const char* chars); - void throwSingularMatrixError(const char* chars, std::shared_ptr> redunEqnNos); + void throwSingularMatrixError(const std::string& chars); + void throwSingularMatrixError(const std::string& chars, std::shared_ptr> redunEqnNos); size_t m = 0, n = 0; FColDsptr answerX, rightHandSideB, rowScalings, pivotValues; diff --git a/OndselSolver/NoRotationJoint.cpp b/OndselSolver/NoRotationJoint.cpp index d55f8e4..d611b3e 100644 --- a/OndselSolver/NoRotationJoint.cpp +++ b/OndselSolver/NoRotationJoint.cpp @@ -17,7 +17,7 @@ MbD::NoRotationJoint::NoRotationJoint() { } -MbD::NoRotationJoint::NoRotationJoint(const char*) +MbD::NoRotationJoint::NoRotationJoint(const std::string&) { } diff --git a/OndselSolver/NoRotationJoint.h b/OndselSolver/NoRotationJoint.h index 8146e90..514d2d7 100644 --- a/OndselSolver/NoRotationJoint.h +++ b/OndselSolver/NoRotationJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: NoRotationJoint(); - NoRotationJoint(const char* str); + NoRotationJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/Orientation.cpp b/OndselSolver/Orientation.cpp index 0dfdea4..89dda45 100644 --- a/OndselSolver/Orientation.cpp +++ b/OndselSolver/Orientation.cpp @@ -16,7 +16,7 @@ MbD::Orientation::Orientation() { } -MbD::Orientation::Orientation(const char*) +MbD::Orientation::Orientation(const std::string&) { } diff --git a/OndselSolver/Orientation.h b/OndselSolver/Orientation.h index bc6566d..3e30b61 100644 --- a/OndselSolver/Orientation.h +++ b/OndselSolver/Orientation.h @@ -16,7 +16,7 @@ namespace MbD { // public: Orientation(); - Orientation(const char* str); + Orientation(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/ParallelAxesJoint.cpp b/OndselSolver/ParallelAxesJoint.cpp index 380c0f3..81d4964 100644 --- a/OndselSolver/ParallelAxesJoint.cpp +++ b/OndselSolver/ParallelAxesJoint.cpp @@ -16,7 +16,7 @@ MbD::ParallelAxesJoint::ParallelAxesJoint() { } -MbD::ParallelAxesJoint::ParallelAxesJoint(const char*) +MbD::ParallelAxesJoint::ParallelAxesJoint(const std::string&) { } diff --git a/OndselSolver/ParallelAxesJoint.h b/OndselSolver/ParallelAxesJoint.h index 4e927ee..dc61a8a 100644 --- a/OndselSolver/ParallelAxesJoint.h +++ b/OndselSolver/ParallelAxesJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: ParallelAxesJoint(); - ParallelAxesJoint(const char* str); + ParallelAxesJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/Part.cpp b/OndselSolver/Part.cpp index 2b19cf0..380dbdd 100644 --- a/OndselSolver/Part.cpp +++ b/OndselSolver/Part.cpp @@ -22,7 +22,7 @@ using namespace MbD; Part::Part() { } -Part::Part(const char* str) : Item(str) { +Part::Part(const std::string& str) : Item(str) { } System* MbD::Part::root() diff --git a/OndselSolver/Part.h b/OndselSolver/Part.h index 35f57c1..610ef7a 100644 --- a/OndselSolver/Part.h +++ b/OndselSolver/Part.h @@ -22,7 +22,7 @@ namespace MbD { //ToDo: ipX ipE m aJ partFrame pX pXdot pE pEdot mX mE mEdot pTpE ppTpEpE ppTpEpEdot public: Part(); - Part(const char* str); + Part(const std::string& str); System* root() override; void initialize() override; void initializeLocally() override; diff --git a/OndselSolver/PartFrame.cpp b/OndselSolver/PartFrame.cpp index 35e9185..a641604 100644 --- a/OndselSolver/PartFrame.cpp +++ b/OndselSolver/PartFrame.cpp @@ -24,7 +24,7 @@ using namespace MbD; PartFrame::PartFrame() { } -PartFrame::PartFrame(const char* str) : CartesianFrame(str) +PartFrame::PartFrame(const std::string& str) : CartesianFrame(str) { } System* PartFrame::root() @@ -127,7 +127,7 @@ void PartFrame::addMarkerFrame(std::shared_ptr markerFrame) markerFrames->push_back(markerFrame); } -EndFrmsptr PartFrame::endFrame(std::string name) +EndFrmsptr PartFrame::endFrame(const std::string& name) { auto match = std::find_if(markerFrames->begin(), markerFrames->end(), [&](auto& mkr) {return mkr->name == name; }); return (*match)->endFrames->at(0); diff --git a/OndselSolver/PartFrame.h b/OndselSolver/PartFrame.h index 61c19bd..12c41ab 100644 --- a/OndselSolver/PartFrame.h +++ b/OndselSolver/PartFrame.h @@ -30,7 +30,7 @@ namespace MbD { //ToDo: part iqX iqE qX qE qXdot qEdot qXddot qEddot aGeu aGabs markerFrames public: PartFrame(); - PartFrame(const char* str); + PartFrame(const std::string& str); System* root() override; void initialize() override; void initializeLocally() override; @@ -57,7 +57,7 @@ namespace MbD { void setPart(Part* x); Part* getPart(); void addMarkerFrame(std::shared_ptr x); - EndFrmsptr endFrame(std::string name); + EndFrmsptr endFrame(const std::string& name); void aGabsDo(const std::function )>& f); void markerFramesDo(const std::function )>& f); void removeRedundantConstraints(std::shared_ptr> redundantEqnNos) override; diff --git a/OndselSolver/PerpendicularJoint.cpp b/OndselSolver/PerpendicularJoint.cpp index a8c30ab..b3eb9f4 100644 --- a/OndselSolver/PerpendicularJoint.cpp +++ b/OndselSolver/PerpendicularJoint.cpp @@ -16,7 +16,7 @@ MbD::PerpendicularJoint::PerpendicularJoint() { } -MbD::PerpendicularJoint::PerpendicularJoint(const char*) +MbD::PerpendicularJoint::PerpendicularJoint(const std::string&) { } diff --git a/OndselSolver/PerpendicularJoint.h b/OndselSolver/PerpendicularJoint.h index 9783d02..b58bfe3 100644 --- a/OndselSolver/PerpendicularJoint.h +++ b/OndselSolver/PerpendicularJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: PerpendicularJoint(); - PerpendicularJoint(const char* str); + PerpendicularJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/PlanarJoint.cpp b/OndselSolver/PlanarJoint.cpp index a79fcfa..85d9de4 100644 --- a/OndselSolver/PlanarJoint.cpp +++ b/OndselSolver/PlanarJoint.cpp @@ -16,7 +16,7 @@ MbD::PlanarJoint::PlanarJoint() { } -MbD::PlanarJoint::PlanarJoint(const char*) +MbD::PlanarJoint::PlanarJoint(const std::string&) { } diff --git a/OndselSolver/PlanarJoint.h b/OndselSolver/PlanarJoint.h index 2a398ad..e2a7a5f 100644 --- a/OndselSolver/PlanarJoint.h +++ b/OndselSolver/PlanarJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: PlanarJoint(); - PlanarJoint(const char* str); + PlanarJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/PointInLineJoint.cpp b/OndselSolver/PointInLineJoint.cpp index 9ecafae..c8dedf8 100644 --- a/OndselSolver/PointInLineJoint.cpp +++ b/OndselSolver/PointInLineJoint.cpp @@ -16,7 +16,7 @@ MbD::PointInLineJoint::PointInLineJoint() { } -MbD::PointInLineJoint::PointInLineJoint(const char* str) : InLineJoint(str) +MbD::PointInLineJoint::PointInLineJoint(const std::string& str) : InLineJoint(str) { } diff --git a/OndselSolver/PointInLineJoint.h b/OndselSolver/PointInLineJoint.h index 76331b4..8de8f5b 100644 --- a/OndselSolver/PointInLineJoint.h +++ b/OndselSolver/PointInLineJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: PointInLineJoint(); - PointInLineJoint(const char* str); + PointInLineJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/PointInPlaneJoint.cpp b/OndselSolver/PointInPlaneJoint.cpp index 992db5a..81009d5 100644 --- a/OndselSolver/PointInPlaneJoint.cpp +++ b/OndselSolver/PointInPlaneJoint.cpp @@ -15,7 +15,7 @@ MbD::PointInPlaneJoint::PointInPlaneJoint() { } -MbD::PointInPlaneJoint::PointInPlaneJoint(const char*) +MbD::PointInPlaneJoint::PointInPlaneJoint(const std::string&) { } diff --git a/OndselSolver/PointInPlaneJoint.h b/OndselSolver/PointInPlaneJoint.h index 07925b2..0a06e02 100644 --- a/OndselSolver/PointInPlaneJoint.h +++ b/OndselSolver/PointInPlaneJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: PointInPlaneJoint(); - PointInPlaneJoint(const char* str); + PointInPlaneJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/PosICKineNewtonRaphson.cpp b/OndselSolver/PosICKineNewtonRaphson.cpp index c7c8569..33097bc 100644 --- a/OndselSolver/PosICKineNewtonRaphson.cpp +++ b/OndselSolver/PosICKineNewtonRaphson.cpp @@ -22,6 +22,6 @@ void PosICKineNewtonRaphson::initializeGlobally() void MbD::PosICKineNewtonRaphson::preRun() { - system->Solver::logString("MbD: Solving for quasi kinematic position."); + system->logString("MbD: Solving for quasi kinematic position."); PosNewtonRaphson::preRun(); } diff --git a/OndselSolver/PrescribedMotion.cpp b/OndselSolver/PrescribedMotion.cpp index 8c0c122..2bf43f1 100644 --- a/OndselSolver/PrescribedMotion.cpp +++ b/OndselSolver/PrescribedMotion.cpp @@ -21,7 +21,7 @@ PrescribedMotion::PrescribedMotion() { } -PrescribedMotion::PrescribedMotion(const char* str) : Joint(str) { +PrescribedMotion::PrescribedMotion(const std::string& str) : Joint(str) { } diff --git a/OndselSolver/PrescribedMotion.h b/OndselSolver/PrescribedMotion.h index bc0c828..a4f083f 100644 --- a/OndselSolver/PrescribedMotion.h +++ b/OndselSolver/PrescribedMotion.h @@ -21,7 +21,7 @@ namespace MbD { //xBlk yBlk zBlk phiBlk theBlk psiBlk public: PrescribedMotion(); - PrescribedMotion(const char* str); + PrescribedMotion(const std::string& str); void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override; void initialize() override; diff --git a/OndselSolver/QuasiIntegrator.cpp b/OndselSolver/QuasiIntegrator.cpp index cd63811..9b8d7c0 100644 --- a/OndselSolver/QuasiIntegrator.cpp +++ b/OndselSolver/QuasiIntegrator.cpp @@ -152,7 +152,7 @@ double QuasiIntegrator::suggestSmallerOrAcceptStepSize(double hnew) system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr item) { hnew2 = item->suggestSmallerOrAcceptDynStepSize(hnew2); }); if (hnew2 > hmax) { hnew2 = hmax; - this->Solver::logString("StM: Step size is at user specified maximum."); + this->logString("StM: Step size is at user specified maximum."); } if (hnew2 < hmin) { std::stringstream ss; @@ -170,7 +170,7 @@ void QuasiIntegrator::incrementTime(double tnew) IntegratorInterface::incrementTime(tnew); } -void QuasiIntegrator::throwDiscontinuityError(const char* chars, std::shared_ptr> discontinuityTypes) +void QuasiIntegrator::throwDiscontinuityError(const std::string& chars, std::shared_ptr> discontinuityTypes) { throw DiscontinuityError(chars, discontinuityTypes); } diff --git a/OndselSolver/QuasiIntegrator.h b/OndselSolver/QuasiIntegrator.h index 12a1830..17a51c4 100644 --- a/OndselSolver/QuasiIntegrator.h +++ b/OndselSolver/QuasiIntegrator.h @@ -28,7 +28,7 @@ namespace MbD { double suggestSmallerOrAcceptFirstStepSize(double hnew) override; double suggestSmallerOrAcceptStepSize(double hnew) override; void incrementTime(double tnew) override; - void throwDiscontinuityError(const char* chars, std::shared_ptr> discontinuityTypes); + void throwDiscontinuityError(const std::string& chars, std::shared_ptr> discontinuityTypes); void checkForOutputThrough(double t) override; void interpolateAt(double t) override; void postStep() override; diff --git a/OndselSolver/RackPinJoint.cpp b/OndselSolver/RackPinJoint.cpp index f196527..a596ce5 100644 --- a/OndselSolver/RackPinJoint.cpp +++ b/OndselSolver/RackPinJoint.cpp @@ -17,7 +17,7 @@ MbD::RackPinJoint::RackPinJoint() { } -MbD::RackPinJoint::RackPinJoint(const char* str) : Joint(str) +MbD::RackPinJoint::RackPinJoint(const std::string& str) : Joint(str) { } // diff --git a/OndselSolver/RackPinJoint.h b/OndselSolver/RackPinJoint.h index 21fdbe4..ac657ef 100644 --- a/OndselSolver/RackPinJoint.h +++ b/OndselSolver/RackPinJoint.h @@ -16,7 +16,7 @@ namespace MbD { //pitchRadius aConstant public: RackPinJoint(); - RackPinJoint(const char* str); + RackPinJoint(const std::string& str); //void initializeLocally() override; void initializeGlobally() override; void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override; diff --git a/OndselSolver/RevCylJoint.cpp b/OndselSolver/RevCylJoint.cpp index 2ed1f2b..01eb3e5 100644 --- a/OndselSolver/RevCylJoint.cpp +++ b/OndselSolver/RevCylJoint.cpp @@ -17,7 +17,7 @@ MbD::RevCylJoint::RevCylJoint() { } -MbD::RevCylJoint::RevCylJoint(const char* str) : CompoundJoint(str) +MbD::RevCylJoint::RevCylJoint(const std::string& str) : CompoundJoint(str) { } diff --git a/OndselSolver/RevCylJoint.h b/OndselSolver/RevCylJoint.h index 384e358..3963b91 100644 --- a/OndselSolver/RevCylJoint.h +++ b/OndselSolver/RevCylJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: RevCylJoint(); - RevCylJoint(const char* str); + RevCylJoint(const std::string& str); void initializeGlobally() override; diff --git a/OndselSolver/RevRevJoint.cpp b/OndselSolver/RevRevJoint.cpp index 362e0e8..53c5b68 100644 --- a/OndselSolver/RevRevJoint.cpp +++ b/OndselSolver/RevRevJoint.cpp @@ -17,7 +17,7 @@ MbD::RevRevJoint::RevRevJoint() { } -MbD::RevRevJoint::RevRevJoint(const char* str) : CompoundJoint(str) +MbD::RevRevJoint::RevRevJoint(const std::string& str) : CompoundJoint(str) { } diff --git a/OndselSolver/RevRevJoint.h b/OndselSolver/RevRevJoint.h index 6a024dc..b5bf71e 100644 --- a/OndselSolver/RevRevJoint.h +++ b/OndselSolver/RevRevJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: RevRevJoint(); - RevRevJoint(const char* str); + RevRevJoint(const std::string& str); void initializeGlobally() override; diff --git a/OndselSolver/RevoluteJoint.cpp b/OndselSolver/RevoluteJoint.cpp index 06a058b..190737e 100644 --- a/OndselSolver/RevoluteJoint.cpp +++ b/OndselSolver/RevoluteJoint.cpp @@ -18,7 +18,7 @@ RevoluteJoint::RevoluteJoint() { } -RevoluteJoint::RevoluteJoint(const char* str) : AtPointJoint(str) +RevoluteJoint::RevoluteJoint(const std::string& str) : AtPointJoint(str) { } diff --git a/OndselSolver/RevoluteJoint.h b/OndselSolver/RevoluteJoint.h index f3895f3..410a33e 100644 --- a/OndselSolver/RevoluteJoint.h +++ b/OndselSolver/RevoluteJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: RevoluteJoint(); - RevoluteJoint(const char* str); + RevoluteJoint(const std::string& str); void initializeGlobally() override; }; } diff --git a/OndselSolver/ScrewJoint.cpp b/OndselSolver/ScrewJoint.cpp index 5b22b5d..18f1136 100644 --- a/OndselSolver/ScrewJoint.cpp +++ b/OndselSolver/ScrewJoint.cpp @@ -17,7 +17,7 @@ MbD::ScrewJoint::ScrewJoint() { } -MbD::ScrewJoint::ScrewJoint(const char* str) : Joint(str) +MbD::ScrewJoint::ScrewJoint(const std::string& str) : Joint(str) { } // diff --git a/OndselSolver/ScrewJoint.h b/OndselSolver/ScrewJoint.h index 17ee8c1..960b4fd 100644 --- a/OndselSolver/ScrewJoint.h +++ b/OndselSolver/ScrewJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: ScrewJoint(); - ScrewJoint(const char* str); + ScrewJoint(const std::string& str); //void initializeLocally() override; void initializeGlobally() override; void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override; diff --git a/OndselSolver/Solver.cpp b/OndselSolver/Solver.cpp index e66aa7d..9c9e5de 100644 --- a/OndselSolver/Solver.cpp +++ b/OndselSolver/Solver.cpp @@ -59,17 +59,11 @@ void Solver::postRun() assert(false); } -void Solver::logString(std::string&) +void Solver::logString(const std::string&) { assert(false); } -void Solver::logString(const char* chars) -{ - std::string str = chars; - this->logString(str); -} - void MbD::Solver::handleSingularMatrix() { assert(false); diff --git a/OndselSolver/Solver.h b/OndselSolver/Solver.h index 4f679f7..126b46f 100644 --- a/OndselSolver/Solver.h +++ b/OndselSolver/Solver.h @@ -27,8 +27,7 @@ namespace MbD { virtual void finalize(); virtual void reportStats(); virtual void postRun(); - virtual void logString(std::string& str); - void logString(const char* chars); + virtual void logString(const std::string& str); virtual void setSystem(Solver* sys) = 0; virtual void handleSingularMatrix(); diff --git a/OndselSolver/SparseMatrix.h b/OndselSolver/SparseMatrix.h index ed1b08d..d5ee463 100644 --- a/OndselSolver/SparseMatrix.h +++ b/OndselSolver/SparseMatrix.h @@ -18,9 +18,10 @@ namespace MbD { template class SparseMatrix; + using SpMatDsptr = std::shared_ptr>; template using SpMatsptr = std::shared_ptr>; - using SpMatDsptr = std::shared_ptr>; + class GESpMatParPvPrecise; template class SparseMatrix : public RowTypeMatrix> diff --git a/OndselSolver/SphSphJoint.cpp b/OndselSolver/SphSphJoint.cpp index e4d32f7..520a972 100644 --- a/OndselSolver/SphSphJoint.cpp +++ b/OndselSolver/SphSphJoint.cpp @@ -17,7 +17,7 @@ MbD::SphSphJoint::SphSphJoint() { } -MbD::SphSphJoint::SphSphJoint(const char* str) : CompoundJoint(str) +MbD::SphSphJoint::SphSphJoint(const std::string& str) : CompoundJoint(str) { } diff --git a/OndselSolver/SphSphJoint.h b/OndselSolver/SphSphJoint.h index 608fcd4..108e7fd 100644 --- a/OndselSolver/SphSphJoint.h +++ b/OndselSolver/SphSphJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: SphSphJoint(); - SphSphJoint(const char* str); + SphSphJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/SphericalJoint.cpp b/OndselSolver/SphericalJoint.cpp index e15bca9..c1d4544 100644 --- a/OndselSolver/SphericalJoint.cpp +++ b/OndselSolver/SphericalJoint.cpp @@ -16,7 +16,7 @@ MbD::SphericalJoint::SphericalJoint() { } -MbD::SphericalJoint::SphericalJoint(const char* str) : AtPointJoint(str) +MbD::SphericalJoint::SphericalJoint(const std::string& str) : AtPointJoint(str) { } diff --git a/OndselSolver/SphericalJoint.h b/OndselSolver/SphericalJoint.h index 44b597c..6209599 100644 --- a/OndselSolver/SphericalJoint.h +++ b/OndselSolver/SphericalJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: SphericalJoint(); - SphericalJoint(const char* str); + SphericalJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/Sum.cpp b/OndselSolver/Sum.cpp index 85520a2..d6b320e 100644 --- a/OndselSolver/Sum.cpp +++ b/OndselSolver/Sum.cpp @@ -16,7 +16,7 @@ using namespace MbD; -Symsptr MbD::Sum::parseExpression(std::string& expression) +Symsptr MbD::Sum::parseExpression(const std::string& expression) { std::istringstream iss(expression); auto sum = std::make_shared(); diff --git a/OndselSolver/Sum.h b/OndselSolver/Sum.h index 49b168e..893741c 100644 --- a/OndselSolver/Sum.h +++ b/OndselSolver/Sum.h @@ -14,7 +14,7 @@ namespace MbD { class Sum : public FunctionWithManyArgs { public: - static Symsptr parseExpression(std::string& expression); + static Symsptr parseExpression(const std::string& expression); void parse(std::istringstream& iss); void parseTerm(std::istringstream& iss); void parsePlusTerm(std::istringstream& iss); diff --git a/OndselSolver/Time.h b/OndselSolver/SymTime.h similarity index 100% rename from OndselSolver/Time.h rename to OndselSolver/SymTime.h diff --git a/OndselSolver/SymbolicParser.cpp b/OndselSolver/SymbolicParser.cpp index 0aacf4a..63fb2b5 100644 --- a/OndselSolver/SymbolicParser.cpp +++ b/OndselSolver/SymbolicParser.cpp @@ -57,7 +57,7 @@ void MbD::SymbolicParser::parseUserFunction(Symsptr userFunc) stack->push(Symbolic::times(func, std::make_shared(usrFunc->myUnit))); } -void MbD::SymbolicParser::parseString(std::string expr) +void MbD::SymbolicParser::parseString(const std::string& expr) { buffer->clear(); while (!stack->empty()) { @@ -179,7 +179,7 @@ bool MbD::SymbolicParser::divideByFunction() return false; } -bool MbD::SymbolicParser::peekForTypeNoPush(std::string c) +bool MbD::SymbolicParser::peekForTypeNoPush(const std::string& c) { //"Test to see if tokenType matches aType. If so, advance to the next token, leaving the stack unchanged" @@ -440,7 +440,7 @@ bool MbD::SymbolicParser::raisedTo() return false; } -bool MbD::SymbolicParser::expected(std::string) +bool MbD::SymbolicParser::expected(const std::string&) { return false; } @@ -472,7 +472,7 @@ bool MbD::SymbolicParser::signedNumber() return false; } -bool MbD::SymbolicParser::peekForTypevalue(std::string type, std::string symbol) +bool MbD::SymbolicParser::peekForTypevalue(const std::string& type, std::string symbol) { if ((tokenType == type) && (token == symbol)) { scanToken(); @@ -481,12 +481,12 @@ bool MbD::SymbolicParser::peekForTypevalue(std::string type, std::string symbol) return false; } -void MbD::SymbolicParser::notify(std::string msg) const +void MbD::SymbolicParser::notify(const std::string& msg) const { notifyat(msg, mark); } -void MbD::SymbolicParser::notifyat(std::string, int) const +void MbD::SymbolicParser::notifyat(const std::string&, int) const { //"Temporarily reset source in order to get full contents" auto p = source->tellg(); diff --git a/OndselSolver/SymbolicParser.h b/OndselSolver/SymbolicParser.h index a38c29b..ef6a0d1 100644 --- a/OndselSolver/SymbolicParser.h +++ b/OndselSolver/SymbolicParser.h @@ -24,7 +24,7 @@ namespace MbD { SymbolicParser(); void initialize(); void parseUserFunction(Symsptr userFunc); - void parseString(std::string expr); + void parseString(const std::string& expr); bool commaExpression(); bool plusTerm(); bool minusTerm(); @@ -33,7 +33,7 @@ namespace MbD { bool plainFunction(); bool timesFunction(); bool divideByFunction(); - bool peekForTypeNoPush(std::string c); + bool peekForTypeNoPush(const std::string& c); std::string scanToken(); void xLetter(); void xDigit(); @@ -46,11 +46,11 @@ namespace MbD { bool intrinsic(); bool variable(); bool raisedTo(); - bool expected(std::string msg); + bool expected(const std::string& msg); bool signedNumber(); - bool peekForTypevalue(std::string type, std::string symbol); - void notify(std::string msg) const; - void notifyat(std::string msg, int mrk) const; + bool peekForTypevalue(const std::string& type, std::string symbol); + void notify(const std::string& msg) const; + void notifyat(const std::string& msg, int mrk) const; void combineStackTo(size_t pos) const; bool isNextLineTag(char c) const; diff --git a/OndselSolver/System.cpp b/OndselSolver/System.cpp index b88dc63..315fd60 100644 --- a/OndselSolver/System.cpp +++ b/OndselSolver/System.cpp @@ -13,7 +13,7 @@ #include "Joint.h" #include "ForceTorqueItem.h" #include "SystemSolver.h" -#include "Time.h" +#include "SymTime.h" #include "CREATE.h" #include "ExternalSystem.h" #include "PrescribedMotion.h" @@ -30,7 +30,7 @@ System::System() { systemSolver = std::make_shared(this); } -System::System(const char* str) : Item(str) { +System::System(const std::string& str) : Item(str) { } System* MbD::System::root() @@ -171,7 +171,7 @@ void MbD::System::partsJointsMotionsLimitsForcesTorquesDo(const std::functionbegin(), forcesTorques->end(), f); } -void System::logString(std::string& str) +void System::logString(const std::string& str) { externalSystem->logString(str); } diff --git a/OndselSolver/System.h b/OndselSolver/System.h index 19aa1a2..a68f651 100644 --- a/OndselSolver/System.h +++ b/OndselSolver/System.h @@ -38,7 +38,7 @@ namespace MbD { //ToDo: Needed members admSystem namedItems mbdTime parts jointsMotions forcesTorques sensors variables hasChanged mbdSystemSolver public: System(); - System(const char* str); + System(const std::string& str); System* root() override; void initialize() override; void initializeLocally() override; @@ -53,7 +53,7 @@ namespace MbD { void partsJointsMotionsForcesTorquesDo(const std::function )>& f); void partsJointsMotionsLimitsForcesTorquesDo(const std::function )>& f); void partsJointsMotionsLimitsDo(const std::function )>& f); - void logString(std::string& str) override; + void logString(const std::string& str) override; double mbdTimeValue(); void mbdTimeValue(double t); std::shared_ptr>> essentialConstraints(); diff --git a/OndselSolver/SystemSolver.cpp b/OndselSolver/SystemSolver.cpp index a64897e..c5b0e01 100644 --- a/OndselSolver/SystemSolver.cpp +++ b/OndselSolver/SystemSolver.cpp @@ -255,7 +255,7 @@ void SystemSolver::partsJointsMotionsDo(const std::functionpartsJointsMotionsDo(f); } -void SystemSolver::logString(std::string& str) +void SystemSolver::logString(const std::string& str) { system->logString(str); } diff --git a/OndselSolver/SystemSolver.h b/OndselSolver/SystemSolver.h index e409290..74988d3 100644 --- a/OndselSolver/SystemSolver.h +++ b/OndselSolver/SystemSolver.h @@ -60,7 +60,7 @@ namespace MbD { void runPosICKine(); void runVelICKine(); void runAccICKine(); - void logString(std::string& str) override; + void logString(const std::string& str) override; std::shared_ptr>> parts(); std::shared_ptr>> limits(); //std::shared_ptr> contactEndFrames(); diff --git a/OndselSolver/Time.cpp b/OndselSolver/Time.cpp index fac3ea5..6dae9b0 100644 --- a/OndselSolver/Time.cpp +++ b/OndselSolver/Time.cpp @@ -6,7 +6,7 @@ * See LICENSE file for details about copyright. * ***************************************************************************/ -#include "Time.h" +#include "SymTime.h" using namespace MbD; diff --git a/OndselSolver/Translation.cpp b/OndselSolver/Translation.cpp index ff58ceb..d4f01f1 100644 --- a/OndselSolver/Translation.cpp +++ b/OndselSolver/Translation.cpp @@ -16,7 +16,7 @@ MbD::Translation::Translation() { } -MbD::Translation::Translation(const char*) +MbD::Translation::Translation(const std::string&) { } diff --git a/OndselSolver/Translation.h b/OndselSolver/Translation.h index 6ea87f6..c7bd9ad 100644 --- a/OndselSolver/Translation.h +++ b/OndselSolver/Translation.h @@ -16,7 +16,7 @@ namespace MbD { // public: Translation(); - Translation(const char* str); + Translation(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/TranslationalJoint.cpp b/OndselSolver/TranslationalJoint.cpp index ee9832c..ddfa3e8 100644 --- a/OndselSolver/TranslationalJoint.cpp +++ b/OndselSolver/TranslationalJoint.cpp @@ -18,7 +18,7 @@ MbD::TranslationalJoint::TranslationalJoint() { } -MbD::TranslationalJoint::TranslationalJoint(const char* str) : InLineJoint(str) +MbD::TranslationalJoint::TranslationalJoint(const std::string& str) : InLineJoint(str) { } diff --git a/OndselSolver/TranslationalJoint.h b/OndselSolver/TranslationalJoint.h index e772bec..bdccab7 100644 --- a/OndselSolver/TranslationalJoint.h +++ b/OndselSolver/TranslationalJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: TranslationalJoint(); - TranslationalJoint(const char* str); + TranslationalJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/UniversalJoint.cpp b/OndselSolver/UniversalJoint.cpp index d10324c..775b868 100644 --- a/OndselSolver/UniversalJoint.cpp +++ b/OndselSolver/UniversalJoint.cpp @@ -16,7 +16,7 @@ MbD::UniversalJoint::UniversalJoint() { } -MbD::UniversalJoint::UniversalJoint(const char* str) : AtPointJoint(str) +MbD::UniversalJoint::UniversalJoint(const std::string& str) : AtPointJoint(str) { } diff --git a/OndselSolver/UniversalJoint.h b/OndselSolver/UniversalJoint.h index 62d2a66..4f756af 100644 --- a/OndselSolver/UniversalJoint.h +++ b/OndselSolver/UniversalJoint.h @@ -16,7 +16,7 @@ namespace MbD { // public: UniversalJoint(); - UniversalJoint(const char* str); + UniversalJoint(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolver/Variable.cpp b/OndselSolver/Variable.cpp index b3f8afc..d0e6d5c 100644 --- a/OndselSolver/Variable.cpp +++ b/OndselSolver/Variable.cpp @@ -15,7 +15,7 @@ Variable::Variable() value = 0.0; } -Variable::Variable(const char* str) : name(str) +Variable::Variable(const std::string& str) : name(str) { value = 0.0; } @@ -28,7 +28,7 @@ void Variable::initialize() { } -void Variable::setName(std::string str) +void Variable::setName(const std::string& str) { name = str; } diff --git a/OndselSolver/Variable.h b/OndselSolver/Variable.h index a5b8851..f2c519f 100644 --- a/OndselSolver/Variable.h +++ b/OndselSolver/Variable.h @@ -17,10 +17,10 @@ namespace MbD { //name value public: Variable(); - Variable(const char* str); + Variable(const std::string& str); Variable(double val); void initialize() override; - void setName(std::string str); + void setName(const std::string& str); const std::string& getName() const; double getValue() override; std::ostream& printOn(std::ostream& s) const override; diff --git a/OndselSolver/VelKineSolver.cpp b/OndselSolver/VelKineSolver.cpp index 422e0a9..38890e8 100644 --- a/OndselSolver/VelKineSolver.cpp +++ b/OndselSolver/VelKineSolver.cpp @@ -49,7 +49,7 @@ void VelKineSolver::assignEquationNumbers() void VelKineSolver::run() { - system->Solver::logString("MbD: Solving for kinematic velocity."); + system->logString("MbD: Solving for kinematic velocity."); system->partsJointsMotionsLimitsDo([](std::shared_ptr item) { item->preVelIC(); }); this->assignEquationNumbers(); system->partsJointsMotionsLimitsDo([](std::shared_ptr item) { item->useEquationNumbers(); }); diff --git a/OndselSolver/ZRotation.cpp b/OndselSolver/ZRotation.cpp index a45652d..3d4cdd7 100644 --- a/OndselSolver/ZRotation.cpp +++ b/OndselSolver/ZRotation.cpp @@ -20,7 +20,7 @@ ZRotation::ZRotation() { } -ZRotation::ZRotation(const char* str) : PrescribedMotion(str) { +ZRotation::ZRotation(const std::string& str) : PrescribedMotion(str) { } diff --git a/OndselSolver/ZRotation.h b/OndselSolver/ZRotation.h index 64f23c2..6a746f6 100644 --- a/OndselSolver/ZRotation.h +++ b/OndselSolver/ZRotation.h @@ -16,7 +16,7 @@ namespace MbD { // public: ZRotation(); - ZRotation(const char* str); + ZRotation(const std::string& str); void initializeGlobally() override; }; } diff --git a/OndselSolver/ZTranslation.cpp b/OndselSolver/ZTranslation.cpp index 7686a17..f3efae1 100644 --- a/OndselSolver/ZTranslation.cpp +++ b/OndselSolver/ZTranslation.cpp @@ -16,7 +16,7 @@ MbD::ZTranslation::ZTranslation() { } -MbD::ZTranslation::ZTranslation(const char*) +MbD::ZTranslation::ZTranslation(const std::string&) { } diff --git a/OndselSolver/ZTranslation.h b/OndselSolver/ZTranslation.h index 8f2a211..cd83af3 100644 --- a/OndselSolver/ZTranslation.h +++ b/OndselSolver/ZTranslation.h @@ -16,7 +16,7 @@ namespace MbD { // public: ZTranslation(); - ZTranslation(const char* str); + ZTranslation(const std::string& str); void initializeGlobally() override; }; diff --git a/OndselSolverMain/OndselSolver.cpp b/OndselSolverMain/OndselSolver.cpp index 1eac311..d4b82d9 100644 --- a/OndselSolverMain/OndselSolver.cpp +++ b/OndselSolverMain/OndselSolver.cpp @@ -20,7 +20,6 @@ #include "../OndselSolver/MomentOfInertiaSolver.h" using namespace MbD; -void runSpMat(); void sharedptrTest(); int main() @@ -30,44 +29,43 @@ int main() //auto assembly = ASMTAssembly::assemblyFromFile("C:/Users/askoh/OneDrive/askoh/visualstudio/Ondsel/OndselFreeCAD/build/src/Main/runPreDrag.asmt"); //assembly->runDraggingLog("C:/Users/askoh/OneDrive/askoh/visualstudio/Ondsel/OndselFreeCAD/build/src/Main/dragging.log"); //return 0; - auto assembly = ASMTAssembly::assemblyFromFile("../../testapp/runPreDragBackhoe3.asmt"); - assembly->runDraggingLog("../../testapp/draggingBackhoe3.log"); + auto assembly = ASMTAssembly::assemblyFromFile(std::string(TEST_DATA_PATH) + "/runPreDragBackhoe3.asmt"); + assembly->runDraggingLog(std::string(TEST_DATA_PATH) + "/draggingBackhoe3.log"); //return 0; ASMTAssembly::runDraggingLogTest3(); ASMTAssembly::runDraggingLogTest2(); ASMTAssembly::runDraggingLogTest(); - ASMTAssembly::runFile("../../testapp/pistonAllowZRotation.asmt"); - ASMTAssembly::runFile("../../testapp/Schmidt_Coupling_Ass_1-1.asmt"); - ASMTAssembly::runFile("../../testapp/RevRevJt.asmt"); - ASMTAssembly::runFile("../../testapp/RevCylJt.asmt"); - ASMTAssembly::runFile("../../testapp/CylSphJt.asmt"); - ASMTAssembly::runFile("../../testapp/SphSphJt.asmt"); - ASMTAssembly::readWriteFile("../../testapp/Gears.asmt"); - ASMTAssembly::readWriteFile("../../testapp/anglejoint.asmt"); - ASMTAssembly::readWriteFile("../../testapp/constvel.asmt"); - ASMTAssembly::readWriteFile("../../testapp/rackscrew.asmt"); - ASMTAssembly::readWriteFile("../../testapp/planarbug.asmt"); - ASMTAssembly::runFile("../../testapp/cirpendu2.asmt"); //Under constrained. Testing ICKine. - ASMTAssembly::runFile("../../testapp/quasikine.asmt"); //Under constrained. Testing ICKine. - ASMTAssembly::readWriteFile("../../testapp/piston.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/pistonAllowZRotation.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/Schmidt_Coupling_Ass_1-1.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/RevRevJt.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/RevCylJt.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/CylSphJt.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/SphSphJt.asmt"); + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/Gears.asmt"); + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/anglejoint.asmt"); + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/constvel.asmt"); + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/rackscrew.asmt"); + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/planarbug.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/cirpendu2.asmt"); //Under constrained. Testing ICKine. + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/quasikine.asmt"); //Under constrained. Testing ICKine. + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/piston.asmt"); ////ASMTAssembly::runSinglePendulumSuperSimplified(); //Mass is missing ////ASMTAssembly::runSinglePendulumSuperSimplified2(); //DOF has infinite acceleration due to zero mass and inertias ASMTAssembly::runSinglePendulumSimplified(); ASMTAssembly::runSinglePendulum(); - ASMTAssembly::runFile("../../testapp/piston.asmt"); - ASMTAssembly::runFile("../../testapp/00backhoe.asmt"); - //ASMTAssembly::runFile("../../testapp/circular.asmt"); //Needs checking - //ASMTAssembly::runFile("../../testapp/engine1.asmt"); //Needs checking - ASMTAssembly::runFile("../../testapp/fourbar.asmt"); - //ASMTAssembly::runFile("../../testapp/fourbot.asmt"); //Very large but works - ASMTAssembly::runFile("../../testapp/wobpump.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/piston.asmt"); + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/00backhoe.asmt"); + //ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/circular.asmt"); //Needs checking + //ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/engine1.asmt"); //Needs checking + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/fourbar.asmt"); + //ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/fourbot.asmt"); //Very large but works + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/wobpump.asmt"); auto cadSystem = std::make_shared(); cadSystem->runOndselSinglePendulum(); cadSystem->runOndselDoublePendulum(); //cadSystem->runOndselPiston(); //For debugging cadSystem->runPiston(); - runSpMat(); MomentOfInertiaSolver::example1(); sharedptrTest(); } @@ -88,20 +86,3 @@ void sharedptrTest() { assert(assm->constantGravity == assm2->constantGravity); //constantGravity is same object pointed to assert(&(assm->constantGravity) != &(assm2->constantGravity)); //Different shared_ptrs of same reference counter } -void runSpMat() { - auto spMat = std::make_shared>(3, 3); - spMat->atijput(0, 0, 1.0); - spMat->atijput(0, 1, 1.0); - spMat->atijput(1, 0, 1.0); - spMat->atijput(1, 1, 1.0); - spMat->atijput(1, 2, 1.0); - spMat->atijput(2, 1, 1.0); - spMat->atijput(2, 2, 1.0); - auto fullCol = std::make_shared>(3); - fullCol->atiput(0, 1.0); - fullCol->atiput(1, 2.0); - fullCol->atiput(2, 3.0); - auto matSolver = CREATE::With(); - auto answer = matSolver->solvewithsaveOriginal(spMat, fullCol, true); - auto aAx = spMat->timesFullColumn(answer); -} diff --git a/testapp/draggingBackhoe.log b/testapp/draggingBackhoe1.log similarity index 100% rename from testapp/draggingBackhoe.log rename to testapp/draggingBackhoe1.log diff --git a/testapp/runPreDragBackhoe.asmt b/testapp/runPreDragBackhoe1.asmt similarity index 100% rename from testapp/runPreDragBackhoe.asmt rename to testapp/runPreDragBackhoe1.asmt diff --git a/tests/test.cpp b/tests/test.cpp index e4fb01c..642dd90 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -1,7 +1,8 @@ #include "pch.h" -#include #include #include +#include +#include using namespace MbD; @@ -16,8 +17,156 @@ TEST(OndselSolver, runOndselSinglePendulum) { //std::string output = testing::internal::GetCapturedStdout(); EXPECT_TRUE(true); } +TEST(OndselSolver, runPreDragBackhoe1) { + auto assembly = ASMTAssembly::assemblyFromFile(std::string(TEST_DATA_PATH) + "/runPreDragBackhoe1.asmt"); + assembly->runDraggingLog(std::string(TEST_DATA_PATH) + "/draggingBackhoe1.log"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, runPreDragBackhoe2) { + auto assembly = ASMTAssembly::assemblyFromFile(std::string(TEST_DATA_PATH) + "/runPreDragBackhoe2.asmt"); + assembly->runDraggingLog(std::string(TEST_DATA_PATH) + "/draggingBackhoe2.log"); + EXPECT_TRUE(true); +} TEST(OndselSolver, runPreDragBackhoe3) { - auto assembly = ASMTAssembly::assemblyFromFile("../../../testapp/runPreDragBackhoe3.asmt"); - assembly->runDraggingLog("../../../testapp/draggingBackhoe3.log"); + auto assembly = ASMTAssembly::assemblyFromFile(std::string(TEST_DATA_PATH) + "/runPreDragBackhoe3.asmt"); + assembly->runDraggingLog(std::string(TEST_DATA_PATH) + "/draggingBackhoe3.log"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, pistonAllowZRotation) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/pistonAllowZRotation.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, RevRevJt) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/RevRevJt.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, RevCylJt) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/RevCylJt.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, CylSphJt) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/CylSphJt.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, SphSphJt) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/SphSphJt.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, Gears) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/Gears.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, anglejoint) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/anglejoint.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, constvel) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/constvel.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, rackscrew) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/rackscrew.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, planarbug) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/planarbug.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, cirpendu2) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/cirpendu2.asmt"); //Under constrained. Testing ICKine. + EXPECT_TRUE(true); +} +TEST(OndselSolver, quasikine) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/quasikine.asmt"); //Under constrained. Testing ICKine. + EXPECT_TRUE(true); +} +TEST(OndselSolver, piston) { + ASMTAssembly::readWriteFile(std::string(TEST_DATA_PATH) + "/piston.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, runSinglePendulumSuperSimplified) { + ASMTAssembly::runSinglePendulumSuperSimplified(); //Mass is missing + EXPECT_TRUE(true); +} +TEST(OndselSolver, runSinglePendulumSuperSimplified2) { + ASMTAssembly::runSinglePendulumSuperSimplified2(); //DOF has infinite acceleration due to zero mass and inertias + EXPECT_TRUE(true); +} +TEST(OndselSolver, runSinglePendulumSimplified) { + ASMTAssembly::runSinglePendulumSimplified(); EXPECT_TRUE(true); -} \ No newline at end of file +} +TEST(OndselSolver, runSinglePendulum) { + ASMTAssembly::runSinglePendulum(); + EXPECT_TRUE(true); +} +TEST(OndselSolver, piston2) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/piston.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, 00backhoe) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/00backhoe.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, circular) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/circular.asmt"); //Needs checking + EXPECT_TRUE(true); +} +TEST(OndselSolver, engine1) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/engine1.asmt"); //Needs checking + EXPECT_TRUE(true); +} +TEST(OndselSolver, fourbar) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/fourbar.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, fourbot) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/fourbot.asmt"); //Very large but works + EXPECT_TRUE(true); +} +TEST(OndselSolver, wobpump) { + ASMTAssembly::runFile(std::string(TEST_DATA_PATH) + "/wobpump.asmt"); + EXPECT_TRUE(true); +} +TEST(OndselSolver, runOndselDoublePendulum) { + auto cadSystem = std::make_shared(); + cadSystem->runOndselDoublePendulum(); + EXPECT_TRUE(true); +} +TEST(OndselSolver, runOndselPiston) { + auto cadSystem = std::make_shared(); + cadSystem->runOndselPiston(); //For debugging + EXPECT_TRUE(true); +} +TEST(OndselSolver, runPiston) { + auto cadSystem = std::make_shared(); + cadSystem->runPiston(); + EXPECT_TRUE(true); +} +TEST(OndselSolver, GESpMatParPvPrecise) { + GESpMatParPvPrecise::runSpMat(); + EXPECT_TRUE(true); +} +TEST(OndselSolver, MomentOfInertiaSolver) { + MomentOfInertiaSolver::example1(); + EXPECT_TRUE(true); +} +TEST(OndselSolver, sharedptrTest) { + auto assm = ASMTAssembly::With(); + + std::shared_ptr assm1 = assm; //New shared_ptr to old object. Reference count incremented. + assert(assm == assm1); + assert(assm.get() == assm1.get()); + assert(&assm != &assm1); + assert(assm->constantGravity == assm1->constantGravity); + assert(&(assm->constantGravity) == &(assm1->constantGravity)); + + auto assm2 = std::make_shared(*assm); //New shared_ptr to new object. Member variables copy old member variables + assert(assm != assm2); + assert(assm.get() != assm2.get()); + assert(&assm != &assm2); + assert(assm->constantGravity == assm2->constantGravity); //constantGravity is same object pointed to + assert(&(assm->constantGravity) != &(assm2->constantGravity)); //Different shared_ptrs of same reference counter + EXPECT_TRUE(true); +} +