Implement Limits

This commit is contained in:
Aik-Siong Koh
2024-04-02 14:30:25 -06:00
committed by PaddleStroke
parent 3a9e7cecab
commit ad4a563b42
184 changed files with 7716 additions and 6083 deletions

View File

@@ -50,7 +50,7 @@ void MbD::ASMTAllowRotation::initMarkers()
}
}
std::shared_ptr<Joint> MbD::ASMTAllowRotation::mbdClassNew()
std::shared_ptr<ItemIJ> MbD::ASMTAllowRotation::mbdClassNew()
{
return AllowZRotation::With();
}

View File

@@ -19,7 +19,7 @@ namespace MbD {
void parseASMT(std::vector<std::string>& lines) override;
void readMotionJoint(std::vector<std::string>& lines);
void initMarkers() override;
std::shared_ptr<Joint> mbdClassNew() override;
std::shared_ptr<ItemIJ> mbdClassNew() override;
void setMotionJoint(std::string motionJoint);
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTAngleJoint::mbdClassNew()
std::shared_ptr<ASMTAngleJoint> MbD::ASMTAngleJoint::With()
{
auto asmt = std::make_shared<ASMTAngleJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTAngleJoint::mbdClassNew()
{
return CREATE<AngleJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTAngleJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readTheIzJz(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;

View File

@@ -10,6 +10,13 @@
using namespace MbD;
std::shared_ptr<ASMTAnimationParameters> MbD::ASMTAnimationParameters::With()
{
auto asmt = std::make_shared<ASMTAnimationParameters>();
asmt->initialize();
return asmt;
}
void MbD::ASMTAnimationParameters::parseASMT(std::vector<std::string>& lines)
{
//size_t nframe, icurrent, istart, iend, framesPerSecond;

View File

@@ -15,6 +15,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTAnimationParameters> With();
void parseASMT(std::vector<std::string>& lines) override;
void storeOnLevel(std::ofstream& os, size_t level) override;

View File

@@ -58,6 +58,9 @@
#include "ExternalSystem.h"
#include "SystemSolver.h"
#include "ASMTRevRevJoint.h"
#include "ASMTLimit.h"
#include "ASMTRotationLimit.h"
#include "ASMTTranslationLimit.h"
using namespace MbD;
@@ -68,8 +71,9 @@ MbD::ASMTAssembly::ASMTAssembly() : ASMTSpatialContainer()
std::shared_ptr<ASMTAssembly> MbD::ASMTAssembly::With()
{
auto assembly = std::make_shared<ASMTAssembly>();
return assembly;
auto asmt = std::make_shared<ASMTAssembly>();
asmt->initialize();
return asmt;
}
void MbD::ASMTAssembly::runSinglePendulumSuperSimplified()
@@ -183,7 +187,7 @@ void MbD::ASMTAssembly::runSinglePendulumSimplified()
assembly->setVelocity3D(0, 0, 0);
assembly->setOmega3D(0, 0, 0);
auto massMarker = std::make_shared<ASMTPrincipalMassMarker>();
auto massMarker = ASMTPrincipalMassMarker::With();
massMarker->setMass(0.0);
massMarker->setDensity(0.0);
massMarker->setMomentOfInertias(0, 0, 0);
@@ -214,7 +218,7 @@ void MbD::ASMTAssembly::runSinglePendulumSimplified()
part->setOmega3D(0, 0, 0);
assembly->addPart(part);
massMarker = std::make_shared<ASMTPrincipalMassMarker>();
massMarker = ASMTPrincipalMassMarker::With();
massMarker->setMass(0.2);
massMarker->setDensity(10.0);
massMarker->setMomentOfInertias(8.3333333333333e-4, 0.016833333333333, 0.017333333333333);
@@ -282,7 +286,7 @@ void MbD::ASMTAssembly::runSinglePendulum()
auto ome3D = std::make_shared<FullColumn<double>>(ListD{ 0, 0, 0 });
assembly->setOmega3D(ome3D);
//
auto massMarker = std::make_shared<ASMTPrincipalMassMarker>();
auto massMarker = ASMTPrincipalMassMarker::With();
massMarker->setMass(0.0);
massMarker->setDensity(0.0);
auto aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 0, 0, 0 });
@@ -327,7 +331,7 @@ void MbD::ASMTAssembly::runSinglePendulum()
part->setOmega3D(ome3D);
assembly->addPart(part);
//
massMarker = std::make_shared<ASMTPrincipalMassMarker>();
massMarker = ASMTPrincipalMassMarker::With();
massMarker->setMass(0.2);
massMarker->setDensity(10.0);
aJ = std::make_shared<DiagonalMatrix<double>>(ListD{ 8.3333333333333e-4, 0.016833333333333, 0.017333333333333 });
@@ -439,7 +443,27 @@ void MbD::ASMTAssembly::runFile(const char* fileName)
void MbD::ASMTAssembly::runDraggingTest()
{
//auto assembly = ASMTAssembly::assemblyFromFile("../testapp/pistonWithLimits.asmt");
auto assembly = ASMTAssembly::assemblyFromFile("../testapp/dragCrankSlider.asmt");
auto limit1 = ASMTRotationLimit::With();
limit1->setName("Limit1");
limit1->setMarkerI("/Assembly1/Marker2");
limit1->setMarkerJ("/Assembly1/Part1/Marker1");
limit1->settype("=>");
limit1->setlimit("30.0*pi/180.0");
limit1->settol("1.0e-9");
assembly->addLimit(limit1);
auto limit2 = ASMTTranslationLimit::With();
limit2->setName("Limit2");
limit2->setMarkerI("/Assembly1/Part3/Marker2");
limit2->setMarkerJ("/Assembly1/Marker1");
limit2->settype("=<");
limit2->setlimit("1.2");
limit2->settol("1.0e-9");
assembly->addLimit(limit2);
auto& dragPart = assembly->parts->at(0);
auto dragParts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
dragParts->push_back(dragPart);
@@ -581,6 +605,7 @@ void MbD::ASMTAssembly::readConstraintSets(std::vector<std::string>& lines)
lines.erase(lines.begin());
readJoints(lines);
readMotions(lines);
readLimits(lines);
readGeneralConstraintSets(lines);
}
@@ -680,7 +705,10 @@ void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
assert(lines[0] == "\t\tMotions");
lines.erase(lines.begin());
motions->clear();
auto it = std::find(lines.begin(), lines.end(), "\t\tGeneralConstraintSets");
auto it = std::find(lines.begin(), lines.end(), "\t\tLimits");
if (it == lines.end()) {
it = std::find(lines.begin(), lines.end(), "\t\tGeneralConstraintSets");
}
std::vector<std::string> motionsLines(lines.begin(), it);
std::shared_ptr<ASMTMotion> motion;
while (!motionsLines.empty()) {
@@ -709,6 +737,33 @@ void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
}
void MbD::ASMTAssembly::readLimits(std::vector<std::string>& lines)
{
if (lines[0] != "\t\tLimits") return;
lines.erase(lines.begin());
limits->clear();
auto it = std::find(lines.begin(), lines.end(), "\t\tGeneralConstraintSets");
std::vector<std::string> limitsLines(lines.begin(), it);
std::shared_ptr<ASMTLimit> limit;
while (!limitsLines.empty()) {
if (limitsLines[0] == "\t\t\tRotationLimit") {
limit = ASMTRotationLimit::With();
}
else if (limitsLines[0] == "\t\t\tTranslationLimit") {
limit = ASMTTranslationLimit::With();
}
else {
assert(false);
}
limitsLines.erase(limitsLines.begin());
limit->parseASMT(limitsLines);
limits->push_back(limit);
limit->owner = this;
limit->initMarkers();
}
lines.erase(lines.begin(), it);
}
void MbD::ASMTAssembly::readGeneralConstraintSets(std::vector<std::string>& lines) const
{
assert(lines[0] == "\t\tGeneralConstraintSets");
@@ -1011,6 +1066,7 @@ void MbD::ASMTAssembly::deleteMbD()
for (auto& part : *parts) { part->deleteMbD(); }
for (auto& joint : *joints) { joint->deleteMbD(); }
for (auto& motion : *motions) { motion->deleteMbD(); }
for (auto& limit : *limits) { limit->deleteMbD(); }
for (auto& forceTorque : *forcesTorques) { forceTorque->deleteMbD(); }
@@ -1026,9 +1082,11 @@ void MbD::ASMTAssembly::createMbD(std::shared_ptr<System> mbdSys, std::shared_pt
jointsMotions->insert(jointsMotions->end(), joints->begin(), joints->end());
jointsMotions->insert(jointsMotions->end(), motions->begin(), motions->end());
std::sort(jointsMotions->begin(), jointsMotions->end(), [](std::shared_ptr<ASMTConstraintSet> a, std::shared_ptr<ASMTConstraintSet> b) { return a->name < b->name; });
std::sort(limits->begin(), limits->end(), [](std::shared_ptr<ASMTLimit> a, std::shared_ptr<ASMTLimit> b) { return a->name < b->name; });
std::sort(forcesTorques->begin(), forcesTorques->end(), [](std::shared_ptr<ASMTForceTorque> a, std::shared_ptr<ASMTForceTorque> b) { return a->name < b->name; });
for (auto& part : *parts) { part->createMbD(mbdSys, mbdUnits); }
for (auto& joint : *jointsMotions) { joint->createMbD(mbdSys, mbdUnits); }
for (auto& limit : *limits) { limit->createMbD(mbdSys, mbdUnits); }
for (auto& forceTorque : *forcesTorques) { forceTorque->createMbD(mbdSys, mbdUnits); }
auto& mbdSysSolver = mbdSys->systemSolver;
@@ -1138,7 +1196,7 @@ void MbD::ASMTAssembly::runKINEMATIC()
void MbD::ASMTAssembly::initprincipalMassMarker()
{
principalMassMarker = std::make_shared<ASMTPrincipalMassMarker>();
principalMassMarker = ASMTPrincipalMassMarker::With();
principalMassMarker->mass = 0.0;
principalMassMarker->density = 0.0;
principalMassMarker->momentOfInertias = std::make_shared<DiagonalMatrix<double>>(3, 0);
@@ -1264,6 +1322,13 @@ void MbD::ASMTAssembly::addMotion(std::shared_ptr<ASMTMotion> motion)
motion->initMarkers();
}
void MbD::ASMTAssembly::addLimit(std::shared_ptr<ASMTLimit> limit)
{
limits->push_back(limit);
limit->owner = this;
limit->initMarkers();
}
void MbD::ASMTAssembly::setConstantGravity(std::shared_ptr<ASMTConstantGravity> gravity)
{
constantGravity = gravity;

View File

@@ -24,6 +24,7 @@ namespace MbD {
class ASMTForceTorque;
class ASMTJoint;
class ASMTMotion;
class ASMTLimit;
class SystemSolver;
class ASMTItemIJ;
class MBDynSystem;
@@ -54,6 +55,7 @@ namespace MbD {
void readConstraintSets(std::vector<std::string>& lines);
void readJoints(std::vector<std::string>& lines);
void readMotions(std::vector<std::string>& lines);
void readLimits(std::vector<std::string>& lines);
void readGeneralConstraintSets(std::vector<std::string>& lines) const;
void readForcesTorques(std::vector<std::string>& lines);
void readConstantGravity(std::vector<std::string>& lines);
@@ -105,6 +107,7 @@ namespace MbD {
void addPart(std::shared_ptr<ASMTPart> part);
void addJoint(std::shared_ptr<ASMTJoint> joint);
void addMotion(std::shared_ptr<ASMTMotion> motion);
void addLimit(std::shared_ptr<ASMTLimit> limit);
void setConstantGravity(std::shared_ptr<ASMTConstantGravity> constantGravity);
void setSimulationParameters(std::shared_ptr<ASMTSimulationParameters> simulationParameters);
std::shared_ptr<ASMTPart> partNamed(std::string partName) const;
@@ -127,12 +130,13 @@ namespace MbD {
std::shared_ptr<std::vector<std::shared_ptr<ASMTConstraintSet>>> constraintSets = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTJoint>>> joints = std::make_shared<std::vector<std::shared_ptr<ASMTJoint>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTMotion>>> motions = std::make_shared<std::vector<std::shared_ptr<ASMTMotion>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTLimit>>> limits = std::make_shared<std::vector<std::shared_ptr<ASMTLimit>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTForceTorque>>> forcesTorques = std::make_shared<std::vector<std::shared_ptr<ASMTForceTorque>>>();
std::shared_ptr<ASMTConstantGravity> constantGravity = std::make_shared<ASMTConstantGravity>();
std::shared_ptr<ASMTSimulationParameters> simulationParameters = std::make_shared<ASMTSimulationParameters>();
std::shared_ptr<ASMTAnimationParameters> animationParameters = std::make_shared<ASMTAnimationParameters>();
std::shared_ptr<ASMTConstantGravity> constantGravity = ASMTConstantGravity::With();
std::shared_ptr<ASMTSimulationParameters> simulationParameters = ASMTSimulationParameters::With();
std::shared_ptr<ASMTAnimationParameters> animationParameters = ASMTAnimationParameters::With();
std::shared_ptr<std::vector<double>> times = std::make_shared<std::vector<double>>();
std::shared_ptr<ASMTTime> asmtTime = std::make_shared<ASMTTime>();
std::shared_ptr<ASMTTime> asmtTime = ASMTTime::With();
std::shared_ptr<Units> mbdUnits = std::make_shared<Units>();
std::shared_ptr<System> mbdSystem;
MBDynSystem* mbdynItem = nullptr;

View File

@@ -15,6 +15,13 @@
using namespace MbD;
std::shared_ptr<ASMTConstantGravity> MbD::ASMTConstantGravity::With()
{
auto asmt = std::make_shared<ASMTConstantGravity>();
asmt->initialize();
return asmt;
}
void MbD::ASMTConstantGravity::parseASMT(std::vector<std::string>& lines)
{
g = readColumnOfDoubles(lines[0]);

View File

@@ -19,6 +19,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTConstantGravity> With();
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
FColDsptr getg();

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTConstantVelocityJoint::mbdClassNew()
std::shared_ptr<ASMTConstantVelocityJoint> MbD::ASMTConstantVelocityJoint::With()
{
auto asmt = std::make_shared<ASMTConstantVelocityJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTConstantVelocityJoint::mbdClassNew()
{
return CREATE<ConstantVelocityJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTConstantVelocityJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -14,25 +14,6 @@
using namespace MbD;
void MbD::ASMTConstraintSet::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units>)
{
//self dataSeries : OrderedCollection new.
//self discontinuities : OrderedCollection new.
auto mbdJt = this->mbdClassNew();
mbdObject = mbdJt;
mbdJt->name = fullName("");
auto mrkI = std::static_pointer_cast<EndFramec>(root()->markerAt(markerI)->mbdObject);
auto mrkJ = std::static_pointer_cast<EndFramec>(root()->markerAt(markerJ)->mbdObject);
mbdJt->connectsItoJ(mrkI, mrkJ);
mbdSys->addJoint(mbdJt);
}
std::shared_ptr<Joint> MbD::ASMTConstraintSet::mbdClassNew()
{
assert(false);
return std::shared_ptr<Joint>();
}
void MbD::ASMTConstraintSet::updateFromMbD()
{
//"

View File

@@ -17,8 +17,6 @@ namespace MbD {
{
//
public:
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
virtual std::shared_ptr<Joint> mbdClassNew();
void updateFromMbD() override;
void compareResults(AnalysisType type) override;
void outputResults(AnalysisType type) override;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTCylSphJoint::mbdClassNew()
std::shared_ptr<ASMTCylSphJoint> MbD::ASMTCylSphJoint::With()
{
auto asmt = std::make_shared<ASMTCylSphJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTCylSphJoint::mbdClassNew()
{
return CREATE<CylSphJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTCylSphJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTCylindricalJoint::mbdClassNew()
std::shared_ptr<ASMTCylindricalJoint> MbD::ASMTCylindricalJoint::With()
{
auto asmt = std::make_shared<ASMTCylindricalJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTCylindricalJoint::mbdClassNew()
{
return CREATE<CylindricalJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTCylindricalJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTFixedJoint::mbdClassNew()
std::shared_ptr<ASMTFixedJoint> MbD::ASMTFixedJoint::With()
{
auto asmt = std::make_shared<ASMTFixedJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTFixedJoint::mbdClassNew()
{
return CREATE<FixedJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTFixedJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTGearJoint::mbdClassNew()
std::shared_ptr<ASMTGearJoint> MbD::ASMTGearJoint::With()
{
auto asmt = std::make_shared<ASMTGearJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTGearJoint::mbdClassNew()
{
return CREATE<GearJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTGearJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readRadiusI(std::vector<std::string>& lines);
void readRadiusJ(std::vector<std::string>& lines);

View File

@@ -19,6 +19,13 @@
using namespace MbD;
std::shared_ptr<ASMTGeneralMotion> MbD::ASMTGeneralMotion::With()
{
auto asmt = std::make_shared<ASMTGeneralMotion>();
asmt->initialize();
return asmt;
}
void MbD::ASMTGeneralMotion::parseASMT(std::vector<std::string>& lines)
{
readName(lines);
@@ -78,7 +85,7 @@ void MbD::ASMTGeneralMotion::readRotationOrder(std::vector<std::string>& lines)
lines.erase(lines.begin());
}
std::shared_ptr<Joint> MbD::ASMTGeneralMotion::mbdClassNew()
std::shared_ptr<ItemIJ> MbD::ASMTGeneralMotion::mbdClassNew()
{
return CREATE<FullMotion>::With();
}
@@ -96,21 +103,21 @@ void MbD::ASMTGeneralMotion::createMbD(std::shared_ptr<System> mbdSys, std::shar
//rIJI
userFunc = std::make_shared<BasicUserFunction>(rIJI->at(0), 1.0);
parser->parseUserFunction(userFunc);
auto geoX = parser->stack->top();
auto& geoX = parser->stack->top();
geoX = Symbolic::times(geoX, sptrConstant(1.0 / mbdUnits->length));
geoX->createMbD(mbdSys, mbdUnits);
auto xBlk = geoX->simplified(geoX);
userFunc = std::make_shared<BasicUserFunction>(rIJI->at(1), 1.0);
parser->parseUserFunction(userFunc);
auto geoY = parser->stack->top();
auto& geoY = parser->stack->top();
geoY = Symbolic::times(geoY, sptrConstant(1.0 / mbdUnits->length));
geoY->createMbD(mbdSys, mbdUnits);
auto yBlk = geoY->simplified(geoY);
userFunc = std::make_shared<BasicUserFunction>(rIJI->at(2), 1.0);
parser->parseUserFunction(userFunc);
auto geoZ = parser->stack->top();
auto& geoZ = parser->stack->top();
geoZ = Symbolic::times(geoZ, sptrConstant(1.0 / mbdUnits->length));
geoZ->createMbD(mbdSys, mbdUnits);
auto zBlk = geoZ->simplified(geoZ);
@@ -121,21 +128,21 @@ void MbD::ASMTGeneralMotion::createMbD(std::shared_ptr<System> mbdSys, std::shar
//angIJJ
userFunc = std::make_shared<BasicUserFunction>(angIJJ->at(0), 1.0);
parser->parseUserFunction(userFunc);
auto geoPhi = parser->stack->top();
auto& geoPhi = parser->stack->top();
geoPhi = Symbolic::times(geoPhi, sptrConstant(1.0 / mbdUnits->angle));
geoPhi->createMbD(mbdSys, mbdUnits);
auto phiBlk = geoPhi->simplified(geoPhi);
userFunc = std::make_shared<BasicUserFunction>(angIJJ->at(1), 1.0);
parser->parseUserFunction(userFunc);
auto geoThe = parser->stack->top();
auto& geoThe = parser->stack->top();
geoThe = Symbolic::times(geoThe, sptrConstant(1.0 / mbdUnits->angle));
geoThe->createMbD(mbdSys, mbdUnits);
auto theBlk = geoThe->simplified(geoThe);
userFunc = std::make_shared<BasicUserFunction>(angIJJ->at(2), 1.0);
parser->parseUserFunction(userFunc);
auto geoPsi = parser->stack->top();
auto& geoPsi = parser->stack->top();
geoPsi = Symbolic::times(geoPsi, sptrConstant(1.0 / mbdUnits->angle));
geoPsi->createMbD(mbdSys, mbdUnits);
auto psiBlk = geoPsi->simplified(geoPsi);

View File

@@ -15,11 +15,12 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTGeneralMotion> With();
void parseASMT(std::vector<std::string>& lines) override;
void readrIJI(std::vector<std::string>& lines);
void readangIJJ(std::vector<std::string>& lines);
void readRotationOrder(std::vector<std::string>& lines);
std::shared_ptr<Joint> mbdClassNew() override;
std::shared_ptr<ItemIJ> mbdClassNew() override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;

View File

@@ -58,7 +58,7 @@ void MbD::ASMTItem::parseASMT(std::vector<std::string>&)
std::string MbD::ASMTItem::popOffTop(std::vector<std::string>& args)
{
auto str = args.at(0); //Must copy string
std::string str = args.at(0); //Must copy string
args.erase(args.begin());
return str;
}

View File

@@ -8,15 +8,21 @@
#include <fstream>
#include "ASMTItemIJ.h"
#include "ASMTAssembly.h"
#include "ASMTMarker.h"
#include "ItemIJ.h"
using namespace MbD;
MbD::ASMTItemIJ::ASMTItemIJ()
{
fxs = std::make_shared<FullRow<double>>();
fys = std::make_shared<FullRow<double>>();
fzs = std::make_shared<FullRow<double>>();
txs = std::make_shared<FullRow<double>>();
tys = std::make_shared<FullRow<double>>();
tzs = std::make_shared<FullRow<double>>();
//Use initialize to be consistent with Smalltalk Twin
//fxs = std::make_shared<FullRow<double>>();
//fys = std::make_shared<FullRow<double>>();
//fzs = std::make_shared<FullRow<double>>();
//txs = std::make_shared<FullRow<double>>();
//tys = std::make_shared<FullRow<double>>();
//tzs = std::make_shared<FullRow<double>>();
}
void MbD::ASMTItemIJ::initialize()
@@ -144,3 +150,28 @@ void MbD::ASMTItemIJ::storeOnTimeSeries(std::ofstream& os)
}
os << std::endl;
}
void MbD::ASMTItemIJ::parseASMT(std::vector<std::string>& lines)
{
readName(lines);
readMarkerI(lines);
readMarkerJ(lines);
}
void MbD::ASMTItemIJ::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
//self dataSeries : OrderedCollection new.
//self discontinuities : OrderedCollection new.
auto mbdJt = this->mbdClassNew();
mbdObject = mbdJt;
mbdJt->name = fullName("");
auto mrkI = std::static_pointer_cast<EndFramec>(root()->markerAt(markerI)->mbdObject);
auto mrkJ = std::static_pointer_cast<EndFramec>(root()->markerAt(markerJ)->mbdObject);
mbdJt->connectsItoJ(mrkI, mrkJ);
}
std::shared_ptr<ItemIJ> MbD::ASMTItemIJ::mbdClassNew()
{
assert(false);
return std::shared_ptr<ItemIJ>();
}

View File

@@ -29,6 +29,9 @@ namespace MbD {
void readTZonIs(std::vector<std::string>& lines);
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
virtual std::shared_ptr<ItemIJ> mbdClassNew();
std::string markerI, markerJ;
FRowDsptr fxs, fys, fzs, txs, tys, tzs;

View File

@@ -8,14 +8,15 @@
#include <fstream>
#include "ASMTJoint.h"
#include "Joint.h"
using namespace MbD;
void MbD::ASMTJoint::parseASMT(std::vector<std::string>& lines)
std::shared_ptr<ASMTJoint> MbD::ASMTJoint::With()
{
readName(lines);
readMarkerI(lines);
readMarkerJ(lines);
auto asmt = std::make_shared<ASMTJoint>();
asmt->initialize();
return asmt;
}
void MbD::ASMTJoint::readJointSeries(std::vector<std::string>& lines)
@@ -53,3 +54,10 @@ void MbD::ASMTJoint::storeOnTimeSeries(std::ofstream& os)
os << label << "Series\t" << fullName("") << std::endl;
ASMTItemIJ::storeOnTimeSeries(os);
}
void MbD::ASMTJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTConstraintSet::createMbD(mbdSys, mbdUnits);
auto mbdJt = std::static_pointer_cast<Joint>(mbdObject);
mbdSys->addJoint(mbdJt);
}

View File

@@ -17,10 +17,11 @@ namespace MbD {
{
//
public:
void parseASMT(std::vector<std::string>& lines) override;
static std::shared_ptr<ASMTJoint> With();
void readJointSeries(std::vector<std::string>& lines);
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<std::vector<std::shared_ptr<ForceTorqueData>>> jointSeries;

103
OndselSolver/ASMTLimit.cpp Normal file
View File

@@ -0,0 +1,103 @@
#include "ASMTLimit.h"
#include "ASMTAssembly.h"
#include "ASMTJoint.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "Constant.h"
using namespace MbD;
void MbD::ASMTLimit::initMarkers()
{
if (motionJoint == "") {
assert(markerI != "");
assert(markerJ != "");
}
else {
auto jt = root()->jointAt(motionJoint);
markerI = jt->markerI;
markerJ = jt->markerJ;
}
}
void MbD::ASMTLimit::storeOnLevel(std::ofstream& os, size_t level)
{
assert(false);
}
void MbD::ASMTLimit::readMotionJoint(std::vector<std::string>& lines)
{
assert(readStringOffTop(lines) == "MotionJoint");
motionJoint = readStringOffTop(lines);
}
void MbD::ASMTLimit::readLimit(std::vector<std::string>& lines)
{
assert(readStringOffTop(lines) == "Limit");
limit = readStringOffTop(lines);
}
void MbD::ASMTLimit::readType(std::vector<std::string>& lines)
{
assert(readStringOffTop(lines) == "Type");
type = readStringOffTop(lines);
}
void MbD::ASMTLimit::readTol(std::vector<std::string>& lines)
{
assert(readStringOffTop(lines) == "Tol");
tol = readStringOffTop(lines);
}
void MbD::ASMTLimit::parseASMT(std::vector<std::string>& lines)
{
ASMTConstraintSet::parseASMT(lines);
readMotionJoint(lines);
readLimit(lines);
readType(lines);
readTol(lines);
}
void MbD::ASMTLimit::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTConstraintSet::createMbD(mbdSys, mbdUnits);
auto limitIJ = std::static_pointer_cast<LimitIJ>(mbdObject);
mbdSys->addLimit(limitIJ);
//
auto parser = std::make_shared<SymbolicParser>();
parser->owner = this;
std::shared_ptr<BasicUserFunction> userFunc;
//
userFunc = std::make_shared<BasicUserFunction>(limit, 1.0);
parser->parseUserFunction(userFunc);
auto& geolimit = parser->stack->top();
geolimit = Symbolic::times(geolimit, sptrConstant(1.0 / mbdUnits->angle));
geolimit->createMbD(mbdSys, mbdUnits);
geolimit = geolimit->simplified(geolimit);
limitIJ->limit = geolimit->getValue();
//
limitIJ->type = type;
//
userFunc = std::make_shared<BasicUserFunction>(tol, 1.0);
parser->parseUserFunction(userFunc);
auto& geotol = parser->stack->top();
geotol = Symbolic::times(geotol, sptrConstant(1.0 / mbdUnits->angle));
geotol->createMbD(mbdSys, mbdUnits);
geotol = geotol->simplified(geotol);
limitIJ->tol = geotol->getValue();
}
void MbD::ASMTLimit::settype(std::string _type)
{
type = _type;
}
void MbD::ASMTLimit::setlimit(std::string _limit)
{
limit = _limit;
}
void MbD::ASMTLimit::settol(std::string _tol)
{
tol = _tol;
}

35
OndselSolver/ASMTLimit.h Normal file
View File

@@ -0,0 +1,35 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTConstraintSet.h"
#include "ForceTorqueData.h"
namespace MbD {
class ASMTLimit : public ASMTConstraintSet
{
//
public:
virtual void initMarkers();
void storeOnLevel(std::ofstream& os, size_t level) override;
void readMotionJoint(std::vector<std::string>& lines);
void readLimit(std::vector<std::string>& lines);
void readType(std::vector<std::string>& lines);
void readTol(std::vector<std::string>& lines);
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void settype(std::string _type);
void setlimit(std::string _limit);
void settol(std::string _tol);
std::string motionJoint, type, limit, tol;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTLineInPlaneJoint::mbdClassNew()
std::shared_ptr<ASMTLineInPlaneJoint> MbD::ASMTLineInPlaneJoint::With()
{
auto asmt = std::make_shared<ASMTLineInPlaneJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTLineInPlaneJoint::mbdClassNew()
{
return CREATE<LineInPlaneJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTLineInPlaneJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -17,6 +17,13 @@
using namespace MbD;
std::shared_ptr<ASMTMarker> MbD::ASMTMarker::With()
{
auto asmt = std::make_shared<ASMTMarker>();
asmt->initialize();
return asmt;
}
void ASMTMarker::parseASMT(std::vector<std::string>& lines)
{
readName(lines);

View File

@@ -18,6 +18,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTMarker> With();
void parseASMT(std::vector<std::string>& lines) override;
FColDsptr rpmp();
FMatDsptr aApm();

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTMotion.h"
#include "Joint.h"
using namespace MbD;
@@ -42,3 +43,10 @@ void ASMTMotion::storeOnTimeSeries(std::ofstream&)
{
assert(false);
}
void MbD::ASMTMotion::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTConstraintSet::createMbD(mbdSys, mbdUnits);
auto mbdJt = std::static_pointer_cast<Joint>(mbdObject);
mbdSys->addJoint(mbdJt);
}

View File

@@ -20,6 +20,7 @@ namespace MbD {
virtual void initMarkers();
void storeOnLevel(std::ofstream& os, size_t level) override;
void storeOnTimeSeries(std::ofstream& os) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<std::vector<std::shared_ptr<ForceTorqueData>>> motionSeries;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTNoRotationJoint::mbdClassNew()
std::shared_ptr<ASMTNoRotationJoint> MbD::ASMTNoRotationJoint::With()
{
auto asmt = std::make_shared<ASMTNoRotationJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTNoRotationJoint::mbdClassNew()
{
return CREATE<NoRotationJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTNoRotationJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTParallelAxesJoint::mbdClassNew()
std::shared_ptr<ASMTParallelAxesJoint> MbD::ASMTParallelAxesJoint::With()
{
auto asmt = std::make_shared<ASMTParallelAxesJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTParallelAxesJoint::mbdClassNew()
{
return CREATE<ParallelAxesJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTParallelAxesJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -15,6 +15,13 @@
using namespace MbD;
std::shared_ptr<ASMTPart> MbD::ASMTPart::With()
{
auto asmt = std::make_shared<ASMTPart>();
asmt->initialize();
return asmt;
}
void MbD::ASMTPart::parseASMT(std::vector<std::string>& lines)
{
readName(lines);
@@ -57,7 +64,7 @@ void MbD::ASMTPart::readPrincipalMassMarker(std::vector<std::string>& lines)
{
assert(lines[0].find("PrincipalMassMarker") != std::string::npos);
lines.erase(lines.begin());
principalMassMarker = std::make_shared<ASMTPrincipalMassMarker>();
principalMassMarker = ASMTPrincipalMassMarker::With();
principalMassMarker->parseASMT(lines);
principalMassMarker->owner = this;
}

View File

@@ -17,6 +17,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTPart> With();
void parseASMT(std::vector<std::string>& lines) override;
void readFeatureOrder(std::vector<std::string>& lines);
void readPrincipalMassMarker(std::vector<std::string>& lines);

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPerpendicularJoint::mbdClassNew()
std::shared_ptr<ASMTPerpendicularJoint> MbD::ASMTPerpendicularJoint::With()
{
auto asmt = std::make_shared<ASMTPerpendicularJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTPerpendicularJoint::mbdClassNew()
{
return CREATE<PerpendicularJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTPerpendicularJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPlanarJoint::mbdClassNew()
std::shared_ptr<ASMTPlanarJoint> MbD::ASMTPlanarJoint::With()
{
auto asmt = std::make_shared<ASMTPlanarJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTPlanarJoint::mbdClassNew()
{
return CREATE<PlanarJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTPlanarJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPointInLineJoint::mbdClassNew()
std::shared_ptr<ASMTPointInLineJoint> MbD::ASMTPointInLineJoint::With()
{
auto asmt = std::make_shared<ASMTPointInLineJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTPointInLineJoint::mbdClassNew()
{
return CREATE<PointInLineJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTPointInLineJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPointInPlaneJoint::mbdClassNew()
std::shared_ptr<ASMTPointInPlaneJoint> MbD::ASMTPointInPlaneJoint::With()
{
auto asmt = std::make_shared<ASMTPointInPlaneJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTPointInPlaneJoint::mbdClassNew()
{
return CREATE<PointInPlaneJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTPointInPlaneJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -17,6 +17,13 @@ MbD::ASMTPrincipalMassMarker::ASMTPrincipalMassMarker()
name = "MassMarker";
}
std::shared_ptr<ASMTPrincipalMassMarker> MbD::ASMTPrincipalMassMarker::With()
{
auto asmt = std::make_shared<ASMTPrincipalMassMarker>();
asmt->initialize();
return asmt;
}
void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector<std::string>& lines)
{
auto pos = lines[0].find_first_not_of("\t");

View File

@@ -16,6 +16,7 @@ namespace MbD {
//
public:
ASMTPrincipalMassMarker();
static std::shared_ptr<ASMTPrincipalMassMarker> With();
void parseASMT(std::vector<std::string>& lines) override;
void setMass(double mass);
void setDensity(double density);

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRackPinionJoint::mbdClassNew()
std::shared_ptr<ASMTRackPinionJoint> MbD::ASMTRackPinionJoint::With()
{
auto asmt = std::make_shared<ASMTRackPinionJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTRackPinionJoint::mbdClassNew()
{
return CREATE<RackPinJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTRackPinionJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readPitchRadius(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRevCylJoint::mbdClassNew()
std::shared_ptr<ASMTRevCylJoint> MbD::ASMTRevCylJoint::With()
{
auto asmt = std::make_shared<ASMTRevCylJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTRevCylJoint::mbdClassNew()
{
return CREATE<RevCylJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTRevCylJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRevRevJoint::mbdClassNew()
std::shared_ptr<ASMTRevRevJoint> MbD::ASMTRevRevJoint::With()
{
auto asmt = std::make_shared<ASMTRevRevJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTRevRevJoint::mbdClassNew()
{
return CREATE<RevRevJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTRevRevJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRevoluteJoint::mbdClassNew()
std::shared_ptr<ASMTRevoluteJoint> MbD::ASMTRevoluteJoint::With()
{
auto asmt = std::make_shared<ASMTRevoluteJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTRevoluteJoint::mbdClassNew()
{
return CREATE<RevoluteJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTRevoluteJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
//void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -0,0 +1,36 @@
#include "ASMTRotationLimit.h"
#include "ASMTAssembly.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "Constant.h"
#include "RotationLimitIJ.h"
using namespace MbD;
std::shared_ptr<ASMTRotationLimit> MbD::ASMTRotationLimit::With()
{
auto rotationLimit = std::make_shared<ASMTRotationLimit>();
rotationLimit->initialize();
return rotationLimit;
}
std::shared_ptr<ItemIJ> MbD::ASMTRotationLimit::mbdClassNew()
{
return RotationLimitIJ::With();
}
void MbD::ASMTRotationLimit::storeOnLevel(std::ofstream& os, size_t level)
{
storeOnLevelString(os, level, "RotationLimit");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "MotionJoint");
storeOnLevelString(os, level + 2, motionJoint);
storeOnLevelString(os, level + 1, "Limit");
storeOnLevelString(os, level + 2, limit);
storeOnLevelString(os, level + 1, "Type");
storeOnLevelString(os, level + 2, type);
storeOnLevelString(os, level + 1, "Tol");
storeOnLevelString(os, level + 2, tol);
}

View File

@@ -0,0 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTLimit.h"
namespace MbD {
class ASMTRotationLimit : public ASMTLimit
{
//
public:
static std::shared_ptr<ASMTRotationLimit> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, size_t level) override;
};
}

View File

@@ -18,6 +18,13 @@
using namespace MbD;
std::shared_ptr<ASMTRotationalMotion> MbD::ASMTRotationalMotion::With()
{
auto asmt = std::make_shared<ASMTRotationalMotion>();
asmt->initialize();
return asmt;
}
void MbD::ASMTRotationalMotion::parseASMT(std::vector<std::string>& lines)
{
readName(lines);
@@ -67,7 +74,7 @@ void MbD::ASMTRotationalMotion::createMbD(std::shared_ptr<System> mbdSys, std::s
parser->variables->insert(std::make_pair("time", geoTime));
auto userFunc = std::make_shared<BasicUserFunction>(rotationZ, 1.0);
parser->parseUserFunction(userFunc);
auto geoPhi = parser->stack->top();
auto& geoPhi = parser->stack->top();
//std::cout << *geoPhi << std::endl;
geoPhi = Symbolic::times(geoPhi, sptrConstant(1.0 / mbdUnits->angle));
geoPhi->createMbD(mbdSys, mbdUnits);
@@ -77,7 +84,7 @@ void MbD::ASMTRotationalMotion::createMbD(std::shared_ptr<System> mbdSys, std::s
std::static_pointer_cast<ZRotation>(mbdObject)->phiBlk = simple;
}
std::shared_ptr<Joint> MbD::ASMTRotationalMotion::mbdClassNew()
std::shared_ptr<ItemIJ> MbD::ASMTRotationalMotion::mbdClassNew()
{
return CREATE<ZRotation>::With();
}

View File

@@ -16,12 +16,13 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTRotationalMotion> With();
void parseASMT(std::vector<std::string>& lines) override;
void readMotionJoint(std::vector<std::string>& lines);
void readRotationZ(std::vector<std::string>& lines);
void initMarkers() override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<Joint> mbdClassNew() override;
std::shared_ptr<ItemIJ> mbdClassNew() override;
void setMotionJoint(std::string motionJoint);
void setRotationZ(std::string rotZ);
void storeOnLevel(std::ofstream& os, size_t level) override;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTScrewJoint::mbdClassNew()
std::shared_ptr<ASMTScrewJoint> MbD::ASMTScrewJoint::With()
{
auto asmt = std::make_shared<ASMTScrewJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTScrewJoint::mbdClassNew()
{
return CREATE<ScrewJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTScrewJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readPitch(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;

View File

@@ -10,6 +10,13 @@
using namespace MbD;
std::shared_ptr<ASMTSimulationParameters> MbD::ASMTSimulationParameters::With()
{
auto asmt = std::make_shared<ASMTSimulationParameters>();
asmt->initialize();
return asmt;
}
void MbD::ASMTSimulationParameters::parseASMT(std::vector<std::string>& lines)
{
//tstart, tend, hmin, hmax, hout, errorTol;

View File

@@ -15,6 +15,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTSimulationParameters> With();
void parseASMT(std::vector<std::string>& lines) override;
void settstart(double tstart);
void settend(double tend);

View File

@@ -99,7 +99,7 @@ namespace MbD {
FRowDsptr axs, ays, azs, alpxs, alpys, alpzs;
FRowDsptr invxs, invys, invzs, inomexs, inomeys, inomezs;
FRowDsptr inaxs, inays, inazs, inalpxs, inalpys, inalpzs;
std::shared_ptr<ASMTPrincipalMassMarker> principalMassMarker = std::make_shared<ASMTPrincipalMassMarker>();
std::shared_ptr<ASMTPrincipalMassMarker> principalMassMarker = ASMTPrincipalMassMarker::With();
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTSphSphJoint::mbdClassNew()
std::shared_ptr<ASMTSphSphJoint> MbD::ASMTSphSphJoint::With()
{
auto asmt = std::make_shared<ASMTSphSphJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTSphSphJoint::mbdClassNew()
{
return CREATE<SphSphJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTSphSphJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTSphericalJoint::mbdClassNew()
std::shared_ptr<ASMTSphericalJoint> MbD::ASMTSphericalJoint::With()
{
auto asmt = std::make_shared<ASMTSphericalJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTSphericalJoint::mbdClassNew()
{
return CREATE<SphericalJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTSphericalJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -15,6 +15,13 @@
using namespace MbD;
std::shared_ptr<ASMTTime> MbD::ASMTTime::With()
{
auto asmt = std::make_shared<ASMTTime>();
asmt->initialize();
return asmt;
}
void MbD::ASMTTime::deleteMbD()
{
xx = nullptr;

View File

@@ -17,6 +17,7 @@ namespace MbD {
{
//
public:
static std::shared_ptr<ASMTTime> With();
void deleteMbD();
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
Symsptr expandUntil(Symsptr sptr, std::shared_ptr<std::unordered_set<Symsptr>> set) override;

View File

@@ -0,0 +1,35 @@
#include "ASMTTranslationLimit.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "Constant.h"
#include "TranslationLimitIJ.h"
using namespace MbD;
std::shared_ptr<ASMTTranslationLimit> MbD::ASMTTranslationLimit::With()
{
auto translationLimit = std::make_shared<ASMTTranslationLimit>();
translationLimit->initialize();
return translationLimit;
}
std::shared_ptr<ItemIJ> MbD::ASMTTranslationLimit::mbdClassNew()
{
return TranslationLimitIJ::With();
}
void MbD::ASMTTranslationLimit::storeOnLevel(std::ofstream& os, size_t level)
{
storeOnLevelString(os, level, "TranslationLimit");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "MotionJoint");
storeOnLevelString(os, level + 2, motionJoint);
storeOnLevelString(os, level + 1, "Limit");
storeOnLevelString(os, level + 2, limit);
storeOnLevelString(os, level + 1, "Type");
storeOnLevelString(os, level + 2, type);
storeOnLevelString(os, level + 1, "Tol");
storeOnLevelString(os, level + 2, tol);
}

View File

@@ -0,0 +1,23 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTLimit.h"
namespace MbD {
class ASMTTranslationLimit : public ASMTLimit
{
//
public:
static std::shared_ptr<ASMTTranslationLimit> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, size_t level) override;
};
}

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTTranslationalJoint::mbdClassNew()
std::shared_ptr<ASMTTranslationalJoint> MbD::ASMTTranslationalJoint::With()
{
auto asmt = std::make_shared<ASMTTranslationalJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTTranslationalJoint::mbdClassNew()
{
return CREATE<TranslationalJoint>::With();
}

View File

@@ -15,7 +15,8 @@ namespace MbD {
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
static std::shared_ptr<ASMTTranslationalJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;

View File

@@ -41,13 +41,13 @@ void MbD::ASMTTranslationalMotion::createMbD(std::shared_ptr<System> mbdSys, std
parser->variables->insert(std::make_pair("time", geoTime));
auto userFunc = std::make_shared<BasicUserFunction>(translationZ, 1.0);
parser->parseUserFunction(userFunc);
auto zIJ = parser->stack->top();
auto& zIJ = parser->stack->top();
zIJ = Symbolic::times(zIJ, sptrConstant(1.0 / mbdUnits->length));
zIJ->createMbD(mbdSys, mbdUnits);
std::static_pointer_cast<ZTranslation>(mbdObject)->zBlk = zIJ->simplified(zIJ);
}
std::shared_ptr<Joint> MbD::ASMTTranslationalMotion::mbdClassNew()
std::shared_ptr<ItemIJ> MbD::ASMTTranslationalMotion::mbdClassNew()
{
return CREATE<ZTranslation>::With();
}

View File

@@ -18,7 +18,7 @@ namespace MbD {
void parseASMT(std::vector<std::string>& lines) override;
void initMarkers() override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<Joint> mbdClassNew() override;
std::shared_ptr<ItemIJ> mbdClassNew() override;
void readMotionJoint(std::vector<std::string>& lines);
void readTranslationZ(std::vector<std::string>& lines);
void storeOnLevel(std::ofstream& os, size_t level) override;

View File

@@ -12,7 +12,14 @@
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTUniversalJoint::mbdClassNew()
std::shared_ptr<ASMTUniversalJoint> MbD::ASMTUniversalJoint::With()
{
auto asmt = std::make_shared<ASMTUniversalJoint>();
asmt->initialize();
return asmt;
}
std::shared_ptr<ItemIJ> MbD::ASMTUniversalJoint::mbdClassNew()
{
return CREATE<UniversalJoint>::With();
}

View File

@@ -5,19 +5,20 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTAtPointJoint.h"
namespace MbD {
class ASMTUniversalJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
class ASMTUniversalJoint : public ASMTAtPointJoint
{
//
public:
static std::shared_ptr<ASMTUniversalJoint> With();
std::shared_ptr<ItemIJ> mbdClassNew() override;
void storeOnTimeSeries(std::ofstream& os) override;
};
};
}

View File

@@ -20,7 +20,7 @@ using namespace MbD;
void AccNewtonRaphson::askSystemToUpdate()
{
system->partsJointsMotionsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->postAccICIteration(); });
system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->postAccICIteration(); });
}
void AccNewtonRaphson::assignEquationNumbers()
@@ -57,7 +57,7 @@ void AccNewtonRaphson::assignEquationNumbers()
void AccNewtonRaphson::fillPyPx()
{
pypx->zeroSelf();
system->partsJointsMotionsForcesTorquesDo([&](std::shared_ptr<Item> item) {
system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr<Item> item) {
item->fillAccICIterJacob(pypx);
});
}
@@ -65,7 +65,7 @@ void AccNewtonRaphson::fillPyPx()
void AccNewtonRaphson::fillY()
{
y->zeroSelf();
system->partsJointsMotionsForcesTorquesDo([&](std::shared_ptr<Item> item) {
system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr<Item> item) {
item->fillAccICIterError(y);
//std::cout << item->name << *y << std::endl;
});
@@ -97,7 +97,7 @@ void AccNewtonRaphson::incrementIterNo()
void AccNewtonRaphson::initializeGlobally()
{
SystemNewtonRaphson::initializeGlobally();
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) { item->fillqsuddotlam(x); });
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) { item->fillqsuddotlam(x); });
}
void AccNewtonRaphson::logSingularMatrixMessage()
@@ -110,17 +110,17 @@ void AccNewtonRaphson::logSingularMatrixMessage()
void AccNewtonRaphson::passRootToSystem()
{
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) { item->setqsuddotlam(x); });
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) { item->setqsuddotlam(x); });
}
void AccNewtonRaphson::postRun()
{
system->partsJointsMotionsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->postAccIC(); });
system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->postAccIC(); });
}
void AccNewtonRaphson::preRun()
{
system->partsJointsMotionsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->preAccIC(); });
system->partsJointsMotionsLimitsForcesTorquesDo([&](std::shared_ptr<Item> item) { item->preAccIC(); });
}
void MbD::AccNewtonRaphson::handleSingularMatrix()

View File

@@ -0,0 +1,94 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "AngleZConstraintIJ.h"
#include "AngleZConstraintIqcJqc.h"
#include "EndFrameqc.h"
using namespace MbD;
MbD::AngleZConstraintIJ::AngleZConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : ConstraintIJ(frmi, frmj)
{
}
std::shared_ptr<AngleZConstraintIJ> MbD::AngleZConstraintIJ::With(EndFrmsptr frmi, EndFrmsptr frmj)
{
assert(frmi->isEndFrameqc());
assert(frmj->isEndFrameqc());
auto angleZConIJ = std::make_shared<AngleZConstraintIqcJqc>(frmi, frmj);
angleZConIJ->initialize();
return angleZConIJ;
}
void MbD::AngleZConstraintIJ::calcPostDynCorrectorIteration()
{
auto thez = thezIeJe->value();
aG = thez - aConstant;
}
void MbD::AngleZConstraintIJ::initthezIeJe()
{
assert(false);
}
void MbD::AngleZConstraintIJ::initialize()
{
ConstraintIJ::initialize();
this->initthezIeJe();
}
void MbD::AngleZConstraintIJ::initializeGlobally()
{
thezIeJe->initializeGlobally();
}
void MbD::AngleZConstraintIJ::initializeLocally()
{
thezIeJe->initializeLocally();
}
void MbD::AngleZConstraintIJ::postInput()
{
assert(aConstant != std::numeric_limits<double>::min());
ConstraintIJ::postInput();
}
void MbD::AngleZConstraintIJ::postPosICIteration()
{
thezIeJe->postPosICIteration();
ConstraintIJ::postPosICIteration();
}
void MbD::AngleZConstraintIJ::preAccIC()
{
thezIeJe->preAccIC();
ConstraintIJ::preAccIC();
}
void MbD::AngleZConstraintIJ::prePosIC()
{
thezIeJe->prePosIC();
ConstraintIJ::prePosIC();
}
void MbD::AngleZConstraintIJ::preVelIC()
{
thezIeJe->preVelIC();
ConstraintIJ::preVelIC();
}
void MbD::AngleZConstraintIJ::simUpdateAll()
{
thezIeJe->simUpdateAll();
ConstraintIJ::simUpdateAll();
}
ConstraintType MbD::AngleZConstraintIJ::type()
{
return essential;
}

View File

@@ -0,0 +1,38 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ConstraintIJ.h"
#include "AngleZIecJec.h"
namespace MbD {
class AngleZConstraintIJ : public ConstraintIJ
{
//thezIeJe
public:
AngleZConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj);
static std::shared_ptr<AngleZConstraintIJ> With(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
virtual void initthezIeJe();
void initialize() override;
void initializeGlobally() override;
void initializeLocally() override;
void postInput() override;
void postPosICIteration() override;
void preAccIC() override;
void prePosIC() override;
void preVelIC() override;
void simUpdateAll() override;
ConstraintType type() override;
std::shared_ptr<AngleZIecJec> thezIeJe;
};
}

View File

@@ -0,0 +1,86 @@
#include "AngleZConstraintIqcJc.h"
#include "AngleZIeqcJec.h"
#include "EndFrameqc.h"
using namespace MbD;
MbD::AngleZConstraintIqcJc::AngleZConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZConstraintIJ(frmi, frmj)
{
pGpEI = std::make_shared<FullRow<double>>(4);
ppGpEIpEI = std::make_shared<FullMatrix<double>>(4, 4);
}
void MbD::AngleZConstraintIqcJc::initthezIeJe()
{
thezIeJe = std::make_shared<AngleZIeqcJec>(frmI, frmJ);
}
void MbD::AngleZConstraintIqcJc::addToJointTorqueI(FColDsptr jointTorque)
{
auto frmIeqc = std::static_pointer_cast<EndFrameqc>(frmI);
auto rIpIeIp = frmIeqc->rpep();
auto pAOIppEI = frmIeqc->pAOppE();
auto aBOIp = frmIeqc->aBOp();
auto fpAOIppEIrIpIeIp = std::make_shared<FullColumn<double>>(4, 0.0);
auto lampGpE = pGpEI->transpose()->times(lam);
auto c2Torque = aBOIp->timesFullColumn(lampGpE->minusFullColumn(fpAOIppEIrIpIeIp));
jointTorque->equalSelfPlusFullColumntimes(c2Torque, 0.5);
}
void MbD::AngleZConstraintIqcJc::calc_pGpEI()
{
pGpEI = thezIeJe->pvaluepEI();
}
void MbD::AngleZConstraintIqcJc::calc_ppGpEIpEI()
{
ppGpEIpEI = thezIeJe->ppvaluepEIpEI();
}
void MbD::AngleZConstraintIqcJc::calcPostDynCorrectorIteration()
{
AngleZConstraintIJ::calcPostDynCorrectorIteration();
this->calc_pGpEI();
this->calc_ppGpEIpEI();
}
void MbD::AngleZConstraintIqcJc::fillAccICIterError(FColDsptr col)
{
col->atiplusFullVectortimes(iqEI, pGpEI, lam);
auto efrmIqc = std::static_pointer_cast<EndFrameqc>(frmI);
auto qXdotI = efrmIqc->qXdot();
auto qEdotI = efrmIqc->qEdot();
auto sum = pGpEI->timesFullColumn(efrmIqc->qEddot());
sum += qEdotI->transposeTimesFullColumn(ppGpEIpEI->timesFullColumn(qEdotI));
col->atiplusNumber(iG, sum);
}
void MbD::AngleZConstraintIqcJc::fillPosICError(FColDsptr col)
{
AngleZConstraintIJ::fillPosICError(col);
col->atiplusFullVectortimes(iqEI, pGpEI, lam);
}
void MbD::AngleZConstraintIqcJc::fillPosICJacob(SpMatDsptr mat)
{
mat->atijplusFullRow(iG, iqEI, pGpEI);
mat->atijplusFullColumn(iqEI, iG, pGpEI->transpose());
mat->atijplusFullMatrixtimes(iqEI, iqEI, ppGpEIpEI, lam);
}
void MbD::AngleZConstraintIqcJc::fillPosKineJacob(SpMatDsptr mat)
{
mat->atijplusFullRow(iG, iqEI, pGpEI);
}
void MbD::AngleZConstraintIqcJc::fillVelICJacob(SpMatDsptr mat)
{
mat->atijplusFullRow(iG, iqEI, pGpEI);
mat->atijplusFullColumn(iqEI, iG, pGpEI->transpose());
}
void MbD::AngleZConstraintIqcJc::useEquationNumbers()
{
auto frmIeqc = std::static_pointer_cast<EndFrameqc>(frmI);
iqEI = frmIeqc->iqE();
}

View File

@@ -0,0 +1,37 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "AngleZConstraintIJ.h"
namespace MbD {
class AngleZConstraintIqcJc : public AngleZConstraintIJ
{
//pGpEI ppGpEIpEI iqEI
public:
AngleZConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj);
void initthezIeJe() override;
void addToJointTorqueI(FColDsptr col) override;
void calc_pGpEI();
void calc_ppGpEIpEI();
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;
void fillPosICError(FColDsptr col) override;
void fillPosICJacob(SpMatDsptr mat) override;
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
FRowDsptr pGpEI;
FMatDsptr ppGpEIpEI;
size_t iqEI = SIZE_MAX;
};
}

View File

@@ -0,0 +1,93 @@
#include "AngleZConstraintIqcJqc.h"
#include "AngleZIeqcJeqc.h"
#include "EndFrameqc.h"
using namespace MbD;
MbD::AngleZConstraintIqcJqc::AngleZConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZConstraintIqcJc(frmi, frmj)
{
pGpEJ = std::make_shared<FullRow<double>>(4);
ppGpEIpEJ = std::make_shared<FullMatrix<double>>(4, 4);
ppGpEJpEJ = std::make_shared<FullMatrix<double>>(4, 4);
}
void MbD::AngleZConstraintIqcJqc::initthezIeJe()
{
thezIeJe = std::make_shared<AngleZIeqcJeqc>(frmI, frmJ);
}
void MbD::AngleZConstraintIqcJqc::calc_pGpEJ()
{
pGpEJ = thezIeJe->pvaluepEJ();
}
void MbD::AngleZConstraintIqcJqc::calc_ppGpEIpEJ()
{
ppGpEIpEJ = thezIeJe->ppvaluepEIpEJ();
}
void MbD::AngleZConstraintIqcJqc::calc_ppGpEJpEJ()
{
ppGpEJpEJ = thezIeJe->ppvaluepEJpEJ();
}
void MbD::AngleZConstraintIqcJqc::calcPostDynCorrectorIteration()
{
AngleZConstraintIqcJc::calcPostDynCorrectorIteration();
this->calc_pGpEJ();
this->calc_ppGpEIpEJ();
this->calc_ppGpEJpEJ();
}
void MbD::AngleZConstraintIqcJqc::fillAccICIterError(FColDsptr col)
{
AngleZConstraintIqcJc::fillAccICIterError(col);
col->atiplusFullVectortimes(iqEJ, pGpEJ, lam);
auto frmIeqc = std::static_pointer_cast<EndFrameqc>(frmI);
auto frmJeqc = std::static_pointer_cast<EndFrameqc>(frmJ);
auto qEdotI = frmIeqc->qEdot();
auto qXdotJ = frmJeqc->qXdot();
auto qEdotJ = frmJeqc->qEdot();
double sum = 0.0;
sum += pGpEJ->timesFullColumn(frmJeqc->qEddot());
sum += 2.0 * (qEdotI->transposeTimesFullColumn(ppGpEIpEJ->timesFullColumn(qEdotJ)));
sum += qEdotJ->transposeTimesFullColumn(ppGpEJpEJ->timesFullColumn(qEdotJ));
col->atiplusNumber(iG, sum);
}
void MbD::AngleZConstraintIqcJqc::fillPosICError(FColDsptr col)
{
AngleZConstraintIqcJc::fillPosICError(col);
col->atiplusFullVectortimes(iqEJ, pGpEJ, lam);
}
void MbD::AngleZConstraintIqcJqc::fillPosICJacob(SpMatDsptr mat)
{
AngleZConstraintIqcJc::fillPosICJacob(mat);
mat->atijplusFullRow(iG, iqEJ, pGpEJ);
mat->atijplusFullColumn(iqEJ, iG, pGpEJ->transpose());
auto ppGpEIpEJlam = ppGpEIpEJ->times(lam);
mat->atijplusFullMatrix(iqEI, iqEJ, ppGpEIpEJlam);
mat->atijplusTransposeFullMatrix(iqEJ, iqEI, ppGpEIpEJlam);
mat->atijplusFullMatrixtimes(iqEJ, iqEJ, ppGpEJpEJ, lam);
}
void MbD::AngleZConstraintIqcJqc::fillPosKineJacob(SpMatDsptr mat)
{
AngleZConstraintIqcJc::fillPosKineJacob(mat);
mat->atijplusFullRow(iG, iqEJ, pGpEJ);
}
void MbD::AngleZConstraintIqcJqc::fillVelICJacob(SpMatDsptr mat)
{
AngleZConstraintIqcJc::fillVelICJacob(mat);
mat->atijplusFullRow(iG, iqEJ, pGpEJ);
mat->atijplusFullColumn(iqEJ, iG, pGpEJ->transpose());
}
void MbD::AngleZConstraintIqcJqc::useEquationNumbers()
{
AngleZConstraintIqcJc::useEquationNumbers();
auto frmJeqc = std::static_pointer_cast<EndFrameqc>(frmJ);
iqEJ = frmJeqc->iqE();
}

View File

@@ -0,0 +1,37 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "AngleZConstraintIqcJc.h"
namespace MbD {
class AngleZConstraintIqcJqc : public AngleZConstraintIqcJc
{
//pGpEJ ppGpEIpEJ ppGpEJpEJ iqEJ
public:
AngleZConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj);
void initthezIeJe() override;
void calc_pGpEJ();
void calc_ppGpEIpEJ();
void calc_ppGpEJpEJ();
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;
void fillPosICError(FColDsptr col) override;
void fillPosICJacob(SpMatDsptr mat) override;
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
FRowDsptr pGpEJ;
FMatDsptr ppGpEIpEJ, ppGpEJpEJ;
size_t iqEJ = SIZE_MAX;
};
}

View File

@@ -91,7 +91,6 @@ void MbD::AngleZIecJec::prePosIC()
{
aA00IeJe->prePosIC();
aA10IeJe->prePosIC();
assert(thez != std::numeric_limits<double>::min());
KinematicIeJe::prePosIC();
}

View File

@@ -23,6 +23,13 @@ MbD::AngleZIeqcJeqc::AngleZIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZIe
ppthezpEJpEJ = std::make_shared<FullMatrix<double>>(4, 4);
}
std::shared_ptr<AngleZIeqcJeqc> MbD::AngleZIeqcJeqc::With(EndFrmsptr frmi, EndFrmsptr frmj)
{
auto angleZIJ = std::make_shared<AngleZIeqcJeqc>(frmi, frmj);
angleZIJ->initialize();
return angleZIJ;
}
void MbD::AngleZIeqcJeqc::calcPostDynCorrectorIteration()
{
AngleZIeqcJec::calcPostDynCorrectorIteration();

View File

@@ -17,7 +17,8 @@ namespace MbD {
public:
AngleZIeqcJeqc();
AngleZIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj);
static std::shared_ptr<AngleZIeqcJeqc> With(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
void init_aAijIeJe() override;
void initialize() override;

View File

@@ -5,11 +5,14 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <iostream>
#include "AnyPosICNewtonRaphson.h"
#include "SystemSolver.h"
#include "Item.h"
#include <iostream>
#include "Part.h"
#include "Constraint.h"
using namespace MbD;
@@ -22,7 +25,7 @@ void AnyPosICNewtonRaphson::initialize()
void AnyPosICNewtonRaphson::initializeGlobally()
{
SystemNewtonRaphson::initializeGlobally();
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) {
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) {
item->fillqsu(qsuOld);
item->fillqsuWeights(qsuWeights);
item->fillqsulam(x);
@@ -42,7 +45,7 @@ void AnyPosICNewtonRaphson::fillY()
newMinusOld->equalSelfPlusFullColumnAt(x, 0);
y->zeroSelf();
y->atiminusFullColumn(0, (qsuWeights->timesFullColumn(newMinusOld)));
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) {
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) {
item->fillPosICError(y);
//std::cout << item->name << *y << std::endl;
//noop();
@@ -54,7 +57,7 @@ void AnyPosICNewtonRaphson::fillPyPx()
{
pypx->zeroSelf();
pypx->atijminusDiagonalMatrix(0, 0, qsuWeights);
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) {
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) {
item->fillPosICJacob(pypx);
//std::cout << *(pypx->at(3)) << std::endl;
});
@@ -63,5 +66,42 @@ void AnyPosICNewtonRaphson::fillPyPx()
void AnyPosICNewtonRaphson::passRootToSystem()
{
system->partsJointsMotionsDo([&](std::shared_ptr<Item> item) { item->setqsulam(x); });
system->partsJointsMotionsLimitsDo([&](std::shared_ptr<Item> item) { item->setqsulam(x); });
}
void MbD::AnyPosICNewtonRaphson::assignEquationNumbers()
{
auto parts = system->parts();
//auto contactEndFrames = system->contactEndFrames();
//auto uHolders = system->uHolders();
auto constraints = system->allConstraints();
size_t eqnNo = 0;
for (auto& part : *parts) {
part->iqX(eqnNo);
eqnNo = eqnNo + 3;
part->iqE(eqnNo);
eqnNo = eqnNo + 4;
}
//for (auto& endFrm : *contactEndFrames) {
// endFrm->is(eqnNo);
// eqnNo = eqnNo + endFrm->sSize();
//}
//for (auto& uHolder : *uHolders) {
// uHolder->iu(eqnNo);
// eqnNo += 1;
//}
auto nEqns = eqnNo; //C++ uses index 0.
nqsu = nEqns;
for (auto& con : *constraints) {
con->iG = eqnNo;
eqnNo += 1;
}
//auto lastEqnNo = eqnNo - 1;
nEqns = eqnNo; //C++ uses index 0.
n = nEqns;
}
bool MbD::AnyPosICNewtonRaphson::isConverged()
{
return dxNorms->at(iterNo) < dxTol || isConvergedToNumericalLimit();
}

View File

@@ -24,7 +24,8 @@ namespace MbD {
void fillY() override;
void fillPyPx() override;
void passRootToSystem() override;
void assignEquationNumbers() override = 0;
void assignEquationNumbers() override;
bool isConverged() override;
size_t nqsu = SIZE_MAX;
FColDsptr qsuOld;

View File

@@ -32,7 +32,7 @@ void CADSystem::outputFor(AnalysisType)
{
auto str = std::to_string(mbdSystem->mbdTimeValue());
this->logString(str);
mbdSystem->partsJointsMotionsForcesTorquesDo([](std::shared_ptr<Item> item) {
mbdSystem->partsJointsMotionsLimitsForcesTorquesDo([](std::shared_ptr<Item> item) {
std::cout << std::endl;
std::cout << item->classname() << " " << item->name << std::endl;
auto data = item->stateData();

View File

@@ -0,0 +1,185 @@
#include <algorithm>
#include <memory>
#include <typeinfo>
#include "ConstraintSet.h"
#include "Constraint.h"
using namespace MbD;
MbD::ConstraintSet::ConstraintSet()
{
}
MbD::ConstraintSet::ConstraintSet(const char* str) : ItemIJ(str)
{
}
void MbD::ConstraintSet::constraintsDo(const std::function <void(std::shared_ptr<Constraint>)>& f)
{
std::for_each(constraints->begin(), constraints->end(), f);
}
void MbD::ConstraintSet::initialize()
{
constraints = std::make_shared<std::vector<std::shared_ptr<Constraint>>>();
}
void MbD::ConstraintSet::initializeGlobally()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->initializeGlobally(); });
}
void MbD::ConstraintSet::initializeLocally()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->initializeLocally(); });
}
void MbD::ConstraintSet::addConstraint(std::shared_ptr<Constraint> con)
{
con->owner = this;
constraints->push_back(con);
}
void MbD::ConstraintSet::postInput()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->postInput(); });
}
void MbD::ConstraintSet::prePosIC()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->prePosIC(); });
}
void MbD::ConstraintSet::prePosKine()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->prePosKine(); });
}
void MbD::ConstraintSet::fillEssenConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> essenConstraints)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillEssenConstraints(con, essenConstraints); });
}
void MbD::ConstraintSet::fillDispConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> dispConstraints)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillDispConstraints(con, dispConstraints); });
}
void MbD::ConstraintSet::fillPerpenConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> perpenConstraints)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillPerpenConstraints(con, perpenConstraints); });
}
void MbD::ConstraintSet::fillConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> allConstraints)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillConstraints(con, allConstraints); });
}
void MbD::ConstraintSet::fillqsulam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillqsulam(col); });
}
void MbD::ConstraintSet::fillqsudot(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillqsudot(col); });
}
void MbD::ConstraintSet::fillqsudotWeights(DiagMatDsptr)
{
}
void MbD::ConstraintSet::useEquationNumbers()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->useEquationNumbers(); });
}
void MbD::ConstraintSet::setqsulam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->setqsulam(col); });
}
void MbD::ConstraintSet::setqsudotlam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->setqsudotlam(col); });
}
void MbD::ConstraintSet::postPosICIteration()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->postPosICIteration(); });
}
void MbD::ConstraintSet::fillPosICError(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillPosICError(col); });
}
void MbD::ConstraintSet::fillPosICJacob(SpMatDsptr mat)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillPosICJacob(mat); });
}
void MbD::ConstraintSet::postPosIC()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->postPosIC(); });
}
void MbD::ConstraintSet::preDyn()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->preDyn(); });
}
void MbD::ConstraintSet::fillPosKineError(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillPosKineError(col); });
}
void MbD::ConstraintSet::fillPosKineJacob(SpMatDsptr mat)
{
constraintsDo([&](std::shared_ptr<Constraint> constraint) { constraint->fillPosKineJacob(mat); });
}
void MbD::ConstraintSet::fillqsuddotlam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> constraint) { constraint->fillqsuddotlam(col); });
}
void MbD::ConstraintSet::preVelIC()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->preVelIC(); });
}
void MbD::ConstraintSet::fillVelICError(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillVelICError(col); });
}
void MbD::ConstraintSet::fillVelICJacob(SpMatDsptr mat)
{
constraintsDo([&](std::shared_ptr<Constraint> constraint) { constraint->fillVelICJacob(mat); });
}
void MbD::ConstraintSet::preAccIC()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->preAccIC(); });
}
void MbD::ConstraintSet::fillAccICIterError(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillAccICIterError(col); });
}
void MbD::ConstraintSet::fillAccICIterJacob(SpMatDsptr mat)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->fillAccICIterJacob(mat); });
}
void MbD::ConstraintSet::setqsuddotlam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->setqsuddotlam(col); });
}
void MbD::ConstraintSet::postDynStep()
{
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->postDynStep(); });
}

