MbDCode repo renamed to OndselSolver. Several *.asmt files working.

This commit is contained in:
Aik-Siong Koh
2023-08-07 08:21:33 -06:00
parent 6ef4789eca
commit e58446b9e2
287 changed files with 13387 additions and 778 deletions

1494
MbDCode/00backhoe.asmt Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,13 @@
#include "ASMTTranslationalMotion.h"
#include "ASMTMarker.h"
#include "Part.h"
#include "ASMTTranslationalJoint.h"
#include "ASMTSphericalJoint.h"
#include "ASMTFixedJoint.h"
#include "ASMTGeneralMotion.h"
#include "ASMTUniversalJoint.h"
#include "ExternalSystem.h"
#include "ASMTPointInPlaneJoint.h"
using namespace MbD;
@@ -141,6 +148,21 @@ void MbD::ASMTAssembly::readJoints(std::vector<std::string>& lines)
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
joint = CREATE<ASMTCylindricalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tTranslationalJoint") {
joint = CREATE<ASMTTranslationalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphericalJoint") {
joint = CREATE<ASMTSphericalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tFixedJoint") {
joint = CREATE<ASMTFixedJoint>::With();
}
else if (jointsLines[0] == "\t\t\tUniversalJoint") {
joint = CREATE<ASMTUniversalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPointInPlaneJoint") {
joint = CREATE<ASMTPointInPlaneJoint>::With();
}
else {
assert(false);
}
@@ -168,6 +190,9 @@ void MbD::ASMTAssembly::readMotions(std::vector<std::string>& lines)
else if (motionsLines[0] == "\t\t\tTranslationalMotion") {
motion = CREATE<ASMTTranslationalMotion>::With();
}
else if (motionsLines[0] == "\t\t\tGeneralMotion") {
motion = CREATE<ASMTGeneralMotion>::With();
}
else {
assert(false);
}
@@ -353,8 +378,8 @@ void MbD::ASMTAssembly::readJointSeries(std::vector<std::string>& lines)
void MbD::ASMTAssembly::readMotionSeriesMany(std::vector<std::string>& lines)
{
assert(lines[0].find("MotionSeries") != std::string::npos);
while (!lines.empty()) {
assert(lines[0].find("MotionSeries") != std::string::npos);
readMotionSeries(lines);
}
}
@@ -494,9 +519,14 @@ void MbD::ASMTAssembly::createMbD(std::shared_ptr<System> mbdSys, std::shared_pt
ASMTSpatialContainer::createMbD(mbdSys, mbdUnits);
constantGravity->createMbD(mbdSys, mbdUnits);
asmtTime->createMbD(mbdSys, mbdUnits);
std::sort(parts->begin(), parts->end(), [](std::shared_ptr<ASMTPart> a, std::shared_ptr<ASMTPart> b) { return a->name < b->name; });
auto jointsMotions = std::make_shared<std::vector<std::shared_ptr<ASMTConstraintSet>>>();
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(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 : *joints) { joint->createMbD(mbdSys, mbdUnits); }
for (auto& motion : *motions) { motion->createMbD(mbdSys, mbdUnits); }
for (auto& joint : *jointsMotions) { joint->createMbD(mbdSys, mbdUnits); }
for (auto& forceTorque : *forcesTorques) { forceTorque->createMbD(mbdSys, mbdUnits); }
auto mbdSysSolver = mbdSys->systemSolver;

View File

@@ -1,7 +1,9 @@
#include "ASMTConstantGravity.h"
#include "ASMTAssembly.h"
#include "Units.h"
#include "ConstantGravity.h"
#include "System.h"
#include "Part.h"
using namespace MbD;

View File

@@ -1,6 +1,7 @@
#include "ASMTConstraintSet.h"
#include "ASMTAssembly.h"
#include "ASMTMarker.h"
#include "Joint.h"
using namespace MbD;

View File

@@ -0,0 +1,8 @@
#include "ASMTFixedJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTFixedJoint::mbdClassNew()
{
return CREATE<FixedJoint>::With();
}

14
MbDCode/ASMTFixedJoint.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include "ASMTJoint.h"
#include "FixedJoint.h"
namespace MbD {
class ASMTFixedJoint : public ASMTJoint
{
//
public:
virtual std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -1,7 +1,139 @@
#include "ASMTGeneralMotion.h"
#include "ASMTAssembly.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "CREATE.h"
#include "Constant.h"
#include "EulerAngles.h"
using namespace MbD;
void MbD::ASMTGeneralMotion::parseASMT(std::vector<std::string>& lines)
{
readName(lines);
readMarkerI(lines);
readMarkerJ(lines);
readrIJI(lines);
readangIJJ(lines);
readRotationOrder(lines);
}
void MbD::ASMTGeneralMotion::readrIJI(std::vector<std::string>& lines)
{
rIJI = std::make_shared<std::vector<std::string>>(3);
assert(lines[0].find("rIJI1") != std::string::npos);
lines.erase(lines.begin());
rIJI->at(0) = readString(lines[0]);
lines.erase(lines.begin());
assert(lines[0].find("rIJI2") != std::string::npos);
lines.erase(lines.begin());
rIJI->at(1) = readString(lines[0]);
lines.erase(lines.begin());
assert(lines[0].find("rIJI3") != std::string::npos);
lines.erase(lines.begin());
rIJI->at(2) = readString(lines[0]);
lines.erase(lines.begin());
}
void MbD::ASMTGeneralMotion::readangIJJ(std::vector<std::string>& lines)
{
angIJJ = std::make_shared<std::vector<std::string>>(3);
assert(lines[0].find("angIJJ1") != std::string::npos);
lines.erase(lines.begin());
angIJJ->at(0) = readString(lines[0]);
lines.erase(lines.begin());
assert(lines[0].find("angIJJ2") != std::string::npos);
lines.erase(lines.begin());
angIJJ->at(1) = readString(lines[0]);
lines.erase(lines.begin());
assert(lines[0].find("angIJJ3") != std::string::npos);
lines.erase(lines.begin());
angIJJ->at(2) = readString(lines[0]);
lines.erase(lines.begin());
}
void MbD::ASMTGeneralMotion::readRotationOrder(std::vector<std::string>& lines)
{
assert(lines[0].find("RotationOrder") != std::string::npos);
lines.erase(lines.begin());
rotationOrder = readString(lines[0]);
lines.erase(lines.begin());
}
std::shared_ptr<Joint> MbD::ASMTGeneralMotion::mbdClassNew()
{
return CREATE<FullMotion>::With();
}
void MbD::ASMTGeneralMotion::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTMotion::createMbD(mbdSys, mbdUnits);
auto parser = CREATE<SymbolicParser>::With();
parser->owner = this;
auto geoTime = owner->root()->geoTime();
parser->variables->insert(std::make_pair("time", geoTime));
std::shared_ptr< BasicUserFunction> userFunc;
auto fullMotion = std::static_pointer_cast<FullMotion>(mbdObject);
//rIJI
userFunc = CREATE<BasicUserFunction>::With(rIJI->at(0), 1.0);
parser->parseUserFunction(userFunc);
auto geoX = parser->stack->top();
geoX = Symbolic::times(geoX, std::make_shared<Constant>(1.0 / mbdUnits->length));
geoX->createMbD(mbdSys, mbdUnits);
auto xBlk = geoX->simplified(geoX);
userFunc = CREATE<BasicUserFunction>::With(rIJI->at(1), 1.0);
parser->parseUserFunction(userFunc);
auto geoY = parser->stack->top();
geoY = Symbolic::times(geoY, std::make_shared<Constant>(1.0 / mbdUnits->length));
geoY->createMbD(mbdSys, mbdUnits);
auto yBlk = geoY->simplified(geoY);
userFunc = CREATE<BasicUserFunction>::With(rIJI->at(2), 1.0);
parser->parseUserFunction(userFunc);
auto geoZ = parser->stack->top();
geoZ = Symbolic::times(geoZ, std::make_shared<Constant>(1.0 / mbdUnits->length));
geoZ->createMbD(mbdSys, mbdUnits);
auto zBlk = geoZ->simplified(geoZ);
auto xyzBlkList = std::initializer_list<Symsptr>{ xBlk, yBlk, zBlk };
fullMotion->frIJI = std::make_shared<FullColumn<Symsptr>>(xyzBlkList);
//angIJJ
userFunc = CREATE<BasicUserFunction>::With(angIJJ->at(0), 1.0);
parser->parseUserFunction(userFunc);
auto geoPhi = parser->stack->top();
geoPhi = Symbolic::times(geoPhi, std::make_shared<Constant>(1.0 / mbdUnits->angle));
geoPhi->createMbD(mbdSys, mbdUnits);
auto phiBlk = geoPhi->simplified(geoPhi);
userFunc = CREATE<BasicUserFunction>::With(angIJJ->at(1), 1.0);
parser->parseUserFunction(userFunc);
auto geoThe = parser->stack->top();
geoThe = Symbolic::times(geoThe, std::make_shared<Constant>(1.0 / mbdUnits->angle));
geoThe->createMbD(mbdSys, mbdUnits);
auto theBlk = geoThe->simplified(geoThe);
userFunc = CREATE<BasicUserFunction>::With(angIJJ->at(2), 1.0);
parser->parseUserFunction(userFunc);
auto geoPsi = parser->stack->top();
geoPsi = Symbolic::times(geoPsi, std::make_shared<Constant>(1.0 / mbdUnits->angle));
geoPsi->createMbD(mbdSys, mbdUnits);
auto psiBlk = geoPsi->simplified(geoPsi);
auto xyzRotBlkList = std::initializer_list<Symsptr>{ phiBlk, theBlk, psiBlk };
auto fangIJJ = std::make_shared<EulerAngles<Symsptr>>(xyzRotBlkList);
std::istringstream iss(rotationOrder);
auto rotOrder = std::make_shared<FullColumn<int>>();
int order;
for (int i = 0; i < 3; i++)
{
iss >> order;
rotOrder->push_back(order);
}
fangIJJ->rotOrder = rotOrder;
fullMotion->fangIJJ = fangIJJ;
}

View File

@@ -1,6 +1,7 @@
#pragma once
#include "ASMTMotion.h"
#include "FullMotion.h"
namespace MbD {
class ASMTGeneralMotion : public ASMTMotion
@@ -8,7 +9,14 @@ namespace MbD {
//
public:
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;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<std::vector<std::string>> rIJI, angIJJ;
std::string rotationOrder;
};
}

View File

@@ -2,6 +2,7 @@
#include "CREATE.h"
#include "ASMTSpatialContainer.h"
#include "ASMTAssembly.h"
#include "Constant.h"
using namespace MbD;
@@ -139,3 +140,8 @@ std::shared_ptr<Units> MbD::ASMTItem::mbdUnits()
}
return static_cast<ASMTAssembly*>(this)->mbdUnits;
}
std::shared_ptr<Constant> MbD::ASMTItem::sptrConstant(double value)
{
return std::make_shared<Constant>(value);
}

