constraintSpecs and constraintSpec and clean up.

This commit is contained in:
Aik-Siong Koh
2025-08-12 18:06:00 -06:00
committed by Chris Hennes
parent 1a8fdc32d3
commit d9ad3290c0
73 changed files with 256 additions and 74 deletions

View File

@@ -35,6 +35,11 @@ void AbsConstraint::useEquationNumbers()
iqXminusOnePlusAxis = static_cast<PartFrame*>(owner)->iqX + axis;
}
std::string MbD::AbsConstraint::constraintSpec()
{
return "AbsConstraint" + MbDMath::XYZFromInt(axis);
}
void AbsConstraint::fillPosICJacob(SpMatDsptr mat)
{
mat->atijplusNumber(iG, iqXminusOnePlusAxis, 1.0);

View File

@@ -27,6 +27,7 @@ namespace MbD {
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
std::string constraintSpec() override;
size_t axis = SIZE_MAX;
size_t iqXminusOnePlusAxis = SIZE_MAX;

View File

@@ -52,3 +52,8 @@ void MbD::AllowZRotationConstraintIqctJqc::postPosIC()
//self becomeRedundantConstraint
assert(false);
}
std::string MbD::AllowZRotationConstraintIqctJqc::constraintSpec()
{
return "AllowZRotationConstraintIJ";
}

View File

@@ -20,6 +20,7 @@ namespace MbD {
void postInput() override;
void postPosIC() override;
std::string constraintSpec() override;
};
}

View File

@@ -25,7 +25,7 @@ void MbD::AngleJoint::initializeGlobally()
{
if (constraints->empty())
{
auto dirCosIzJz = CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 2);
auto dirCosIzJz = CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 2);
dirCosIzJz->setConstant(std::cos(theIzJz));
addConstraint(dirCosIzJz);
this->root()->hasChanged = true;

View File

@@ -92,3 +92,8 @@ ConstraintType MbD::AngleZConstraintIJ::type()
{
return essential;
}
std::string MbD::AngleZConstraintIJ::constraintSpec()
{
return "AngleZConstraintIJ";
}

View File

@@ -32,6 +32,7 @@ namespace MbD {
void preVelIC() override;
void simUpdateAll() override;
ConstraintType type() override;
std::string constraintSpec() override;
std::shared_ptr<AngleZIecJec> thezIeJe;
};

View File

@@ -91,3 +91,8 @@ void MbD::AngleZConstraintIqcJqc::useEquationNumbers()
auto frmJeqc = std::static_pointer_cast<EndFrameqc>(frmJ);
iqEJ = frmJeqc->iqE();
}
std::string MbD::AngleZConstraintIqcJqc::constraintSpec()
{
return "AngleZConstraintIJ";
}

View File