View File

@@ -0,0 +1,61 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include <functional>
#include "ItemIJ.h"
namespace MbD {
class ConstraintSet : public ItemIJ
{
//
public:
ConstraintSet();
ConstraintSet(const char* str);
void constraintsDo(const std::function <void(std::shared_ptr<Constraint>)>& f);
void initialize() override;
void initializeGlobally() override;
void initializeLocally() override;
void addConstraint(std::shared_ptr<Constraint> con);
void fillAccICIterError(FColDsptr col) override;
void fillAccICIterJacob(SpMatDsptr mat) override;
void fillConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> allConstraints) override;
void fillDispConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> dispConstraints) override;
void fillEssenConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> essenConstraints) override;
void fillPerpenConstraints(std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> perpenConstraints) override;
void fillPosICError(FColDsptr col) override;
void fillPosICJacob(SpMatDsptr mat) override;
void fillPosKineError(FColDsptr col) override;
void fillPosKineJacob(SpMatDsptr mat) override;
void fillqsuddotlam(FColDsptr col) override;
void fillqsulam(FColDsptr col) override;
void fillqsudot(FColDsptr col) override;
void fillqsudotWeights(DiagMatDsptr diagMat) override;
void fillVelICError(FColDsptr col) override;
void fillVelICJacob(SpMatDsptr mat) override;
void postDynStep() override;
void postInput() override;
void postPosIC() override;
void postPosICIteration() override;
void preAccIC() override;
void preDyn() override;
void prePosIC() override;
void prePosKine() override;
void preVelIC() override;
void setqsuddotlam(FColDsptr col) override;
void setqsudotlam(FColDsptr col) override;
void setqsulam(FColDsptr col) override;
void useEquationNumbers() override;
std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> constraints;
};
}

View File

@@ -37,6 +37,11 @@ Symsptr MbD::Integral::simplifyUntil(Symsptr, std::shared_ptr<std::unordered_set
return answer;
}
void MbD::Integral::setIntegrationConstant(double integConstant)
{
integrationConstant = sptrConstant(integConstant);
}
std::ostream& MbD::Integral::printOn(std::ostream& s) const
{
s << *expression << " + ";

Some files were not shown because too many files have changed in this diff Show More