View File

@@ -29,6 +29,7 @@ namespace MbD {
virtual void updateFromMbD();
virtual void compareResults(AnalysisType type);
std::shared_ptr<Units> mbdUnits();
std::shared_ptr<Constant> sptrConstant(double value);
std::string name;
ASMTItem* owner;

View File

@@ -0,0 +1,32 @@
#include "ASMTPointInPlaneJoint.h"
#include "PointInPlaneJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPointInPlaneJoint::mbdClassNew()
{
return CREATE<PointInPlaneJoint>::With();
}
void MbD::ASMTPointInPlaneJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readOffset(lines);
}
void MbD::ASMTPointInPlaneJoint::readOffset(std::vector<std::string>& lines)
{
assert(lines[0].find("offset") != std::string::npos);
lines.erase(lines.begin());
offset = readDouble(lines[0]);
lines.erase(lines.begin());
}
void MbD::ASMTPointInPlaneJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto pointInPlaneJoint = std::static_pointer_cast<PointInPlaneJoint>(mbdObject);
pointInPlaneJoint->offset = offset;
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class ASMTPointInPlaneJoint : public ASMTJoint
{
//
public:
virtual std::shared_ptr<Joint> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readOffset(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
double offset;
};
}

View File

@@ -326,23 +326,62 @@ void MbD::ASMTSpatialContainer::compareResults(AnalysisType type)
auto accelerationTol = mbdUnts->acceleration * factor;
auto alphaTol = mbdUnts->alpha * factor;
auto i = xs->size() - 1;
assert(Numeric::equaltol(xs->at(i), inxs->at(i), lengthTol));
assert(Numeric::equaltol(ys->at(i), inys->at(i), lengthTol));
assert(Numeric::equaltol(zs->at(i), inzs->at(i), lengthTol));
assert(Numeric::equaltol(bryxs->at(i), inbryxs->at(i), lengthTol));
assert(Numeric::equaltol(bryys->at(i), inbryys->at(i), lengthTol));
assert(Numeric::equaltol(bryzs->at(i), inbryzs->at(i), lengthTol));
assert(Numeric::equaltol(vxs->at(i), invxs->at(i), lengthTol));
assert(Numeric::equaltol(vys->at(i), invys->at(i), lengthTol));
assert(Numeric::equaltol(vzs->at(i), invzs->at(i), lengthTol));
assert(Numeric::equaltol(omexs->at(i), inomexs->at(i), lengthTol));
assert(Numeric::equaltol(omeys->at(i), inomeys->at(i), lengthTol));
assert(Numeric::equaltol(omezs->at(i), inomezs->at(i), lengthTol));
if (type == INPUT) return;
assert(Numeric::equaltol(axs->at(i), inaxs->at(i), lengthTol));
assert(Numeric::equaltol(ays->at(i), inays->at(i), lengthTol));
assert(Numeric::equaltol(azs->at(i), inazs->at(i), lengthTol));
assert(Numeric::equaltol(alpxs->at(i), inalpxs->at(i), lengthTol));
assert(Numeric::equaltol(alpys->at(i), inalpys->at(i), lengthTol));
assert(Numeric::equaltol(alpzs->at(i), inalpzs->at(i), lengthTol));
//Pos
if (!Numeric::equaltol(xs->at(i), inxs->at(i), lengthTol)) {
std::cout << i << " xs " << xs->at(i) << ", " << i<< lengthTol << std::endl;
std::cout << i << " xs " << xs->at(i) << ", " << inxs->at(i) << ", " << lengthTol << std::endl;
}
if (!Numeric::equaltol(ys->at(i), inys->at(i), lengthTol)) {
std::cout << i << " ys " << ys->at(i) << ", " << inys->at(i) << ", " << lengthTol << std::endl;
}
if (!Numeric::equaltol(zs->at(i), inzs->at(i), lengthTol)) {
std::cout << i << " zs " << zs->at(i) << ", " << inzs->at(i) << ", " << lengthTol << std::endl;
}
if (!Numeric::equaltol(bryxs->at(i), inbryxs->at(i), angleTol)) {
std::cout << i << " bryxs " << bryxs->at(i) << ", " << inbryxs->at(i) << ", " << angleTol << std::endl;
}
if (!Numeric::equaltol(bryys->at(i), inbryys->at(i), angleTol)) {
std::cout << i << " bryys " << bryys->at(i) << ", " << inbryys->at(i) << ", " << angleTol << std::endl;
}
if (!Numeric::equaltol(bryzs->at(i), inbryzs->at(i), angleTol)) {
std::cout << i << " bryzs " << bryzs->at(i) << ", " << inbryzs->at(i) << ", " << angleTol << std::endl;
}
//Vel
if (!Numeric::equaltol(vxs->at(i), invxs->at(i), velocityTol)) {
std::cout << i << " vxs " << vxs->at(i) << ", " << invxs->at(i) << ", " << velocityTol << std::endl;
}
if (!Numeric::equaltol(vys->at(i), invys->at(i), velocityTol)) {
std::cout << i << " vys " << vys->at(i) << ", " << invys->at(i) << ", " << velocityTol << std::endl;
}
if (!Numeric::equaltol(vzs->at(i), invzs->at(i), velocityTol)) {
std::cout << i << " vzs " << vzs->at(i) << ", " << invzs->at(i) << ", " << velocityTol << std::endl;
}
if (!Numeric::equaltol(omexs->at(i), inomexs->at(i), omegaTol)) {
std::cout << i << " omexs " << omexs->at(i) << ", " << inomexs->at(i) << ", " << omegaTol << std::endl;
}
if (!Numeric::equaltol(omeys->at(i), inomeys->at(i), omegaTol)) {
std::cout << i << " omeys " << omeys->at(i) << ", " << inomeys->at(i) << ", " << omegaTol << std::endl;
}
if (!Numeric::equaltol(omezs->at(i), inomezs->at(i), omegaTol)) {
std::cout << i << " omezs " << omezs->at(i) << ", " << inomezs->at(i) << ", " << omegaTol << std::endl;
}
//Acc
if (!Numeric::equaltol(axs->at(i), inaxs->at(i), accelerationTol)) {
std::cout << i << " axs " << axs->at(i) << ", " << inaxs->at(i) << ", " << accelerationTol << std::endl;
}
if (!Numeric::equaltol(ays->at(i), inays->at(i), accelerationTol)) {
std::cout << i << " ays " << ays->at(i) << ", " << inays->at(i) << ", " << accelerationTol << std::endl;
}
if (!Numeric::equaltol(azs->at(i), inazs->at(i), accelerationTol)) {
std::cout << i << " azs " << azs->at(i) << ", " << inazs->at(i) << ", " << accelerationTol << std::endl;
}
if (!Numeric::equaltol(alpxs->at(i), inalpxs->at(i), alphaTol)) {
std::cout << i << " alpxs " << alpxs->at(i) << ", " << inalpxs->at(i) << ", " << alphaTol << std::endl;
}
if (!Numeric::equaltol(alpys->at(i), inalpys->at(i), alphaTol)) {
std::cout << i << " alpys " << alpys->at(i) << ", " << inalpys->at(i) << ", " << alphaTol << std::endl;
}
if (!Numeric::equaltol(alpzs->at(i), inalpzs->at(i), alphaTol)) {
std::cout << i << " alpzs " << alpzs->at(i) << ", " << inalpzs->at(i) << ", " << alphaTol << std::endl;
}
}