@@ -30,6 +30,7 @@ namespace MbD {
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpEJ;
FMatDsptr ppGpEIpEJ, ppGpEJpEJ;

View File

@@ -30,7 +30,6 @@ namespace MbD {
void prePosIC() override;
void preVelIC() override;
ConstraintType type() override;
size_t axis;
std::shared_ptr<DispCompIecJecO> riIeJeO;

View File

@@ -43,6 +43,11 @@ void AtPointConstraintIqcJqc::useEquationNumbers()
iqEJ = frmJeqc->iqE();
}
std::string MbD::AtPointConstraintIqcJqc::constraintSpec()
{
return "AtPointConstraintIJ" + MbDMath::XYZFromInt(axis);
}
void AtPointConstraintIqcJqc::fillPosICError(FColDsptr col)
{
AtPointConstraintIqcJc::fillPosICError(col);

View File

@@ -28,6 +28,7 @@ namespace MbD {
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpEJ;
FMatDsptr ppGpEJpEJ;

View File

@@ -41,6 +41,11 @@ ConstraintType AtPointConstraintIqctJqc::type()
return essential;
}
std::string MbD::AtPointConstraintIqctJqc::constraintSpec()
{
return AtPointConstraintIqcJqc::constraintSpec();
}
void AtPointConstraintIqctJqc::preVelIC()
{
AtPointConstraintIqcJqc::preVelIC();

View File

@@ -25,6 +25,7 @@ namespace MbD {
void preAccIC() override;
void preVelIC() override;
ConstraintType type() override;
std::string constraintSpec() override;
double pGpt;
FRowDsptr ppGpEIpt;

View File

@@ -20,9 +20,23 @@ MbD::AtPointJoint::AtPointJoint(const std::string& str) : Joint(str)
{
}
std::shared_ptr<AtPointJoint> MbD::AtPointJoint::With()
{
auto inst = std::make_shared<AtPointJoint>();
inst->initialize();
return inst;
}
std::shared_ptr<AtPointJoint> MbD::AtPointJoint::With(const char* str)
{
auto inst = std::make_shared<AtPointJoint>(str);
inst->initialize();
return inst;
}
void MbD::AtPointJoint::createAtPointConstraints()
{
addConstraint(CREATE<AtPointConstraintIJ>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<AtPointConstraintIJ>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<AtPointConstraintIJ>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<AtPointConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<AtPointConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<AtPointConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2));
}

View File

@@ -17,6 +17,8 @@ namespace MbD {
public:
AtPointJoint();
AtPointJoint(const std::string& str);
static std::shared_ptr<AtPointJoint> With();
static std::shared_ptr<AtPointJoint> With(const char* str);
void createAtPointConstraints();

View File

@@ -5,7 +5,7 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <string>
#include <iostream>
@@ -595,6 +595,18 @@ void CADSystem::runOndselPiston()
TheSystem->addJoint(rotMotion1);
//
TheSystem->runKINEMATIC(TheSystem);
str = "";
TheSystem->jointsMotionsDo([&](std::shared_ptr<Joint> jm) {
str += jm->constraintSpecs();
});
str = "";
TheSystem->jointsMotionsDo([&](std::shared_ptr<Joint> jm) {
str += jm->name + " constraints\n";
jm->constraintsDo([&](std::shared_ptr<Constraint> con) {
str += " " + con->constraintSpec() + "\n";
});
});
std::cout << str << std::endl;
}
void CADSystem::runPiston()

View File

@@ -70,8 +70,8 @@ namespace MbD {
}
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, size_t axis) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axis)).name();
if (str.find("AtPointConstraintIJ") != std::string::npos) {
std::string str = typeid(T).name();
if (str.find("AtPointConstraintIqcJqc") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<AtPointConstraintIqctJqc>(frmi, frmj, axis);
}
@@ -79,7 +79,7 @@ namespace MbD {
inst = std::make_shared<AtPointConstraintIqcJqc>(frmi, frmj, axis);
}
}
else if(str.find("TranslationConstraintIJ") != std::string::npos) {
else if(str.find("TranslationConstraintIqcJqc") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<TranslationConstraintIqctJqc>(frmi, frmj, axis);
}
@@ -97,8 +97,8 @@ namespace MbD {
}
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, size_t axisi, size_t axisj) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axisi, axisj)).name();
if (str.find("DirectionCosineConstraintIJ") != std::string::npos) {
std::string str = typeid(T).name();
if (str.find("DirectionCosineConstraintIqcJqc") != std::string::npos) {
if (std::dynamic_pointer_cast<EndFrameqct>(frmi)) {
inst = std::make_shared<DirectionCosineConstraintIqctJqc>(frmi, frmj, axisi, axisj);
}

View File

@@ -130,3 +130,8 @@ void MbD::ConstVelConstraintIqcJqc::useEquationNumbers()
ConstVelConstraintIqcJc::useEquationNumbers();
iqEJ = std::static_pointer_cast<EndFrameqc>(frmJ)->iqE();
}
std::string MbD::ConstVelConstraintIqcJqc::constraintSpec()
{
return "ConstVelConstraintIJ";
}

View File

@@ -29,6 +29,7 @@ namespace MbD {
void initA10IeJe() override;
void initialize() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpEJ;
FMatDsptr ppGpEIpEJ;

View File

@@ -53,6 +53,7 @@ namespace MbD {
void setqsuddotlam(FColDsptr col) override;
void setqsulam(FColDsptr col) override;
virtual ConstraintType type();
virtual std::string constraintSpec() = 0;
size_t iG = SIZE_MAX;
double aG = 0.0; //Constraint function

View File

@@ -94,6 +94,15 @@ void MbD::ConstraintSet::useEquationNumbers()
constraintsDo([](std::shared_ptr<Constraint> constraint) { constraint->useEquationNumbers(); });
}
std::string MbD::ConstraintSet::constraintSpecs()
{
std::stringstream ss;
constraintsDo([&](std::shared_ptr<Constraint> con) {
ss << con->constraintSpec() << std::endl;
});
return ss.str();
}
void MbD::ConstraintSet::setqsulam(FColDsptr col)
{
constraintsDo([&](std::shared_ptr<Constraint> con) { con->setqsulam(col); });

View File

@@ -53,7 +53,7 @@ namespace MbD {
void setqsudotlam(FColDsptr col) override;
void setqsulam(FColDsptr col) override;
void useEquationNumbers() override;
std::string constraintSpecs();
std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> constraints;

View File

@@ -27,8 +27,8 @@ void CylindricalJoint::initializeGlobally()
if (constraints->empty())
{
createInLineConstraints();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -38,6 +38,11 @@ void DirectionCosineConstraintIqcJqc::useEquationNumbers()
iqEJ = std::static_pointer_cast<EndFrameqc>(frmJ)->iqE();
}
std::string MbD::DirectionCosineConstraintIqcJqc::constraintSpec()
{
return "DirectionCosineConstraintI" + MbDMath::xyzFromInt(axisI) + "J" + MbDMath::xyzFromInt(axisJ);
}
void DirectionCosineConstraintIqcJqc::fillPosICError(FColDsptr col)
{
DirectionCosineConstraintIqcJc::fillPosICError(col);

View File

@@ -27,6 +27,7 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void initaAijIeJe() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpEJ;
FMatDsptr ppGpEIpEJ;

View File

@@ -27,6 +27,11 @@ ConstraintType DirectionCosineConstraintIqctJqc::type()
return essential;
}
std::string MbD::DirectionCosineConstraintIqctJqc::constraintSpec()
{
return DirectionCosineConstraintIqcJqc::constraintSpec();
}
void DirectionCosineConstraintIqctJqc::preVelIC()
{
DirectionCosineConstraintIJ::preVelIC();

View File

@@ -23,6 +23,7 @@ namespace MbD {
void preAccIC() override;
void preVelIC() override;
ConstraintType type() override;
std::string constraintSpec() override;
double pGpt = std::numeric_limits<double>::min();
FRowDsptr ppGpEIpt;

View File

@@ -30,7 +30,8 @@ namespace MbD {
FRowDsptr pGpXI, pGpEI;
FMatDsptr ppGpXIpXI, ppGpXIpEI, ppGpEIpEI;
size_t iqXI, iqEI;
size_t iqXI = SIZE_MAX, iqEI = SIZE_MAX;
};
}

View File

@@ -116,3 +116,8 @@ void MbD::DistanceConstraintIqcJqc::useEquationNumbers()
iqXJ = frmJeqc->iqX();
iqEJ = frmJeqc->iqE();
}
std::string MbD::DistanceConstraintIqcJqc::constraintSpec()
{
return "DistanceConstraintIJ";
}

View File

@@ -25,10 +25,11 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void init_distIeJe() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpXIpXJ, ppGpEIpXJ, ppGpXJpXJ, ppGpXIpEJ, ppGpEIpEJ, ppGpXJpEJ, ppGpEJpEJ;
size_t iqXJ, iqEJ;
size_t iqXJ = SIZE_MAX, iqEJ = SIZE_MAX;
};
}

View File

@@ -19,3 +19,8 @@ ConstraintType MbD::DistanceConstraintIqctJqc::type()
{
return essential;
}
std::string MbD::DistanceConstraintIqctJqc::constraintSpec()
{
return DistanceConstraintIqcJqc::constraintSpec();
}

View File

@@ -17,6 +17,7 @@ namespace MbD {
public:
DistanceConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj);
ConstraintType type() override;
std::string constraintSpec() override;
double pGpt, ppGptpt;
FRowDsptr ppGpXIpt, ppGpEIpt, ppGpXJpt, ppGpEJpt;

View File

@@ -36,7 +36,7 @@ namespace MbD {
FRowDsptr pGpXI, pGpEI;
FMatDsptr ppGpXIpXI, ppGpXIpEI, ppGpEIpEI;
size_t iqXI, iqEI;
size_t iqXI = SIZE_MAX, iqEI = SIZE_MAX;
};
}

View File

@@ -192,3 +192,8 @@ void MbD::DistancexyConstraintIqcJqc::useEquationNumbers()
iqXJ = frmJeqc->iqX();
iqEJ = frmJeqc->iqE();
}
std::string MbD::DistancexyConstraintIqcJqc::constraintSpec()
{
return "DistancexyConstraintIJ";
}

