diff --git a/MbDCode/ASMTAssembly.cpp b/MbDCode/ASMTAssembly.cpp index 998f559..a164799 100644 --- a/MbDCode/ASMTAssembly.cpp +++ b/MbDCode/ASMTAssembly.cpp @@ -43,6 +43,100 @@ using namespace MbD; + +void MbD::ASMTAssembly::runSinglePendulumSimplified() +{ + auto assembly = CREATE::With(); + + assembly->setNotes(""); + assembly->setName("Assembly1"); + assembly->setPosition3D(0, 0, 0); + assembly->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + assembly->setVelocity3D(0, 0, 0); + assembly->setOmega3D(0, 0, 0); + + auto massMarker = CREATE::With(); + massMarker->setMass(0.0); + massMarker->setDensity(0.0); + massMarker->setMomentOfInertias(0, 0, 0); + massMarker->setPosition3D(0, 0, 0); + massMarker->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + assembly->setPrincipalMassMarker(massMarker); + + auto mkr = CREATE::With(); + mkr->setName("Marker1"); + mkr->setPosition3D(0, 0, 0); + massMarker->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + assembly->addMarker(mkr); + + auto part = CREATE::With(); + part->setName("Part1"); + part->setPosition3D(-0.1, -0.1, -0.1); + part->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + part->setVelocity3D(0, 0, 0); + part->setOmega3D(0, 0, 0); + assembly->addPart(part); + + massMarker = CREATE::With(); + massMarker->setMass(0.2); + massMarker->setDensity(10.0); + massMarker->setMomentOfInertias(8.3333333333333e-4, 0.016833333333333, 0.017333333333333); + massMarker->setPosition3D(0.5, 0.1, 0.05); + massMarker->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + part->setPrincipalMassMarker(massMarker); + + mkr = CREATE::With(); + mkr->setName("Marker1"); + mkr->setPosition3D(0.1, 0.1, 0.1); + mkr->setRotationMatrix( + 1, 0, 0, + 0, 1, 0, + 0, 0, 1); + part->addMarker(mkr); + + auto joint = CREATE::With(); + joint->setName("Joint1"); + joint->setMarkerI("/Assembly1/Marker1"); + joint->setMarkerJ("/Assembly1/Part1/Marker1"); + assembly->addJoint(joint); + + auto motion = CREATE::With(); + motion->setName("Motion1"); + motion->setMotionJoint("/Assembly1/Joint1"); + motion->setRotationZ("0.0"); + assembly->addMotion(motion); + + auto constantGravity = CREATE::With(); + constantGravity->setg(0.0, 0.0, 0.0); + assembly->setConstantGravity(constantGravity); + + auto simulationParameters = CREATE::With(); + simulationParameters->settstart(0.0); + simulationParameters->settend(0.0); //tstart == tend Initial Conditions only. + simulationParameters->sethmin(1.0e-9); + simulationParameters->sethmax(1.0); + simulationParameters->sethout(0.04); + simulationParameters->seterrorTol(1.0e-6); + assembly->setSimulationParameters(simulationParameters); + + assembly->runKINEMATIC(); +} + void MbD::ASMTAssembly::runSinglePendulum() { auto assembly = CREATE::With(); @@ -205,7 +299,7 @@ ASMTAssembly* MbD::ASMTAssembly::root() return this; } -void MbD::ASMTAssembly::setNotes(std::string& str) +void MbD::ASMTAssembly::setNotes(std::string str) { notes = str; } diff --git a/MbDCode/ASMTAssembly.h b/MbDCode/ASMTAssembly.h index b9a0b32..ed78413 100644 --- a/MbDCode/ASMTAssembly.h +++ b/MbDCode/ASMTAssembly.h @@ -35,11 +35,12 @@ namespace MbD { { // public: + static void runSinglePendulumSimplified(); static void runSinglePendulum(); static void runFile(const char* chars); void initialize() override; ASMTAssembly* root() override; - void setNotes(std::string& str); + void setNotes(std::string str); void parseASMT(std::vector& lines) override; void readNotes(std::vector& lines); void readParts(std::vector& lines); diff --git a/MbDCode/ASMTConstantGravity.cpp b/MbDCode/ASMTConstantGravity.cpp index 0183bc0..181ffd1 100644 --- a/MbDCode/ASMTConstantGravity.cpp +++ b/MbDCode/ASMTConstantGravity.cpp @@ -33,3 +33,8 @@ void MbD::ASMTConstantGravity::setg(FColDsptr gravity) { g = gravity; } + +void MbD::ASMTConstantGravity::setg(double a, double b, double c) +{ + g = std::make_shared>(ListD{ a, b, c }); +} diff --git a/MbDCode/ASMTConstantGravity.h b/MbDCode/ASMTConstantGravity.h index bfd4a16..cc6f995 100644 --- a/MbDCode/ASMTConstantGravity.h +++ b/MbDCode/ASMTConstantGravity.h @@ -23,6 +23,8 @@ namespace MbD { void createMbD(std::shared_ptr mbdSys, std::shared_ptr mbdUnits) override; void setg(FColDsptr g); + void setg(double a, double b, double c); + FColDsptr g; }; } diff --git a/MbDCode/ASMTItem.cpp b/MbDCode/ASMTItem.cpp index 744ecd9..5739233 100644 --- a/MbDCode/ASMTItem.cpp +++ b/MbDCode/ASMTItem.cpp @@ -28,7 +28,7 @@ void MbD::ASMTItem::initialize() { } -void MbD::ASMTItem::setName(std::string& str) +void MbD::ASMTItem::setName(std::string str) { name = str; } diff --git a/MbDCode/ASMTItem.h b/MbDCode/ASMTItem.h index 36a346e..060dc5f 100644 --- a/MbDCode/ASMTItem.h +++ b/MbDCode/ASMTItem.h @@ -22,7 +22,7 @@ namespace MbD { virtual std::shared_ptr part(); virtual void initialize(); - void setName(std::string& str); + void setName(std::string str); virtual void parseASMT(std::vector& lines); FRowDsptr readRowOfDoubles(std::string& line); FColDsptr readColumnOfDoubles(std::string& line); diff --git a/MbDCode/ASMTItemIJ.cpp b/MbDCode/ASMTItemIJ.cpp index f35a7b0..62f3571 100644 --- a/MbDCode/ASMTItemIJ.cpp +++ b/MbDCode/ASMTItemIJ.cpp @@ -18,12 +18,12 @@ void MbD::ASMTItemIJ::initialize() tzs = std::make_shared>(); } -void MbD::ASMTItemIJ::setMarkerI(std::string& mkrI) +void MbD::ASMTItemIJ::setMarkerI(std::string mkrI) { markerI = mkrI; } -void MbD::ASMTItemIJ::setMarkerJ(std::string& mkrJ) +void MbD::ASMTItemIJ::setMarkerJ(std::string mkrJ) { markerJ = mkrJ; } diff --git a/MbDCode/ASMTItemIJ.h b/MbDCode/ASMTItemIJ.h index 76b53bc..7d33fa6 100644 --- a/MbDCode/ASMTItemIJ.h +++ b/MbDCode/ASMTItemIJ.h @@ -16,8 +16,8 @@ namespace MbD { // public: void initialize() override; - void setMarkerI(std::string& mkrI); - void setMarkerJ(std::string& mkrJ); + void setMarkerI(std::string mkrI); + void setMarkerJ(std::string mkrJ); void readMarkerI(std::vector& lines); void readMarkerJ(std::vector& lines); void readFXonIs(std::vector& lines); diff --git a/MbDCode/ASMTPrincipalMassMarker.cpp b/MbDCode/ASMTPrincipalMassMarker.cpp index 4eeffe4..80b1406 100644 --- a/MbDCode/ASMTPrincipalMassMarker.cpp +++ b/MbDCode/ASMTPrincipalMassMarker.cpp @@ -66,3 +66,9 @@ void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(DiagMatDsptr mat) { momentOfInertias = mat; } + +// Overloads to simplify syntax. +void MbD::ASMTPrincipalMassMarker::setMomentOfInertias(double a, double b, double c) +{ + momentOfInertias = std::make_shared>(ListD{ a, b, c }); +} diff --git a/MbDCode/ASMTPrincipalMassMarker.h b/MbDCode/ASMTPrincipalMassMarker.h index 56349f7..726c3ca 100644 --- a/MbDCode/ASMTPrincipalMassMarker.h +++ b/MbDCode/ASMTPrincipalMassMarker.h @@ -20,6 +20,9 @@ namespace MbD { void setDensity(double density); void setMomentOfInertias(DiagMatDsptr momentOfInertias); + // Overloads to simplify syntax. + void setMomentOfInertias(double a, double b, double c); + double mass, density; DiagMatDsptr momentOfInertias; diff --git a/MbDCode/ASMTRotationalMotion.cpp b/MbDCode/ASMTRotationalMotion.cpp index 45ed977..bf0014a 100644 --- a/MbDCode/ASMTRotationalMotion.cpp +++ b/MbDCode/ASMTRotationalMotion.cpp @@ -67,12 +67,12 @@ std::shared_ptr MbD::ASMTRotationalMotion::mbdClassNew() return CREATE::With(); } -void MbD::ASMTRotationalMotion::setMotionJoint(std::string& str) +void MbD::ASMTRotationalMotion::setMotionJoint(std::string str) { motionJoint = str; } -void MbD::ASMTRotationalMotion::setRotationZ(std::string& rotZ) +void MbD::ASMTRotationalMotion::setRotationZ(std::string rotZ) { rotationZ = rotZ; } diff --git a/MbDCode/ASMTRotationalMotion.h b/MbDCode/ASMTRotationalMotion.h index 3f969c3..1b36204 100644 --- a/MbDCode/ASMTRotationalMotion.h +++ b/MbDCode/ASMTRotationalMotion.h @@ -22,8 +22,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(std::string motionJoint); + void setRotationZ(std::string rotZ); std::string motionJoint, rotationZ; }; diff --git a/MbDCode/ASMTSpatialItem.cpp b/MbDCode/ASMTSpatialItem.cpp index 6832a6c..888d431 100644 --- a/MbDCode/ASMTSpatialItem.cpp +++ b/MbDCode/ASMTSpatialItem.cpp @@ -85,3 +85,31 @@ void MbD::ASMTSpatialItem::readOmega3D(std::vector& lines) } lines.erase(lines.begin()); } + + +// Overloads to simplify syntax. +void MbD::ASMTSpatialItem::setPosition3D(double a, double b, double c) +{ + position3D = std::make_shared>(ListD{ a, b, c }); +} + +void MbD::ASMTSpatialItem::setVelocity3D(double a, double b, double c) +{ + velocity3D = std::make_shared>(ListD{ a, b, c }); +} + +void MbD::ASMTSpatialItem::setOmega3D(double a, double b, double c) +{ + omega3D = std::make_shared>(ListD{ a, b, c }); +} + +void MbD::ASMTSpatialItem::setRotationMatrix(double v11, double v12, double v13, + double v21, double v22, double v23, + double v31, double v32, double v33) +{ + rotationMatrix = std::make_shared>(ListListD{ + { v11, v12, v13 }, + { v21, v22, v23 }, + { v31, v32, v33 } + }); +} \ No newline at end of file diff --git a/MbDCode/ASMTSpatialItem.h b/MbDCode/ASMTSpatialItem.h index 77abab9..ac5fe64 100644 --- a/MbDCode/ASMTSpatialItem.h +++ b/MbDCode/ASMTSpatialItem.h @@ -33,6 +33,13 @@ namespace MbD { { 0, 0, 1 } }); + // Overloads to simplify syntax. + void setPosition3D(double a, double b, double c); + void setVelocity3D(double a, double b, double c); + void setOmega3D(double a, double b, double c); + void setRotationMatrix(double v11, double v12, double v13, + double v21, double v22, double v23, + double v31, double v32, double v33); }; }