View File

@@ -0,0 +1,8 @@
#include "ASMTSphericalJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTSphericalJoint::mbdClassNew()
{
return CREATE<SphericalJoint>::With();
}

View File

@@ -0,0 +1,15 @@
#pragma once
#include "ASMTJoint.h"
#include "SphericalJoint.h"
namespace MbD {
class ASMTSphericalJoint : public ASMTJoint
{
//
public:
virtual std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -0,0 +1,8 @@
#include "ASMTTranslationalJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTTranslationalJoint::mbdClassNew()
{
return CREATE<TranslationalJoint>::With();
}

View File

@@ -0,0 +1,16 @@
#pragma once
#include "ASMTJoint.h"
#include "TranslationalJoint.h"
namespace MbD {
class ASMTTranslationalJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -1,24 +1,31 @@
#include "ASMTTranslationalMotion.h"
#include "ASMTAssembly.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "Constant.h"
using namespace MbD;
void MbD::ASMTTranslationalMotion::parseASMT(std::vector<std::string>& lines)
{
size_t pos = lines[0].find_first_not_of("\t");
auto leadingTabs = lines[0].substr(0, pos);
assert(lines[0] == (leadingTabs + "Name"));
lines.erase(lines.begin());
name = lines[0];
lines.erase(lines.begin());
assert(lines[0] == (leadingTabs + "MotionJoint"));
lines.erase(lines.begin());
motionJoint = lines[0];
lines.erase(lines.begin());
assert(lines[0] == (leadingTabs + "TranslationZ"));
lines.erase(lines.begin());
translationZ = lines[0];
lines.erase(lines.begin());
readName(lines);
readMotionJoint(lines);
readTranslationZ(lines);
//size_t pos = lines[0].find_first_not_of("\t");
//auto leadingTabs = lines[0].substr(0, pos);
//assert(lines[0] == (leadingTabs + "Name"));
//lines.erase(lines.begin());
//name = lines[0];
//lines.erase(lines.begin());
//assert(lines[0] == (leadingTabs + "MotionJoint"));
//lines.erase(lines.begin());
//motionJoint = lines[0];
//lines.erase(lines.begin());
//assert(lines[0] == (leadingTabs + "TranslationZ"));
//lines.erase(lines.begin());
//translationZ = lines[0];
//lines.erase(lines.begin());
}
void MbD::ASMTTranslationalMotion::initMarkers()
@@ -30,25 +37,36 @@ void MbD::ASMTTranslationalMotion::initMarkers()
void MbD::ASMTTranslationalMotion::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
//ASMTMotion::createMbD(mbdSys, mbdUnits);
// zFunc : = zIJ isNil
// ifTrue : [StMConstant with : 0]
// ifFalse : [zIJ isUserFunction
// ifTrue :
//[parser:= self functionParser.
// stack : = parser
// parseUserFunction : zIJ
// notifying : nil
// ifFail : nil.
// func : = stack last.
// func]
//ifFalse: [zIJ] ] .
// zFunc : = (zFunc / self mbdUnits length) createMbD simplified.
// mbdZTranslation : = self mbdObject.
// mbdZTranslation zBlk : zFunc
ASMTMotion::createMbD(mbdSys, mbdUnits);
auto parser = CREATE<SymbolicParser>::With();
parser->owner = this;
auto geoTime = owner->root()->geoTime();
parser->variables->insert(std::make_pair("time", geoTime));
auto userFunc = CREATE<BasicUserFunction>::With(translationZ, 1.0);
parser->parseUserFunction(userFunc);
auto zIJ = parser->stack->top();
zIJ = Symbolic::times(zIJ, std::make_shared<Constant>(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()
{
return CREATE<ZTranslation>::With();
}
void MbD::ASMTTranslationalMotion::readMotionJoint(std::vector<std::string>& lines)
{
assert(lines[0].find("MotionJoint") != std::string::npos);
lines.erase(lines.begin());
motionJoint = readString(lines[0]);
lines.erase(lines.begin());
}
void MbD::ASMTTranslationalMotion::readTranslationZ(std::vector<std::string>& lines)
{
assert(lines[0].find("TranslationZ") != std::string::npos);
lines.erase(lines.begin());
translationZ = readString(lines[0]);
lines.erase(lines.begin());
}

View File

@@ -12,6 +12,8 @@ namespace MbD {
void initMarkers() override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
std::shared_ptr<Joint> mbdClassNew() override;
void readMotionJoint(std::vector<std::string>& lines);
void readTranslationZ(std::vector<std::string>& lines);
std::string motionJoint, translationZ;

View File

@@ -0,0 +1,9 @@
#include "ASMTUniversalJoint.h"
#include "UniversalJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTUniversalJoint::mbdClassNew()
{
return CREATE<UniversalJoint>::With();
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class ASMTUniversalJoint : public ASMTJoint
{
//
public:
virtual std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -1,6 +1,18 @@
#include "Abs.h"
using namespace MbD;
MbD::Abs::Abs(Symsptr arg) : FunctionX(arg)
{
}
double MbD::Abs::getValue()
{
return std::abs(xx->getValue());
}
std::ostream& MbD::Abs::printOn(std::ostream& s) const
{
s << "abs(" << xx << ")";
return s;
}

View File

@@ -7,8 +7,11 @@ namespace MbD {
{
//
public:
Abs() = default;
Abs(Symsptr arg);
double getValue() override;
std::ostream& printOn(std::ostream& s) const override;
};
}

View File

@@ -1,11 +1,11 @@
#pragma once
#include "AccNewtonRaphson.h"
#include "AccICNewtonRaphson.h"
namespace MbD {
class AccICKineNewtonRaphson : public AccNewtonRaphson
class AccICKineNewtonRaphson : public AccICNewtonRaphson
{
//
//Kinematics with under constrained system
public:
void initializeGlobally() override;
void preRun() override;

View File

@@ -10,7 +10,7 @@ bool AccICNewtonRaphson::isConverged()
void AccICNewtonRaphson::preRun()
{
std::string str("MbD: Solving for quasi kinematic acceleration.");
std::string str("MbD: Solving for acceleration initial conditions.");
system->logString(str);
AccNewtonRaphson::preRun();
}

View File

@@ -5,7 +5,7 @@
namespace MbD {
class AccICNewtonRaphson : public AccNewtonRaphson
{
//
//IC acceleration with fully or under constrained system
public:
bool isConverged() override;
void preRun() override;

View File

@@ -5,7 +5,7 @@
namespace MbD {
class AccKineNewtonRaphson : public AccNewtonRaphson
{
//
//Kinematics with fully constrained system
public:
void initializeGlobally() override;
void preRun() override;

View File

@@ -58,7 +58,7 @@ void AccNewtonRaphson::fillY()
item->fillAccICIterError(y);
//std::cout << item->name << *y << std::endl;
});
std::cout << *y << std::endl;
//std::cout << *y << std::endl;
}
void AccNewtonRaphson::incrementIterNo()

View File

@@ -9,7 +9,7 @@ MbD::AngleZIecJec::AngleZIecJec()
{
}
MbD::AngleZIecJec::AngleZIecJec(EndFrmcptr frmi, EndFrmcptr frmj) : KinematicIeJe(frmi, frmj)
MbD::AngleZIecJec::AngleZIecJec(EndFrmsptr frmi, EndFrmsptr frmj) : KinematicIeJe(frmi, frmj)
{
}

View File

@@ -9,7 +9,7 @@ namespace MbD {
//thez aA00IeJe aA10IeJe cosOverSSq sinOverSSq twoCosSinOverSSqSq dSqOverSSqSq
public:
AngleZIecJec();
AngleZIecJec(EndFrmcptr frmi, EndFrmcptr frmj);
AngleZIecJec(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
virtual void init_aAijIeJe() = 0;

View File

@@ -7,7 +7,7 @@ MbD::AngleZIeqcJec::AngleZIeqcJec()
{
}
MbD::AngleZIeqcJec::AngleZIeqcJec(EndFrmcptr frmi, EndFrmcptr frmj) : AngleZIecJec(frmi, frmj)
MbD::AngleZIeqcJec::AngleZIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZIecJec(frmi, frmj)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//pthezpEI ppthezpEIpEI pcthezpEI psthezpEI
public:
AngleZIeqcJec();
AngleZIeqcJec(EndFrmcptr frmi, EndFrmcptr frmj);
AngleZIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
void init_aAijIeJe() override;

View File

@@ -8,7 +8,7 @@ MbD::AngleZIeqcJeqc::AngleZIeqcJeqc()
{
}
MbD::AngleZIeqcJeqc::AngleZIeqcJeqc(EndFrmcptr frmi, EndFrmcptr frmj) : AngleZIeqcJec(frmi, frmj)
MbD::AngleZIeqcJeqc::AngleZIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZIeqcJec(frmi, frmj)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//pthezpEJ ppthezpEIpEJ ppthezpEJpEJ
public:
AngleZIeqcJeqc();
AngleZIeqcJeqc(EndFrmcptr frmi, EndFrmcptr frmj);
AngleZIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
void init_aAijIeJe() override;

View File

@@ -0,0 +1,7 @@
#include "AnyGeneralSpline.h"
using namespace MbD;
MbD::AnyGeneralSpline::AnyGeneralSpline(Symsptr arg) : FunctionFromData(arg)
{
}

View File

@@ -0,0 +1,13 @@
#pragma once
#include "FunctionFromData.h"
namespace MbD {
class AnyGeneralSpline : public FunctionFromData
{
//derivs degree index delta
public:
AnyGeneralSpline() = default;
AnyGeneralSpline(Symsptr arg);
};
}

View File

@@ -7,6 +7,7 @@ namespace MbD {
class AnyPosICNewtonRaphson : public PosNewtonRaphson
{
//IC with fully or under constrained system
//nqsu qsuOld qsuWeights nSingularMatrixError
public:
void initialize() override;
@@ -18,8 +19,8 @@ namespace MbD {
void assignEquationNumbers() = 0;
int nqsu = -1;
std::shared_ptr<FullColumn<double>> qsuOld;
std::shared_ptr<DiagonalMatrix<double>> qsuWeights;
FColDsptr qsuOld;
DiagMatDsptr qsuWeights;
int nSingularMatrixError = -1;
};
}

View File

@@ -1,6 +1,18 @@
#include "ArcTan.h"
using namespace MbD;
MbD::ArcTan::ArcTan(Symsptr arg) : FunctionX(arg)
{
}
double MbD::ArcTan::getValue()
{
return std::atan(xx->getValue());
}
std::ostream& MbD::ArcTan::printOn(std::ostream& s) const
{
s << "arctan(" << xx << ")";
return s;
}

View File

@@ -7,8 +7,11 @@ namespace MbD {
{
//
public:
ArcTan() = default;
ArcTan(Symsptr arg);
double getValue() override;
std::ostream& printOn(std::ostream& s) const override;
};
}

12
MbDCode/ArcTan2.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "ArcTan2.h"
using namespace MbD;
MbD::ArcTan2::ArcTan2(Symsptr arg, Symsptr arg1) : FunctionXY(arg, arg1)
{
}
double MbD::ArcTan2::getValue()
{
return std::atan2(y->getValue(), x->getValue());;
}

17
MbDCode/ArcTan2.h Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include "FunctionXY.h"
namespace MbD {
class ArcTan2 : public FunctionXY
{
//
public:
ArcTan2() = default;
ArcTan2(Symsptr arg, Symsptr arg1);
double getValue() override;
};
}

View File

@@ -6,8 +6,13 @@
#include <cmath>
#include <cassert>
//#include "Symbolic.h"
namespace MbD {
using ListD = std::initializer_list<double>;
using ListListD = std::initializer_list<std::initializer_list<double>>;
using ListListPairD = std::initializer_list<std::initializer_list<std::initializer_list<double>>>;
template<typename T>
class Array : public std::vector<T>
{
@@ -167,7 +172,4 @@ namespace MbD {
{
this->at(i) *= factor;
}
using ListD = std::initializer_list<double>;
using ListListD = std::initializer_list<std::initializer_list<double>>;
using ListListPairD = std::initializer_list<std::initializer_list<std::initializer_list<double>>>;
}

View File

@@ -4,7 +4,7 @@
using namespace MbD;
AtPointConstraintIJ::AtPointConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj, int axisi) :
AtPointConstraintIJ::AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) :
ConstraintIJ(frmi, frmj), axis(axisi)
{
}

View File

@@ -9,7 +9,7 @@ namespace MbD {
{
//axis riIeJeO
public:
AtPointConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj, int axisi);
AtPointConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi);
void calcPostDynCorrectorIteration() override;
void initialize() override;

View File

@@ -5,7 +5,7 @@
using namespace MbD;
AtPointConstraintIqcJc::AtPointConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi) :
AtPointConstraintIqcJc::AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) :
AtPointConstraintIJ(frmi, frmj, axisi)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEI ppGpEIpEI iqXIminusOnePlusAxis iqEI
public:
AtPointConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi);
AtPointConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi);
void addToJointForceI(FColDsptr col) override;
void addToJointTorqueI(FColDsptr col) override;

View File

@@ -5,7 +5,7 @@
using namespace MbD;
AtPointConstraintIqcJqc::AtPointConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi) :
AtPointConstraintIqcJqc::AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) :
AtPointConstraintIqcJc(frmi, frmj, axisi)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEJ ppGpEJpEJ iqXJminusOnePlusAxis iqEJ
public:
AtPointConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi);
AtPointConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi);
void calcPostDynCorrectorIteration() override;
void initializeGlobally() override;

View File

@@ -4,7 +4,7 @@
using namespace MbD;
AtPointConstraintIqctJqc::AtPointConstraintIqctJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi) :
AtPointConstraintIqctJqc::AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi) :
AtPointConstraintIqcJqc(frmi, frmj, axisi)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpt ppGpEIpt ppGptpt
public:
AtPointConstraintIqctJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi);
AtPointConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi);
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;

View File

@@ -18,7 +18,6 @@
#include "StateData.h"
using namespace MbD;
//using namespace CAD;
void CADSystem::outputFor(AnalysisType type)
{

View File

@@ -2,13 +2,10 @@
#include<memory>
#include "ExternalSystem.h"
#include "System.h"
//using namespace MbD;
//namespace CAD {
namespace MbD {
//class System;
class CADSystem
{

View File

@@ -45,22 +45,22 @@ namespace MbD {
inst->initialize();
return inst;
}
static std::shared_ptr<T> With(EndFrmcptr frmi, EndFrmcptr frmj) {
static std::shared_ptr<T> With(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj) {
auto inst = std::make_shared<T>(frmi, frmj);
inst->initialize();
return inst;
}
static std::shared_ptr<T> With(EndFrmcptr frmi, EndFrmcptr frmj, int axis) {
static std::shared_ptr<T> With(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axis) {
auto inst = std::make_shared<T>(frmi, frmj, axis);
inst->initialize();
return inst;
}
static std::shared_ptr<T> With(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk) {
static std::shared_ptr<T> With(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, std::shared_ptr<EndFramec> frmk, int axisk) {
auto inst = std::make_shared<T>(frmi, frmj, frmk, axisk);
inst->initialize();
return inst;
}
static std::shared_ptr<Constraint> ConstraintWith(EndFrmcptr frmi, EndFrmcptr frmj, int axis) {
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axis) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axis)).name();
if (str == "class MbD::AtPointConstraintIJ") {
@@ -82,12 +82,12 @@ namespace MbD {
inst->initialize();
return inst;
}
static std::shared_ptr<T> With(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) {
static std::shared_ptr<T> With(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axisi, int axisj) {
auto inst = std::make_shared<T>(frmi, frmj, axisi, axisj);
inst->initialize();
return inst;
}
static std::shared_ptr<Constraint> ConstraintWith(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) {
static std::shared_ptr<Constraint> ConstraintWith(std::shared_ptr<EndFramec> frmi, std::shared_ptr<EndFramec> frmj, int axisi, int axisj) {
std::shared_ptr<Constraint> inst;
std::string str = typeid(T(frmi, frmj, axisi, axisj)).name();
if (str == "class MbD::DirectionCosineConstraintIJ") {

View File

@@ -3,7 +3,7 @@
using namespace MbD;
ConstVelConstraintIJ::ConstVelConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj) : ConstraintIJ(frmi, frmj)
ConstVelConstraintIJ::ConstVelConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : ConstraintIJ(frmi, frmj)
{
}

View File

@@ -9,7 +9,7 @@ namespace MbD {
{
//aA01IeJe aA10IeJe
public:
ConstVelConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj);
ConstVelConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
virtual void initA01IeJe();

View File

@@ -8,7 +8,7 @@
using namespace MbD;
MbD::ConstVelConstraintIqcJc::ConstVelConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj) : ConstVelConstraintIJ(frmi, frmj)
MbD::ConstVelConstraintIqcJc::ConstVelConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj) : ConstVelConstraintIJ(frmi, frmj)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEI ppGpEIpEI iqEI
public:
ConstVelConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj);
ConstVelConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;

View File

@@ -5,7 +5,7 @@
using namespace MbD;
MbD::ConstVelConstraintIqcJqc::ConstVelConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj) : ConstVelConstraintIqcJc(frmi, frmj)
MbD::ConstVelConstraintIqcJqc::ConstVelConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj) : ConstVelConstraintIqcJc(frmi, frmj)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEJ ppGpEIpEJ ppGpEJpEJ iqEJ
public:
ConstVelConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj);
ConstVelConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;

View File

@@ -1,9 +1,12 @@
#include "ConstantGravity.h"
#include "System.h"
#include "Part.h"
using namespace MbD;
void MbD::ConstantGravity::submitToSystem(std::shared_ptr<Item> self)
void MbD::ConstantGravity::fillAccICIterError(FColDsptr col)
{
root()->forcesTorques->push_back(std::static_pointer_cast<ForceTorqueItem>(self));
for (auto& part : *(root()->parts)) {
col->atiplusFullColumn(part->iqX(), gXYZ->times(part->m));
}
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//
public:
void submitToSystem(std::shared_ptr<Item> self) override;
void fillAccICIterError(FColDsptr col) override;
FColDsptr gXYZ;
};

View File

@@ -27,7 +27,7 @@ void MbD::ConstantVelocityJoint::initializeGlobally()
}
}
void MbD::ConstantVelocityJoint::connectsItoJ(EndFrmcptr frmIe, EndFrmcptr frmJe)
void MbD::ConstantVelocityJoint::connectsItoJ(EndFrmsptr frmIe, EndFrmsptr frmJe)
{
//"Subsequent prescribed motions may make frmIe, frmJe become prescribed end frames."
//"Use newCopyEndFrameqc to prevent efrms from becoming EndFrameqct."

View File

@@ -10,7 +10,7 @@ namespace MbD {
ConstantVelocityJoint();
ConstantVelocityJoint(const char* str);
void initializeGlobally() override;
void connectsItoJ(EndFrmcptr frmI, EndFrmcptr frmJ) override;
void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override;
};

View File

@@ -3,7 +3,7 @@
using namespace MbD;
ConstraintIJ::ConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj) : frmI(frmi), frmJ(frmj)
ConstraintIJ::ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : frmI(frmi), frmJ(frmj)
{
}

View File

@@ -1,19 +1,22 @@
#pragma once
#include "Constraint.h"
#include "EndFramec.h" //EndFrmcptr is defined
//#include "EndFramec.h" //EndFrmsptr is defined
namespace MbD {
class EndFramec;
using EndFrmsptr = std::shared_ptr<EndFramec>;
class ConstraintIJ : public Constraint
{
//frmI frmJ aConstant
public:
ConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj);
ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj);
void initialize() override;
void setConstant(double value) override;
EndFrmcptr frmI, frmJ;
EndFrmsptr frmI, frmJ;
double aConstant;
};
}

25
MbDCode/Cosine.cpp Normal file
View File

@@ -0,0 +1,25 @@
#include "Cosine.h"
#include "Sine.h"
#include "Negative.h"
using namespace MbD;
MbD::Cosine::Cosine(Symsptr arg) : FunctionX(arg)
{
}
double MbD::Cosine::getValue()
{
return std::cos(xx->getValue());
}
Symsptr MbD::Cosine::differentiateWRTx()
{
return std::make_shared<Negative>(std::make_shared<Sine>(xx));
}
std::ostream& MbD::Cosine::printOn(std::ostream& s) const
{
s << "cos(" << xx << ")";
return s;
}

19
MbDCode/Cosine.h Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include "FunctionX.h"
namespace MbD {
class Cosine : public FunctionX
{
//
public:
Cosine() = default;
Cosine(Symsptr arg);
double getValue() override;
Symsptr differentiateWRTx() override;
std::ostream& printOn(std::ostream& s) const override;
};
}

View File

@@ -5,6 +5,12 @@
#include "FullMatrix.h"
namespace MbD {
template<typename T>
class DiagonalMatrix;
template<typename T>
using DiagMatsptr = std::shared_ptr<DiagonalMatrix<T>>;
using DiagMatDsptr = std::shared_ptr<DiagonalMatrix<double>>;
template<typename T>
class DiagonalMatrix : public Array<T>
{
@@ -14,9 +20,9 @@ namespace MbD {
DiagonalMatrix(int count, const T& value) : Array<T>(count, value) {}
DiagonalMatrix(std::initializer_list<T> list) : Array<T>{ list } {}
void atiputDiagonalMatrix(int i, std::shared_ptr < DiagonalMatrix<T>> diagMat);
std::shared_ptr<DiagonalMatrix<T>> times(T factor);
std::shared_ptr<FullColumn<T>> timesFullColumn(std::shared_ptr<FullColumn<T>> fullCol);
std::shared_ptr<FullMatrix<T>> timesFullMatrix(std::shared_ptr<FullMatrix<T>> fullMat);
DiagMatsptr<T> times(T factor);
FColsptr<T> timesFullColumn(FColsptr<T> fullCol);
FMatsptr<T> timesFullMatrix(FMatsptr<T> fullMat);
int nrow() {
return (int)this->size();
}
@@ -32,18 +38,18 @@ namespace MbD {
};
template<typename T>
inline void DiagonalMatrix<T>::atiputDiagonalMatrix(int i, std::shared_ptr<DiagonalMatrix<T>> diagMat)
inline void DiagonalMatrix<T>::atiputDiagonalMatrix(int i, DiagMatsptr<T> diagMat)
{
for (int ii = 0; ii < diagMat->size(); ii++)
{
this->at(i + ii) = diagMat->at(ii);
}
}
template<typename T>
inline std::shared_ptr<DiagonalMatrix<T>> DiagonalMatrix<T>::times(T factor)
template<>
inline DiagMatDsptr DiagonalMatrix<double>::times(double factor)
{
auto nrow = (int)this->size();
auto answer = std::make_shared<DiagonalMatrix<T>>(nrow);
auto answer = std::make_shared<DiagonalMatrix<double>>(nrow);
for (int i = 0; i < nrow; i++)
{
answer->at(i) = this->at(i) * factor;
@@ -51,7 +57,12 @@ namespace MbD {
return answer;
}
template<typename T>
inline std::shared_ptr<FullColumn<T>> DiagonalMatrix<T>::timesFullColumn(std::shared_ptr<FullColumn<T>> fullCol)
inline DiagMatsptr<T> DiagonalMatrix<T>::times(T factor)
{
assert(false);
}
template<typename T>
inline FColsptr<T> DiagonalMatrix<T>::timesFullColumn(FColsptr<T> fullCol)
{
//"a*b = a(i,j)b(j) sum j."
@@ -64,7 +75,7 @@ namespace MbD {
return answer;
}
template<typename T>
inline std::shared_ptr<FullMatrix<T>> DiagonalMatrix<T>::timesFullMatrix(std::shared_ptr<FullMatrix<T>> fullMat)
inline FMatsptr<T> DiagonalMatrix<T>::timesFullMatrix(FMatsptr<T> fullMat)
{
auto nrow = (int)this->size();
auto answer = std::make_shared<FullMatrix<T>>(nrow);
@@ -128,6 +139,5 @@ namespace MbD {
s << "]";
return s;
}
using DiagMatDsptr = std::shared_ptr<DiagonalMatrix<double>>;
}

View File

@@ -8,7 +8,7 @@
using namespace MbD;
std::shared_ptr<FullRow<double>> DifferenceOperator::OneOverFactorials = []() {
FRowDsptr DifferenceOperator::OneOverFactorials = []() {
auto oneOverFactorials = std::make_shared<FullRow<double>>(10);
for (int i = 0; i < oneOverFactorials->size(); i++)
{

View File

@@ -19,10 +19,10 @@ namespace MbD {
void settime(double t);
int iStep = 0, order = 0;
std::shared_ptr<FullMatrix<double>> taylorMatrix, operatorMatrix;
FMatDsptr taylorMatrix, operatorMatrix;
double time = 0;
std::shared_ptr<std::vector<double>> timeNodes;
static std::shared_ptr<FullRow<double>> OneOverFactorials;
static FRowDsptr OneOverFactorials;
};
}

View File

@@ -0,0 +1,31 @@
#include "DifferentiatedGeneralSpline.h"
#include "GeneralSpline.h"
using namespace MbD;
MbD::DifferentiatedGeneralSpline::DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, int derivOrder) : AnyGeneralSpline(arg), generalSpline(spline), derivativeOrder(derivOrder)
{
}
double MbD::DifferentiatedGeneralSpline::getValue()
{
return std::static_pointer_cast<GeneralSpline>(generalSpline)->derivativeAt(derivativeOrder, xx->getValue());
}
Symsptr MbD::DifferentiatedGeneralSpline::differentiateWRTx()
{
auto arg = std::static_pointer_cast<GeneralSpline>(generalSpline)->xx;
auto deriv = std::make_shared<DifferentiatedGeneralSpline>(arg, generalSpline, derivativeOrder + 1);
return deriv;
}
Symsptr MbD::DifferentiatedGeneralSpline::clonesptr()
{
return std::make_shared<DifferentiatedGeneralSpline>(*this);
}
std::ostream& MbD::DifferentiatedGeneralSpline::printOn(std::ostream& s) const
{
s << "deriv(" << generalSpline << ", " << derivativeOrder << ")";
return s;
}

View File

@@ -0,0 +1,21 @@
#pragma once
#include "AnyGeneralSpline.h"
namespace MbD {
class DifferentiatedGeneralSpline : public AnyGeneralSpline
{
//derivativeOrder
public:
DifferentiatedGeneralSpline() = default;
DifferentiatedGeneralSpline(Symsptr arg, Symsptr spline, int derivOrder);
double getValue() override;
Symsptr differentiateWRTx() override;
Symsptr clonesptr() override;
std::ostream& printOn(std::ostream& s) const override;
Symsptr generalSpline;
int derivativeOrder;
};
}

View File

@@ -5,7 +5,7 @@
using namespace MbD;
DirectionCosineConstraintIJ::DirectionCosineConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIJ::DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
ConstraintIJ(frmi, frmj), axisI(axisi), axisJ(axisj)
{
}

View File

@@ -9,7 +9,7 @@ namespace MbD {
{
//axisI axisJ aAijIeJe
public:
DirectionCosineConstraintIJ(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
virtual void initaAijIeJe();

View File

@@ -5,7 +5,7 @@
using namespace MbD;
DirectionCosineConstraintIqcJc::DirectionCosineConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIqcJc::DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIJ(frmi, frmj, axisi, axisj)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEI ppGpEIpEI iqEI
public:
DirectionCosineConstraintIqcJc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void addToJointTorqueI(FColDsptr col) override;
void calcPostDynCorrectorIteration() override;

View File

@@ -5,7 +5,7 @@
using namespace MbD;
DirectionCosineConstraintIqcJqc::DirectionCosineConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIqcJqc::DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIqcJc(frmi, frmj, axisi, axisj)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpEJ ppGpEIpEJ ppGpEJpEJ iqEJ
public:
DirectionCosineConstraintIqcJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
void fillAccICIterError(FColDsptr col) override;

View File

@@ -4,7 +4,7 @@
using namespace MbD;
DirectionCosineConstraintIqctJqc::DirectionCosineConstraintIqctJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIqctJqc::DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineConstraintIqcJqc(frmi, frmj, axisi, axisj)
{
}

View File

@@ -7,7 +7,7 @@ namespace MbD {
{
//pGpt ppGpEIpt ppGpEJpt ppGptpt
public:
DirectionCosineConstraintIqctJqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineConstraintIqctJqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void fillAccICIterError(FColDsptr col) override;
void fillVelICError(FColDsptr col) override;

View File

@@ -2,6 +2,7 @@
#include "DirectionCosineIecJec.h"
#include "FullColumn.h"
#include "EndFramec.h"
using namespace MbD;
@@ -9,7 +10,7 @@ DirectionCosineIecJec::DirectionCosineIecJec()
{
}
DirectionCosineIecJec::DirectionCosineIecJec(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineIecJec::DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
KinematicIeJe(frmi, frmj), axisI(axisi), axisJ(axisj)
{

View File

@@ -13,14 +13,14 @@ namespace MbD {
//aAijIeJe axisI axisJ aAjOIe aAjOJe
public:
DirectionCosineIecJec();
DirectionCosineIecJec(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineIecJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
double value() override;
int axisI, axisJ; //0, 1, 2 = x, y, z
double aAijIeJe;
std::shared_ptr<FullColumn<double>> aAjOIe, aAjOJe;
FColDsptr aAjOIe, aAjOJe;
};
}

View File

@@ -7,7 +7,7 @@ DirectionCosineIeqcJec::DirectionCosineIeqcJec()
{
}
DirectionCosineIeqcJec::DirectionCosineIeqcJec(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineIeqcJec::DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineIecJec(frmi, frmj, axisi, axisj)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//pAijIeJepEI ppAijIeJepEIpEI pAjOIepEIT ppAjOIepEIpEI
public:
DirectionCosineIeqcJec();
DirectionCosineIeqcJec(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
void initialize() override;
@@ -19,7 +19,7 @@ namespace MbD {
FRowDsptr pAijIeJepEI;
FMatDsptr ppAijIeJepEIpEI;
FMatDsptr pAjOIepEIT;
std::shared_ptr<FullMatrix<std::shared_ptr<FullColumn<double>>>> ppAjOIepEIpEI;
FMatFColDsptr ppAjOIepEIpEI;
};
}

View File

@@ -7,7 +7,7 @@ DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc()
{
}
DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineIeqcJeqc::DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineIeqcJec(frmi, frmj, axisi, axisj)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//pAijIeJepEJ ppAijIeJepEIpEJ ppAijIeJepEJpEJ pAjOJepEJT ppAjOJepEJpEJ
public:
DirectionCosineIeqcJeqc();
DirectionCosineIeqcJeqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
void initialize() override;
@@ -21,7 +21,7 @@ namespace MbD {
FMatDsptr ppAijIeJepEIpEJ;
FMatDsptr ppAijIeJepEJpEJ;
FMatDsptr pAjOJepEJT;
std::shared_ptr<FullMatrix<std::shared_ptr<FullColumn<double>>>> ppAjOJepEJpEJ;
FMatFColDsptr ppAjOJepEJpEJ;
};
}

View File

@@ -8,7 +8,7 @@ DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc()
{
}
DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj) :
DirectionCosineIeqctJeqc::DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj) :
DirectionCosineIeqcJeqc(frmi, frmj, axisi, axisj)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//pAijIeJept ppAijIeJepEIpt ppAijIeJepEJpt ppAijIeJeptpt
public:
DirectionCosineIeqctJeqc();
DirectionCosineIeqctJeqc(EndFrmcptr frmi, EndFrmcptr frmj, int axisi, int axisj);
DirectionCosineIeqctJeqc(EndFrmsptr frmi, EndFrmsptr frmj, int axisi, int axisj);
void calcPostDynCorrectorIteration() override;
void initialize() override;

View File

@@ -1,4 +1,5 @@
#include "DispCompIecJecIe.h"
#include "EndFramec.h"
using namespace MbD;
@@ -6,7 +7,7 @@ MbD::DispCompIecJecIe::DispCompIecJecIe()
{
}
MbD::DispCompIecJecIe::DispCompIecJecIe(EndFrmcptr frmi, EndFrmcptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis)
MbD::DispCompIecJecIe::DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//axis riIeJeIe aAjOIe rIeJeO
public:
DispCompIecJecIe();
DispCompIecJecIe(EndFrmcptr frmi, EndFrmcptr frmj, int axis);
DispCompIecJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis);
void calc_value() override;
void calcPostDynCorrectorIteration() override;

View File

@@ -6,7 +6,7 @@ DispCompIecJecKec::DispCompIecJecKec()
{
}
DispCompIecJecKec::DispCompIecJecKec(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk): KinematicIeJe(frmi, frmj), efrmK(frmk), axisK(axisk)
DispCompIecJecKec::DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk): KinematicIeJe(frmi, frmj), efrmK(frmk), axisK(axisk)
{
}

View File

@@ -8,11 +8,11 @@ namespace MbD {
//efrmK axisK riIeJeKe aAjOKe rIeJeO
public:
DispCompIecJecKec();
DispCompIecJecKec(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk);
DispCompIecJecKec(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk);
double value() override;
EndFrmcptr efrmK;
EndFrmsptr efrmK;
int axisK;
double riIeJeKe;
FColDsptr aAjOKe;

View File

@@ -7,7 +7,7 @@ DispCompIecJecKeqc::DispCompIecJecKeqc()
{
}
DispCompIecJecKeqc::DispCompIecJecKeqc(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk) : DispCompIecJecKec(frmi, frmj, frmk, axisk)
DispCompIecJecKeqc::DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIecJecKec(frmi, frmj, frmk, axisk)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//priIeJeKepEK ppriIeJeKepEKpEK pAjOKepEKT ppAjOKepEKpEK
public:
DispCompIecJecKeqc();
DispCompIecJecKeqc(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk);
DispCompIecJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk);
void calcPostDynCorrectorIteration() override;
void initialize() override;

View File

@@ -1,4 +1,5 @@
#include "DispCompIecJecO.h"
#include "EndFramec.h"
using namespace MbD;
@@ -6,7 +7,7 @@ DispCompIecJecO::DispCompIecJecO()
{
}
DispCompIecJecO::DispCompIecJecO(EndFrmcptr frmi, EndFrmcptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis)
DispCompIecJecO::DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : KinematicIeJe(frmi, frmj), axis(axis)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//axis riIeJeO
public:
DispCompIecJecO();
DispCompIecJecO(EndFrmcptr frmi, EndFrmcptr frmj, int axis);
DispCompIecJecO(EndFrmsptr frmi, EndFrmsptr frmj, int axis);
void calcPostDynCorrectorIteration() override;
double value() override;

View File

@@ -7,7 +7,7 @@ MbD::DispCompIeqcJecIe::DispCompIeqcJecIe()
{
}
MbD::DispCompIeqcJecIe::DispCompIeqcJecIe(EndFrmcptr frmi, EndFrmcptr frmj, int axis) : DispCompIecJecIe(frmi, frmj, axis)
MbD::DispCompIeqcJecIe::DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIecJecIe(frmi, frmj, axis)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//priIeJeIepXI priIeJeIepEI ppriIeJeIepXIpEI ppriIeJeIepEIpEI pAjOIepEIT ppAjOIepEIpEI
public:
DispCompIeqcJecIe();
DispCompIeqcJecIe(EndFrmcptr frmi, EndFrmcptr frmj, int axis);
DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis);
void calc_ppvaluepEIpEI() override;
void calc_ppvaluepXIpEI() override;

View File

@@ -7,7 +7,7 @@ DispCompIeqcJecKeqc::DispCompIeqcJecKeqc()
{
}
DispCompIeqcJecKeqc::DispCompIeqcJecKeqc(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk) : DispCompIecJecKeqc(frmi, frmj, frmk, axisk)
DispCompIeqcJecKeqc::DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk) : DispCompIecJecKeqc(frmi, frmj, frmk, axisk)
{
}

View File

@@ -8,7 +8,7 @@ namespace MbD {
//priIeJeKepXI priIeJeKepEI ppriIeJeKepXIpEK ppriIeJeKepEIpEI ppriIeJeKepEIpEK
public:
DispCompIeqcJecKeqc();
DispCompIeqcJecKeqc(EndFrmcptr frmi, EndFrmcptr frmj, EndFrmcptr frmk, int axisk);
DispCompIeqcJecKeqc(EndFrmsptr frmi, EndFrmsptr frmj, EndFrmsptr frmk, int axisk);
void calcPostDynCorrectorIteration() override;
void initialize() override;

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