View File

@@ -34,10 +34,11 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void init_xyIeJeIe() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpXIpXJ, ppGpEIpXJ, ppGpXJpXJ, ppGpXIpEJ, ppGpEIpEJ, ppGpXJpEJ, ppGpEJpEJ;
size_t iqXJ, iqEJ;
size_t iqXJ = SIZE_MAX, iqEJ = SIZE_MAX;
};
}

View File

@@ -83,3 +83,8 @@ void EulerConstraint::fillAccICIterError(FColDsptr col)
sum += 2.0 * partFrame->qEdot->sumOfSquares();
col->atiplusNumber(iG, sum);
}
std::string MbD::EulerConstraint::constraintSpec()
{
return "EulerConstraint";
}

View File

@@ -30,6 +30,7 @@ namespace MbD {
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void fillAccICIterError(FColDsptr col) override;
std::string constraintSpec() override;
FRowDsptr pGpE; //partial derivative of G wrt pE
size_t iqE = SIZE_MAX;

View File

@@ -25,9 +25,9 @@ void MbD::FixedJoint::initializeGlobally()
if (constraints->empty())
{
createAtPointConstraints();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -16,7 +16,7 @@ MbD::FullMotion::FullMotion()
{
}
MbD::FullMotion::FullMotion(const std::string&)
MbD::FullMotion::FullMotion(const std::string& str) : PrescribedMotion(str)
{
}
@@ -30,12 +30,12 @@ void MbD::FullMotion::initializeGlobally()
{
if (constraints->empty()) {
initMotions();
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -162,3 +162,8 @@ void MbD::GearConstraintIqcJqc::useEquationNumbers()
iqXJ = frmJeqc->iqX();
iqEJ = frmJeqc->iqE();
}
std::string MbD::GearConstraintIqcJqc::constraintSpec()
{
return "GearConstraintIJ";
}

View File

@@ -34,6 +34,7 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void initorbitsIJ() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpXIpXJ, ppGpXIpEJ, ppGpEIpXJ, ppGpEIpEJ, ppGpXJpXJ, ppGpXJpEJ, ppGpEJpEJ;

View File

@@ -17,7 +17,7 @@ MbD::GearJoint::GearJoint()
{
}
MbD::GearJoint::GearJoint(const std::string&)
MbD::GearJoint::GearJoint(const std::string& str) : Joint(str)
{
}
//

View File

@@ -13,12 +13,12 @@ MbD::InLineJoint::InLineJoint()
{
}
MbD::InLineJoint::InLineJoint(const std::string&)
MbD::InLineJoint::InLineJoint(const std::string& str) : Joint(str)
{
}
void MbD::InLineJoint::createInLineConstraints()
{
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1));
}

View File

@@ -13,13 +13,13 @@ MbD::InPlaneJoint::InPlaneJoint()
{
}
MbD::InPlaneJoint::InPlaneJoint(const std::string&)
MbD::InPlaneJoint::InPlaneJoint(const std::string& str) : Joint(str)
{
}
void MbD::InPlaneJoint::createInPlaneConstraint()
{
auto tranCon = CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 2);
auto tranCon = CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2);
tranCon->setConstant(offset);
addConstraint(tranCon);
}

View File

@@ -97,7 +97,7 @@ void Joint::constraintsReport()
std::string str = "MbD: " + this->classname() + std::string(" ") + this->name + " has the following constraint(s) removed: ";
this->logString(str);
std::for_each(redunCons->begin(), redunCons->end(), [&](auto& con) {
str = "MbD: " + std::string(" ") + con->classname();
str = "MbD: " + std::string(" ") + con->constraintSpec();
this->logString(str);
});
}

View File

@@ -16,7 +16,7 @@ MbD::LineInPlaneJoint::LineInPlaneJoint()
{
}
MbD::LineInPlaneJoint::LineInPlaneJoint(const std::string&)
MbD::LineInPlaneJoint::LineInPlaneJoint(const std::string& str) : InPlaneJoint(str)
{
}
@@ -25,7 +25,7 @@ void MbD::LineInPlaneJoint::initializeGlobally()
if (constraints->empty())
{
this->createInPlaneConstraint();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 2));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 2));
this->root()->hasChanged = true;
}
else {

View File

@@ -12,3 +12,31 @@ void MbD::MbDMath::noop()
{
//No Operations
}
std::string MbD::MbDMath::xyzFromInt(int i)
{
switch (i) {
case 0:
return "x";
case 1:
return "y";
case 2:
return "z";
default:
return std::to_string(i);
}
}
std::string MbD::MbDMath::XYZFromInt(int i)
{
switch (i) {
case 0:
return "X";
case 1:
return "Y";
case 2:
return "Z";
default:
return std::to_string(i);
}
}

View File

@@ -7,13 +7,15 @@
***************************************************************************/
#pragma once
#include <string>
namespace MbD {
class MbDMath
{
public:
void noop();
static std::string xyzFromInt(int i);
static std::string XYZFromInt(int i);
};
}

View File

@@ -17,7 +17,7 @@ MbD::NoRotationJoint::NoRotationJoint()
{
}
MbD::NoRotationJoint::NoRotationJoint(const std::string&)
MbD::NoRotationJoint::NoRotationJoint(const std::string& str) : Joint(str)
{
}
@@ -25,9 +25,9 @@ void MbD::NoRotationJoint::initializeGlobally()
{
if (constraints->empty())
{
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -16,7 +16,7 @@ MbD::Orientation::Orientation()
{
}
MbD::Orientation::Orientation(const std::string&)
MbD::Orientation::Orientation(const std::string& str) : PrescribedMotion(str)
{
}
@@ -24,9 +24,9 @@ void MbD::Orientation::initializeGlobally()
{
if (constraints->empty()) {
initMotions();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -16,7 +16,7 @@ MbD::ParallelAxesJoint::ParallelAxesJoint()
{
}
MbD::ParallelAxesJoint::ParallelAxesJoint(const std::string&)
MbD::ParallelAxesJoint::ParallelAxesJoint(const std::string& str) : Joint(str)
{
}
@@ -24,8 +24,8 @@ void MbD::ParallelAxesJoint::initializeGlobally()
{
if (constraints->empty())
{
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -16,7 +16,7 @@ MbD::PerpendicularJoint::PerpendicularJoint()
{
}
MbD::PerpendicularJoint::PerpendicularJoint(const std::string&)
MbD::PerpendicularJoint::PerpendicularJoint(const std::string& str) : Joint(str)
{
}
@@ -24,7 +24,7 @@ void MbD::PerpendicularJoint::initializeGlobally()
{
if (constraints->empty())
{
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 2));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 2));
this->root()->hasChanged = true;
}
else {

View File

@@ -16,7 +16,7 @@ MbD::PlanarJoint::PlanarJoint()
{
}
MbD::PlanarJoint::PlanarJoint(const std::string&)
MbD::PlanarJoint::PlanarJoint(const std::string& str) : InPlaneJoint(str)
{
}
@@ -25,8 +25,8 @@ void MbD::PlanarJoint::initializeGlobally()
if (constraints->empty())
{
this->createInPlaneConstraint();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -15,7 +15,7 @@ MbD::PointInPlaneJoint::PointInPlaneJoint()
{
}
MbD::PointInPlaneJoint::PointInPlaneJoint(const std::string&)
MbD::PointInPlaneJoint::PointInPlaneJoint(const std::string& str) : InPlaneJoint(str)
{
}

View File

@@ -141,3 +141,8 @@ void MbD::RackPinConstraintIqcJqc::useEquationNumbers()
iqXJ = frmJeqc->iqX();
iqEJ = frmJeqc->iqE();
}
std::string MbD::RackPinConstraintIqcJqc::constraintSpec()
{
return "RackPinConstraintIJ";
}

View File

@@ -34,6 +34,7 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void init_xthez() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ;

View File

@@ -5,7 +5,7 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "RedundantConstraint.h"
using namespace MbD;
@@ -112,3 +112,8 @@ void RedundantConstraint::discontinuityAtaddTypeTo(double, std::shared_ptr<std::
//newSelf discontinuityAt : tstartNew addTypeTo : collection.
//self become : newSelf
}
std::string MbD::RedundantConstraint::constraintSpec()
{
return "RedundantConstraint" + constraint->constraintSpec();
}

View File

@@ -38,6 +38,7 @@ namespace MbD {
void fillAccICIterError(FColDsptr col) override;
void setqsuddotlam(FColDsptr col) override;
void discontinuityAtaddTypeTo(double t, std::shared_ptr<std::vector<DiscontinuityType>> disconTypes) override;
std::string constraintSpec() override;
std::shared_ptr<Constraint> constraint;
};

View File

@@ -28,8 +28,8 @@ void MbD::RevCylJoint::initializeGlobally()
auto distxyIJ = DistancexyConstraintIJ::With(frmI, frmJ);
distxyIJ->setConstant(distanceIJ);
addConstraint(distxyIJ);
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -28,9 +28,9 @@ void MbD::RevRevJoint::initializeGlobally()
auto distxyIJ = DistancexyConstraintIJ::With(frmI, frmJ);
distxyIJ->setConstant(distanceIJ);
addConstraint(distxyIJ);
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -27,8 +27,8 @@ void RevoluteJoint::initializeGlobally()
if (constraints->empty())
{
createAtPointConstraints();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -143,3 +143,8 @@ void MbD::ScrewConstraintIqcJqc::useEquationNumbers()
iqXJ = frmJeqc->iqX();
iqEJ = frmJeqc->iqE();
}
std::string MbD::ScrewConstraintIqcJqc::constraintSpec()
{
return "ScrewConstraintIJ";
}

View File

@@ -34,6 +34,7 @@ namespace MbD {
void fillVelICJacob(SpMatDsptr mat) override;
void init_zthez() override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ;

View File

@@ -16,7 +16,7 @@ MbD::Translation::Translation()
{
}
MbD::Translation::Translation(const std::string&)
MbD::Translation::Translation(const std::string& str) : PrescribedMotion(str)
{
}
@@ -24,9 +24,9 @@ void MbD::Translation::initializeGlobally()
{
if (constraints->empty()) {
initMotions();
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 2));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 0));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1));
addConstraint(CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2));
this->root()->hasChanged = true;
}
else {

View File

@@ -41,6 +41,11 @@ void TranslationConstraintIqcJqc::useEquationNumbers()
iqEJ = frmJeqc->iqE();
}
std::string MbD::TranslationConstraintIqcJqc::constraintSpec()
{
return "TranslationConstraintI" + MbDMath::xyzFromInt(axisI) + "J";
}
void TranslationConstraintIqcJqc::fillPosICError(FColDsptr col)
{
TranslationConstraintIqcJc::fillPosICError(col);

View File

@@ -27,6 +27,7 @@ namespace MbD {
void fillPosKineJacob(SpMatDsptr mat) override;
void fillVelICJacob(SpMatDsptr mat) override;
void useEquationNumbers() override;
std::string constraintSpec() override;
FRowDsptr pGpXJ, pGpEJ;
FMatDsptr ppGpEIpXJ, ppGpEIpEJ, ppGpEJpEJ;

View File

@@ -27,6 +27,11 @@ ConstraintType TranslationConstraintIqctJqc::type()
return essential;
}
std::string MbD::TranslationConstraintIqctJqc::constraintSpec()
{
return TranslationConstraintIqcJqc::constraintSpec();
}
void TranslationConstraintIqctJqc::preVelIC()
{
TranslationConstraintIJ::preVelIC();

View File

@@ -23,6 +23,7 @@ namespace MbD {
void preAccIC() override;
void preVelIC() override;
ConstraintType type() override;
std::string constraintSpec() override;
double pGpt;
FRowDsptr ppGpXIpt;

View File

@@ -27,9 +27,9 @@ void MbD::TranslationalJoint::initializeGlobally()
if (constraints->empty())
{
createInLineConstraints();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 1));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 0));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 1));
this->root()->hasChanged = true;
}
else {

View File

@@ -25,7 +25,7 @@ void MbD::UniversalJoint::initializeGlobally()
if (constraints->empty())
{
createAtPointConstraints();
addConstraint(CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 2, 2));
addConstraint(CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2, 2));
this->root()->hasChanged = true;
}
else {

View File

@@ -28,7 +28,7 @@ void ZRotation::initializeGlobally()
{
if (constraints->empty()) {
initMotions();
auto dirCosCon = CREATE<DirectionCosineConstraintIJ>::ConstraintWith(frmI, frmJ, 1, 0); //Use Iy and Jx to make sin(theta).
auto dirCosCon = CREATE<DirectionCosineConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 1, 0); //Use Iy and Jx to make sin(theta).
addConstraint(dirCosCon);
this->root()->hasChanged = true;
}

View File

@@ -16,7 +16,7 @@ MbD::ZTranslation::ZTranslation()
{
}
MbD::ZTranslation::ZTranslation(const std::string&)
MbD::ZTranslation::ZTranslation(const std::string& str) : PrescribedMotion(str)
{
}
@@ -24,7 +24,7 @@ void MbD::ZTranslation::initializeGlobally()
{
if (constraints->empty()) {
initMotions();
auto tranCon = CREATE<TranslationConstraintIJ>::ConstraintWith(frmI, frmJ, 2);
auto tranCon = CREATE<TranslationConstraintIqcJqc>::ConstraintWith(frmI, frmJ, 2);
addConstraint(tranCon);
this->root()->hasChanged = true;
}