Merge pull request #36 from Ondsel-Development/MBDynIC2

Merging ASMT and MBDyn joints
This commit is contained in:
John Dupuy
2023-11-29 16:01:58 -06:00
committed by GitHub
244 changed files with 44342 additions and 2618 deletions

View File

@@ -0,0 +1,50 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTAngleJoint.h"
#include "AngleJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTAngleJoint::mbdClassNew()
{
return CREATE<AngleJoint>::With();
}
void MbD::ASMTAngleJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readTheIzJz(lines);
}
void MbD::ASMTAngleJoint::readTheIzJz(std::vector<std::string>& lines)
{
if (lines[0].find("theIzJz") == std::string::npos) {
theIzJz = 0.0;
}
else {
lines.erase(lines.begin());
theIzJz = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTAngleJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto angleJoint = std::static_pointer_cast<AngleJoint>(mbdObject);
angleJoint->theIzJz = theIzJz;
}
void MbD::ASMTAngleJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "theIzJz");
storeOnLevelDouble(os, level + 2, theIzJz);
}

View File

@@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTAngleJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> 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;
void storeOnLevel(std::ofstream& os, int level) override;
double theIzJz = 0.0;
};
}

View File

@@ -14,7 +14,7 @@ void MbD::ASMTAnimationParameters::parseASMT(std::vector<std::string>& lines)
{
//int nframe, icurrent, istart, iend, framesPerSecond;
//bool isForward;
size_t pos = lines[0].find_first_not_of("\t");
int pos = lines[0].find_first_not_of("\t");
auto leadingTabs = lines[0].substr(0, pos);
assert(lines[0] == (leadingTabs + "nframe"));
lines.erase(lines.begin());

View File

@@ -41,6 +41,21 @@
#include "ASMTItemIJ.h"
#include "ASMTKinematicIJ.h"
#include <iomanip>
#include "ASMTAngleJoint.h"
#include "ASMTConstantVelocityJoint.h"
#include "ASMTCylSphJoint.h"
#include "ASMTGearJoint.h"
#include "ASMTPointInLineJoint.h"
#include "ASMTRevCylJoint.h"
#include "ASMTSphSphJoint.h"
#include "ASMTLineInPlaneJoint.h"
#include "ASMTPlanarJoint.h"
#include "ASMTNoRotationJoint.h"
#include "ASMTParallelAxesJoint.h"
#include "ASMTPerpendicularJoint.h"
#include "ASMTRackPinionJoint.h"
#include "ASMTScrewJoint.h"
#include "SimulationStoppingError.h"
using namespace MbD;
@@ -386,6 +401,7 @@ void MbD::ASMTAssembly::runFile(const char* fileName)
if (lines[0] == "Assembly") {
lines.erase(lines.begin());
auto assembly = CREATE<ASMTAssembly>::With();
assembly->setFilename(fileName);
assembly->parseASMT(lines);
assembly->runKINEMATIC();
}
@@ -528,24 +544,70 @@ void MbD::ASMTAssembly::readJoints(std::vector<std::string>& lines)
std::vector<std::string> jointsLines(lines.begin(), it);
std::shared_ptr<ASMTJoint> joint;
while (!jointsLines.empty()) {
if (jointsLines[0] == "\t\t\tRevoluteJoint") {
joint = CREATE<ASMTRevoluteJoint>::With();
if (jointsLines[0] == "\t\t\tAngleJoint") {
joint = CREATE<ASMTAngleJoint>::With();
}
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
joint = CREATE<ASMTCylindricalJoint>::With();
else if (jointsLines[0] == "\t\t\tGearJoint") {
joint = CREATE<ASMTGearJoint>::With();
}
else if (jointsLines[0] == "\t\t\tTranslationalJoint") {
joint = CREATE<ASMTTranslationalJoint>::With();
else if (jointsLines[0] == "\t\t\tNoRotationJoint") {
joint = CREATE<ASMTNoRotationJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphericalJoint") {
joint = CREATE<ASMTSphericalJoint>::With();
else if (jointsLines[0] == "\t\t\tParallelAxesJoint") {
joint = CREATE<ASMTParallelAxesJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPerpendicularJoint") {
joint = CREATE<ASMTPerpendicularJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRackPinionJoint") {
joint = CREATE<ASMTRackPinionJoint>::With();
}
else if (jointsLines[0] == "\t\t\tScrewJoint") {
joint = CREATE<ASMTScrewJoint>::With();
}
//AtPointJoints
else if (jointsLines[0] == "\t\t\tConstantVelocityJoint") {
joint = CREATE<ASMTConstantVelocityJoint>::With();
}
else if (jointsLines[0] == "\t\t\tFixedJoint") {
joint = CREATE<ASMTFixedJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRevoluteJoint") {
joint = CREATE<ASMTRevoluteJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphericalJoint") {
joint = CREATE<ASMTSphericalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tUniversalJoint") {
joint = CREATE<ASMTUniversalJoint>::With();
}
//CompoundJoints
else if (jointsLines[0] == "\t\t\tCylSphJoint") {
joint = CREATE<ASMTCylSphJoint>::With();
}
else if (jointsLines[0] == "\t\t\tRevCylJoint") {
joint = CREATE<ASMTRevCylJoint>::With();
}
else if (jointsLines[0] == "\t\t\tSphSphJoint") {
joint = CREATE<ASMTSphSphJoint>::With();
}
//InLineJoints
else if (jointsLines[0] == "\t\t\tCylindricalJoint") {
joint = CREATE<ASMTCylindricalJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPointInLineJoint") {
joint = CREATE<ASMTPointInLineJoint>::With();
}
else if (jointsLines[0] == "\t\t\tTranslationalJoint") {
joint = CREATE<ASMTTranslationalJoint>::With();
}
//InPlaneJoints
else if (jointsLines[0] == "\t\t\tLineInPlaneJoint") {
joint = CREATE<ASMTLineInPlaneJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPlanarJoint") {
joint = CREATE<ASMTPlanarJoint>::With();
}
else if (jointsLines[0] == "\t\t\tPointInPlaneJoint") {
joint = CREATE<ASMTPointInPlaneJoint>::With();
}
@@ -790,16 +852,6 @@ void MbD::ASMTAssembly::outputFor(AnalysisType type)
assert(false);
}
void MbD::ASMTAssembly::logString(std::string& str)
{
assert(false);
}
void MbD::ASMTAssembly::logString(double value)
{
assert(false);
}
void MbD::ASMTAssembly::preMbDrun(std::shared_ptr<System> mbdSys)
{
calcCharacteristicDimensions();
@@ -830,7 +882,7 @@ double MbD::ASMTAssembly::calcCharacteristicTime()
double MbD::ASMTAssembly::calcCharacteristicMass()
{
auto n = parts->size();
auto n = (int)parts->size();
double sumOfSquares = 0.0;
for (int i = 0; i < n; i++)
{
@@ -853,7 +905,7 @@ double MbD::ASMTAssembly::calcCharacteristicLength()
auto& mkrJ = markerMap->at(connector->markerJ);
lengths->push_back(mkrJ->rpmp()->length());
}
auto n = lengths->size();
auto n = (int)lengths->size();
double sumOfSquares = std::accumulate(lengths->begin(), lengths->end(), 0.0, [](double sum, double l) { return sum + l * l; });
auto unitLength = std::sqrt(sumOfSquares / std::max((int)n, 1));
if (unitLength <= 0) unitLength = 1.0;
@@ -987,7 +1039,12 @@ void MbD::ASMTAssembly::runKINEMATIC()
auto mbdSystem = std::make_shared<System>();
mbdObject = mbdSystem;
mbdSystem->externalSystem->asmtAssembly = this;
mbdSystem->runKINEMATIC(mbdSystem);
try {
mbdSystem->runKINEMATIC(mbdSystem);
}
catch (SimulationStoppingError ex) {
}
}
void MbD::ASMTAssembly::initprincipalMassMarker()
@@ -1072,8 +1129,9 @@ std::shared_ptr<ASMTTime> MbD::ASMTAssembly::geoTime()
void MbD::ASMTAssembly::updateFromMbD()
{
ASMTSpatialContainer::updateFromMbD();
times->push_back(asmtTime->getValue());
std::cout << "Time = " << asmtTime->getValue() << std::endl;
auto time = asmtTime->getValue();
times->push_back(time);
std::cout << "Time = " << time << std::endl;
for (auto& part : *parts) part->updateFromMbD();
for (auto& joint : *joints) joint->updateFromMbD();
for (auto& motion : *motions) motion->updateFromMbD();
@@ -1091,11 +1149,11 @@ void MbD::ASMTAssembly::compareResults(AnalysisType type)
void MbD::ASMTAssembly::outputResults(AnalysisType type)
{
ASMTSpatialContainer::outputResults(type);
for (auto& part : *parts) part->outputResults(type);
for (auto& joint : *joints) joint->outputResults(type);
for (auto& motion : *motions) motion->outputResults(type);
for (auto& forceTorque : *forcesTorques) forceTorque->outputResults(type);
//ASMTSpatialContainer::outputResults(type);
//for (auto& part : *parts) part->outputResults(type);
//for (auto& joint : *joints) joint->outputResults(type);
//for (auto& motion : *motions) motion->outputResults(type);
//for (auto& forceTorque : *forcesTorques) forceTorque->outputResults(type);
}
void MbD::ASMTAssembly::addPart(std::shared_ptr<ASMTPart> part)
@@ -1215,13 +1273,13 @@ void MbD::ASMTAssembly::storeOnTimeSeries(std::ofstream& os)
if (times->empty()) return;
os << "TimeSeries" << std::endl;
os << "Number\tInput\t";
for (size_t i = 1; i < times->size(); i++)
for (int i = 1; i < times->size(); i++)
{
os << i << '\t';
}
os << std::endl;
os << "Time\tInput\t";
for (size_t i = 1; i < times->size(); i++)
for (int i = 1; i < times->size(); i++)
{
os << times->at(i) << '\t';
}
@@ -1233,4 +1291,13 @@ void MbD::ASMTAssembly::storeOnTimeSeries(std::ofstream& os)
for (auto& motion : *motions) motion->storeOnTimeSeries(os);
}
void MbD::ASMTAssembly::setFilename(std::string str)
{
std::stringstream ss;
ss << "FileName = " << str << std::endl;
auto str2 = ss.str();
logString(str2);
filename = str;
}

View File

@@ -75,8 +75,6 @@ namespace MbD {
void readMotionSeries(std::vector<std::string>& lines);
void outputFor(AnalysisType type);
void logString(std::string& str);
void logString(double value);
void preMbDrun(std::shared_ptr<System> mbdSys);
void postMbDrun();
void calcCharacteristicDimensions();
@@ -122,7 +120,9 @@ namespace MbD {
void storeOnLevelMotions(std::ofstream& os, int level);
void storeOnLevelGeneralConstraintSets(std::ofstream& os, int level);
void storeOnTimeSeries(std::ofstream& os) override;
void setFilename(std::string filename);
std::string filename = "";
std::string notes = "(Text string: '' runs: (Core.RunArray runs: #() values: #()))";
std::shared_ptr<std::vector<std::shared_ptr<ASMTPart>>> parts = std::make_shared<std::vector<std::shared_ptr<ASMTPart>>>();
std::shared_ptr<std::vector<std::shared_ptr<ASMTKinematicIJ>>> kinematicIJs = std::make_shared<std::vector<std::shared_ptr<ASMTKinematicIJ>>>();

View File

@@ -0,0 +1 @@
#include "ASMTAtPointJoint.h"

View File

@@ -0,0 +1,20 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTAtPointJoint : public ASMTJoint
{
//
public:
};
}

View File

@@ -0,0 +1,45 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTCompoundJoint.h"
#include "CompoundJoint.h"
using namespace MbD;
void MbD::ASMTCompoundJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readDistanceIJ(lines);
}
void MbD::ASMTCompoundJoint::readDistanceIJ(std::vector<std::string>& lines)
{
if (lines[0].find("distanceIJ") == std::string::npos) {
distanceIJ = 0.0;
}
else {
lines.erase(lines.begin());
distanceIJ = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTCompoundJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto compoundJoint = std::static_pointer_cast<CompoundJoint>(mbdObject);
compoundJoint->distanceIJ = distanceIJ;
}
void MbD::ASMTCompoundJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "distanceIJ");
storeOnLevelDouble(os, level + 2, distanceIJ);
}

View File

@@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTCompoundJoint : public ASMTJoint
{
//
public:
void parseASMT(std::vector<std::string>& lines) override;
void readDistanceIJ(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void storeOnLevel(std::ofstream& os, int level) override;
double distanceIJ = 0.0;
};
}

View File

@@ -29,6 +29,11 @@ void MbD::ASMTConstantGravity::createMbD(std::shared_ptr<System> mbdSys, std::sh
mbdSys->addForceTorque(mbdGravity);
}
FColDsptr MbD::ASMTConstantGravity::getg()
{
return g;
}
void MbD::ASMTConstantGravity::setg(FColDsptr gravity)
{
g = gravity;

View File

@@ -21,6 +21,7 @@ namespace MbD {
public:
void parseASMT(std::vector<std::string>& lines) override;
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
FColDsptr getg();
void setg(FColDsptr g);
void setg(double a, double b, double c);

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTConstantVelocityJoint.h"
#include "ConstantVelocityJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTConstantVelocityJoint::mbdClassNew()
{
return CREATE<ConstantVelocityJoint>::With();
}

View File

@@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTAtPointJoint.h"
namespace MbD {
class EXPORT ASMTConstantVelocityJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTCylSphJoint.h"
#include "CylSphJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTCylSphJoint::mbdClassNew()
{
return CREATE<CylSphJoint>::With();
}

View File

@@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTCompoundJoint.h"
namespace MbD {
class EXPORT ASMTCylSphJoint : public ASMTCompoundJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTCylindricalJoint.h"
#include "CylindricalJoint.h"
using namespace MbD;
@@ -16,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTCylindricalJoint::mbdClassNew()
return CREATE<CylindricalJoint>::With();
}
void MbD::ASMTCylindricalJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "CylindricalJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTCylindricalJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "CylindricalJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,16 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "CylindricalJoint.h"
#include "ASMTInLineJoint.h"
namespace MbD {
class EXPORT ASMTCylindricalJoint : public ASMTJoint
class EXPORT ASMTCylindricalJoint : public ASMTInLineJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTFixedJoint.h"
#include "FixedJoint.h"
using namespace MbD;
@@ -16,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTFixedJoint::mbdClassNew()
return CREATE<FixedJoint>::With();
}
void MbD::ASMTFixedJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "FixedJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTFixedJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "FixedJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,16 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "FixedJoint.h"
#include "ASMTAtPointJoint.h"
namespace MbD {
class EXPORT ASMTFixedJoint : public ASMTJoint
class EXPORT ASMTFixedJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -0,0 +1,68 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTGearJoint.h"
#include "GearJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTGearJoint::mbdClassNew()
{
return CREATE<GearJoint>::With();
}
void MbD::ASMTGearJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readRadiusI(lines);
readRadiusJ(lines);
}
void MbD::ASMTGearJoint::readRadiusI(std::vector<std::string>& lines)
{
if (lines[0].find("radiusI") == std::string::npos) {
radiusI = 0.0;
}
else {
lines.erase(lines.begin());
radiusI = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTGearJoint::readRadiusJ(std::vector<std::string>& lines)
{
if (lines[0].find("radiusJ") == std::string::npos) {
radiusJ = 0.0;
}
else {
lines.erase(lines.begin());
radiusJ = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTGearJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto gearJoint = std::static_pointer_cast<GearJoint>(mbdObject);
gearJoint->radiusI = radiusI;
gearJoint->radiusJ = radiusJ;
}
void MbD::ASMTGearJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "radiusI");
storeOnLevelDouble(os, level + 2, radiusI);
storeOnLevelString(os, level + 1, "radiusJ");
storeOnLevelDouble(os, level + 2, radiusJ);
//storeOnLevelString(os, level + 1, "constant");
//storeOnLevelDouble(os, level + 2, aConstant);
}

View File

@@ -0,0 +1,28 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTGearJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void parseASMT(std::vector<std::string>& lines) override;
void readRadiusI(std::vector<std::string>& lines);
void readRadiusJ(std::vector<std::string>& lines);
void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits) override;
void storeOnLevel(std::ofstream& os, int level) override;
double radiusI = 0.0, radiusJ = 0.0, aConstant = 0.0;
};
}

View File

@@ -0,0 +1,2 @@
#include "ASMTInLineJoint.h"

View File

@@ -0,0 +1,20 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class ASMTInLineJoint : public ASMTJoint
{
//
public:
};
}

View File

@@ -0,0 +1,35 @@
#include "ASMTInPlaneJoint.h"
#include "InPlaneJoint.h"
void MbD::ASMTInPlaneJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readOffset(lines);
}
void MbD::ASMTInPlaneJoint::readOffset(std::vector<std::string>& lines)
{
if (lines[0].find("offset") == std::string::npos) {
offset = 0.0;
}
else {
lines.erase(lines.begin());
offset = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTInPlaneJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto inPlaneJoint = std::static_pointer_cast<InPlaneJoint>(mbdObject);
inPlaneJoint->offset = offset;
}
void MbD::ASMTInPlaneJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "offset");
storeOnLevelDouble(os, level + 2, offset);
}

View File

@@ -0,0 +1,26 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class ASMTInPlaneJoint : public ASMTJoint
{
//
public:
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;
void storeOnLevel(std::ofstream& os, int level) override;
double offset = 0.0;
};
}

View File

@@ -39,6 +39,13 @@ void MbD::ASMTItem::noop()
//No Operations
}
std::string MbD::ASMTItem::classname()
{
std::string str = typeid(*this).name();
auto answer = str.substr(11, str.size() - 11);
return answer;
}
void MbD::ASMTItem::setName(std::string str)
{
name = str;
@@ -220,7 +227,7 @@ void MbD::ASMTItem::storeOnLevelBool(std::ofstream& os, int level, bool value)
void MbD::ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector<double> array)
{
storeOnLevelTabs(os, level);
for (size_t i = 0; i < array.size(); i++)
for (int i = 0; i < array.size(); i++)
{
os << array[i] << '\t';
}
@@ -237,3 +244,13 @@ void MbD::ASMTItem::storeOnTimeSeries(std::ofstream& os)
{
assert(false);
}
void MbD::ASMTItem::logString(std::string& str)
{
std::cout << str << std::endl;
}
void MbD::ASMTItem::logString(const char* chars)
{
std::cout << chars << std::endl;
}

View File

@@ -27,6 +27,7 @@ namespace MbD {
virtual void initialize();
void noop();
virtual std::string classname();
void setName(std::string str);
virtual void parseASMT(std::vector<std::string>& lines);
FRowDsptr readRowOfDoubles(std::string& line);
@@ -56,6 +57,8 @@ namespace MbD {
void storeOnLevelArray(std::ofstream& os, int level, std::vector<double> array);
void storeOnLevelName(std::ofstream& os, int level);
virtual void storeOnTimeSeries(std::ofstream& os);
void logString(std::string& str);
void logString(const char* chars);
std::string name;
ASMTItem* owner = nullptr;
@@ -65,7 +68,7 @@ namespace MbD {
//inline void ASMTItem::storeOnLevelArray(std::ofstream& os, int level, std::vector<T> array)
//{
// storeOnLevelTabs(os, level);
// for (size_t i = 0; i < array.size(); i++)
// for (int i = 0; i < array.size(); i++)
// {
// os << array[i] << '\t';
// }

View File

@@ -108,37 +108,37 @@ void MbD::ASMTItemIJ::storeOnLevel(std::ofstream& os, int level)
void MbD::ASMTItemIJ::storeOnTimeSeries(std::ofstream& os)
{
os << "FXonI\t";
for (size_t i = 0; i < fxs->size(); i++)
for (int i = 0; i < fxs->size(); i++)
{
os << fxs->at(i) << '\t';
}
os << std::endl;
os << "FYonI\t";
for (size_t i = 0; i < fys->size(); i++)
for (int i = 0; i < fys->size(); i++)
{
os << fys->at(i) << '\t';
}
os << std::endl;
os << "FZonI\t";
for (size_t i = 0; i < fzs->size(); i++)
for (int i = 0; i < fzs->size(); i++)
{
os << fzs->at(i) << '\t';
}
os << std::endl;
os << "TXonI\t";
for (size_t i = 0; i < txs->size(); i++)
for (int i = 0; i < txs->size(); i++)
{
os << txs->at(i) << '\t';
}
os << std::endl;
os << "TYonI\t";
for (size_t i = 0; i < tys->size(); i++)
for (int i = 0; i < tys->size(); i++)
{
os << tys->at(i) << '\t';
}
os << std::endl;
os << "TZonI\t";
for (size_t i = 0; i < tzs->size(); i++)
for (int i = 0; i < tzs->size(); i++)
{
os << tzs->at(i) << '\t';
}

View File

@@ -38,10 +38,18 @@ void MbD::ASMTJoint::readJointSeries(std::vector<std::string>& lines)
void MbD::ASMTJoint::storeOnLevel(std::ofstream& os, int level)
{
assert(false);
auto jointType = classname();
jointType = jointType.substr(4, jointType.size() - 4); //Remove ASMT in name
storeOnLevelString(os, level, jointType);
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTJoint::storeOnTimeSeries(std::ofstream& os)
{
assert(false);
std::string label = typeid(*this).name();
label = label.substr(15, label.size() - 15);
os << label << "Series\t" << fullName("") << std::endl;
ASMTItemIJ::storeOnTimeSeries(os);
}

View File

@@ -9,9 +9,10 @@
#pragma once
#include "ASMTConstraintSet.h"
#include "ForceTorqueData.h"
namespace MbD {
class ForceTorqueData;
class EXPORT ASMTJoint : public ASMTConstraintSet
{
//

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTLineInPlaneJoint.h"
#include "LineInPlaneJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTLineInPlaneJoint::mbdClassNew()
{
return CREATE<LineInPlaneJoint>::With();
}

View File

@@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTInPlaneJoint.h"
namespace MbD {
class EXPORT ASMTLineInPlaneJoint : public ASMTInPlaneJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -17,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTNoRotationJoint::mbdClassNew()
return CREATE<NoRotationJoint>::With();
}
void MbD::ASMTNoRotationJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "NoRotationJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTNoRotationJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "NoRotationJointSeries\t" << fullName("") << std::endl;

View File

@@ -16,7 +16,6 @@ namespace MbD {
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTParallelAxesJoint.h"
#include "ParallelAxesJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTParallelAxesJoint::mbdClassNew()
{
return CREATE<ParallelAxesJoint>::With();
}

View File

@@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTParallelAxesJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTPerpendicularJoint.h"
#include "PerpendicularJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPerpendicularJoint::mbdClassNew()
{
return CREATE<PerpendicularJoint>::With();
}

View File

@@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTPerpendicularJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTPlanarJoint.h"
#include "PlanarJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTPlanarJoint::mbdClassNew()
{
return CREATE<PlanarJoint>::With();
}

View File

@@ -0,0 +1,22 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTInPlaneJoint.h"
namespace MbD {
class EXPORT ASMTPlanarJoint : public ASMTInPlaneJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -17,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTPointInLineJoint::mbdClassNew()
return CREATE<PointInLineJoint>::With();
}
void MbD::ASMTPointInLineJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "PointInLineJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTPointInLineJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "PointInLineJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,15 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "ASMTInLineJoint.h"
namespace MbD {
class EXPORT ASMTPointInLineJoint : public ASMTJoint
class EXPORT ASMTPointInLineJoint : public ASMTInLineJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -17,39 +17,6 @@ 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)
{
if (lines[0].find("offset") == std::string::npos) {
offset = 0.0;
}
else {
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;
}
void MbD::ASMTPointInPlaneJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "PointInPlaneJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTPointInPlaneJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "PointInPlaneJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,21 +8,16 @@
#pragma once
#include "ASMTJoint.h"
#include "ASMTInPlaneJoint.h"
namespace MbD {
class EXPORT ASMTPointInPlaneJoint : public ASMTJoint
class EXPORT ASMTPointInPlaneJoint : public ASMTInPlaneJoint
{
//
public:
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;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
double offset;
};
}

View File

@@ -19,7 +19,7 @@ MbD::ASMTPrincipalMassMarker::ASMTPrincipalMassMarker()
void MbD::ASMTPrincipalMassMarker::parseASMT(std::vector<std::string>& lines)
{
size_t pos = lines[0].find_first_not_of("\t");
int pos = lines[0].find_first_not_of("\t");
auto leadingTabs = lines[0].substr(0, pos);
assert(lines[0] == (leadingTabs + "Name"));
lines.erase(lines.begin());

View File

@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTRackPinionJoint.h"
#include "RackPinJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRackPinionJoint::mbdClassNew()
{
return CREATE<RackPinJoint>::With();
}
void MbD::ASMTRackPinionJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readPitchRadius(lines);
}
void MbD::ASMTRackPinionJoint::readPitchRadius(std::vector<std::string>& lines)
{
if (lines[0].find("pitchRadius") == std::string::npos) {
pitchRadius = 0.0;
}
else {
lines.erase(lines.begin());
pitchRadius = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTRackPinionJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto rackPinJoint = std::static_pointer_cast<RackPinJoint>(mbdObject);
rackPinJoint->pitchRadius = pitchRadius;
}
void MbD::ASMTRackPinionJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "pitchRadius");
storeOnLevelDouble(os, level + 2, pitchRadius);
//storeOnLevelString(os, level + 1, "constant");
//storeOnLevelDouble(os, level + 2, aConstant);
}

View File

@@ -0,0 +1,27 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTRackPinionJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> 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;
void storeOnLevel(std::ofstream& os, int level) override;
double pitchRadius = 0.0, aConstant = 0.0;
};
}

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTRevCylJoint.h"
#include "RevCylJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTRevCylJoint::mbdClassNew()
{
return CREATE<RevCylJoint>::With();
}

View File

@@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTCompoundJoint.h"
namespace MbD {
class EXPORT ASMTRevCylJoint : public ASMTCompoundJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTRevoluteJoint.h"
#include "RevoluteJoint.h"
using namespace MbD;
@@ -16,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTRevoluteJoint::mbdClassNew()
return CREATE<RevoluteJoint>::With();
}
void MbD::ASMTRevoluteJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "RevoluteJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTRevoluteJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "RevoluteJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,16 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "RevoluteJoint.h"
#include "ASMTAtPointJoint.h"
namespace MbD {
class EXPORT ASMTRevoluteJoint : public ASMTJoint
class EXPORT ASMTRevoluteJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -68,12 +68,12 @@ void MbD::ASMTRotationalMotion::createMbD(std::shared_ptr<System> mbdSys, std::s
auto userFunc = std::make_shared<BasicUserFunction>(rotationZ, 1.0);
parser->parseUserFunction(userFunc);
auto geoPhi = parser->stack->top();
std::cout << *geoPhi << std::endl;
//std::cout << *geoPhi << std::endl;
geoPhi = Symbolic::times(geoPhi, sptrConstant(1.0 / mbdUnits->angle));
geoPhi->createMbD(mbdSys, mbdUnits);
std::cout << *geoPhi << std::endl;
//std::cout << *geoPhi << std::endl;
auto simple = geoPhi->simplified(geoPhi);
std::cout << *simple << std::endl;
//std::cout << *simple << std::endl;
std::static_pointer_cast<ZRotation>(mbdObject)->phiBlk = simple;
}

View File

@@ -0,0 +1,52 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTScrewJoint.h"
#include "ScrewJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTScrewJoint::mbdClassNew()
{
return CREATE<ScrewJoint>::With();
}
void MbD::ASMTScrewJoint::parseASMT(std::vector<std::string>& lines)
{
ASMTJoint::parseASMT(lines);
readPitch(lines);
}
void MbD::ASMTScrewJoint::readPitch(std::vector<std::string>& lines)
{
if (lines[0].find("pitch") == std::string::npos) {
pitch = 0.0;
}
else {
lines.erase(lines.begin());
pitch = readDouble(lines[0]);
lines.erase(lines.begin());
}
}
void MbD::ASMTScrewJoint::createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits)
{
ASMTJoint::createMbD(mbdSys, mbdUnits);
auto screwJoint = std::static_pointer_cast<ScrewJoint>(mbdObject);
screwJoint->pitch = pitch;
}
void MbD::ASMTScrewJoint::storeOnLevel(std::ofstream& os, int level)
{
ASMTJoint::storeOnLevel(os, level);
storeOnLevelString(os, level + 1, "pitch");
storeOnLevelDouble(os, level + 2, pitch);
//storeOnLevelString(os, level + 1, "constant");
//storeOnLevelDouble(os, level + 2, aConstant);
}

View File

@@ -0,0 +1,26 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTJoint.h"
namespace MbD {
class EXPORT ASMTScrewJoint : public ASMTJoint
{
//
public:
std::shared_ptr<Joint> 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;
void storeOnLevel(std::ofstream& os, int level) override;
double pitch = 0.0, aConstant = 0.0;
};
}

View File

@@ -14,7 +14,7 @@ void MbD::ASMTSimulationParameters::parseASMT(std::vector<std::string>& lines)
{
//tstart, tend, hmin, hmax, hout, errorTol;
size_t pos = lines[0].find_first_not_of("\t");
int pos = lines[0].find_first_not_of("\t");
auto leadingTabs = lines[0].substr(0, pos);
assert(lines[0] == (leadingTabs + "tstart"));
lines.erase(lines.begin());

View File

@@ -333,6 +333,7 @@ void MbD::ASMTSpatialContainer::updateFromMbD()
auto mbdPart = std::static_pointer_cast<Part>(mbdObject);
auto rOcmO = mbdPart->qX()->times(mbdUnts->length);
auto aAOp = mbdPart->aAOp();
std::cout << "aAOp" << *aAOp << std::endl;
auto vOcmO = mbdPart->qXdot()->times(mbdUnts->velocity);
auto omeOPO = mbdPart->omeOpO()->times(mbdUnts->omega);
omega3D = omeOPO;
@@ -355,6 +356,7 @@ void MbD::ASMTSpatialContainer::updateFromMbD()
bryxs->push_back(bryantAngles->at(0));
bryys->push_back(bryantAngles->at(1));
bryzs->push_back(bryantAngles->at(2));
std::cout << "bry " << *bryantAngles << std::endl;
vxs->push_back(vOPO->at(0));
vys->push_back(vOPO->at(1));
vzs->push_back(vOPO->at(2));
@@ -383,60 +385,60 @@ void MbD::ASMTSpatialContainer::compareResults(AnalysisType type)
auto i = xs->size() - 1;
//Pos
if (!Numeric::equaltol(xs->at(i), inxs->at(i), lengthTol)) {
std::cout << i << " xs " << xs->at(i) << ", " << inxs->at(i) << ", " << lengthTol << std::endl;
std::cout << i << " xs " << xs->at(i) << " != " << inxs->at(i) << " tol = " << 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;
std::cout << i << " ys " << ys->at(i) << " != " << inys->at(i) << " tol = " << 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;
std::cout << i << " zs " << zs->at(i) << " != " << inzs->at(i) << " tol = " << 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;
std::cout << i << " bryxs " << bryxs->at(i) << " != " << inbryxs->at(i) << " tol = " << 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;
std::cout << i << " bryys " << bryys->at(i) << " != " << inbryys->at(i) << " tol = " << 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;
std::cout << i << " bryzs " << bryzs->at(i) << " != " << inbryzs->at(i) << " tol = " << 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;
std::cout << i << " vxs " << vxs->at(i) << " != " << invxs->at(i) << " tol = " << 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;
std::cout << i << " vys " << vys->at(i) << " != " << invys->at(i) << " tol = " << 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;
std::cout << i << " vzs " << vzs->at(i) << " != " << invzs->at(i) << " tol = " << 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;
std::cout << i << " omexs " << omexs->at(i) << " != " << inomexs->at(i) << " tol = " << 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;
std::cout << i << " omeys " << omeys->at(i) << " != " << inomeys->at(i) << " tol = " << 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;
std::cout << i << " omezs " << omezs->at(i) << " != " << inomezs->at(i) << " tol = " << 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;
std::cout << i << " axs " << axs->at(i) << " != " << inaxs->at(i) << " tol = " << 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;
std::cout << i << " ays " << ays->at(i) << " != " << inays->at(i) << " tol = " << 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;
std::cout << i << " azs " << azs->at(i) << " != " << inazs->at(i) << " tol = " << 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;
std::cout << i << " alpxs " << alpxs->at(i) << " != " << inalpxs->at(i) << " tol = " << 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;
std::cout << i << " alpys " << alpys->at(i) << " != " << inalpys->at(i) << " tol = " << 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;
std::cout << i << " alpzs " << alpzs->at(i) << " != " << inalpzs->at(i) << " tol = " << alphaTol << std::endl;
}
}
@@ -601,116 +603,116 @@ void MbD::ASMTSpatialContainer::storeOnLevelRefSurfaces(std::ofstream& os, int l
void MbD::ASMTSpatialContainer::storeOnTimeSeries(std::ofstream& os)
{
os << "X\t";
for (size_t i = 0; i < xs->size(); i++)
for (int i = 0; i < xs->size(); i++)
{
os << xs->at(i) << '\t';
}
os << std::endl;
os << "Y\t";
for (size_t i = 0; i < ys->size(); i++)
for (int i = 0; i < ys->size(); i++)
{
os << ys->at(i) << '\t';
}
os << std::endl;
os << "Z\t";
for (size_t i = 0; i < zs->size(); i++)
for (int i = 0; i < zs->size(); i++)
{
os << zs->at(i) << '\t';
}
os << std::endl;
os << "Bryantx\t";
for (size_t i = 0; i < bryxs->size(); i++)
for (int i = 0; i < bryxs->size(); i++)
{
os << bryxs->at(i) << '\t';
}
os << std::endl;
os << "Bryanty\t";
for (size_t i = 0; i < bryys->size(); i++)
for (int i = 0; i < bryys->size(); i++)
{
os << bryys->at(i) << '\t';
}
os << std::endl;
os << "Bryantz\t";
for (size_t i = 0; i < bryzs->size(); i++)
for (int i = 0; i < bryzs->size(); i++)
{
os << bryzs->at(i) << '\t';
}
os << std::endl;
os << "VX\t";
for (size_t i = 0; i < vxs->size(); i++)
for (int i = 0; i < vxs->size(); i++)
{
os << vxs->at(i) << '\t';
}
os << std::endl;
os << "VY\t";
for (size_t i = 0; i < vys->size(); i++)
for (int i = 0; i < vys->size(); i++)
{
os << vys->at(i) << '\t';
}
os << std::endl;
os << "VZ\t";
for (size_t i = 0; i < vzs->size(); i++)
for (int i = 0; i < vzs->size(); i++)
{
os << vzs->at(i) << '\t';
}
os << std::endl;
os << "OmegaX\t";
for (size_t i = 0; i < omexs->size(); i++)
for (int i = 0; i < omexs->size(); i++)
{
os << omexs->at(i) << '\t';
}
os << std::endl;
os << "OmegaY\t";
for (size_t i = 0; i < omeys->size(); i++)
for (int i = 0; i < omeys->size(); i++)
{
os << omeys->at(i) << '\t';
}
os << std::endl;
os << "OmegaZ\t";
for (size_t i = 0; i < omezs->size(); i++)
for (int i = 0; i < omezs->size(); i++)
{
os << omezs->at(i) << '\t';
}
os << std::endl;
os << "AX\t";
for (size_t i = 0; i < axs->size(); i++)
for (int i = 0; i < axs->size(); i++)
{
os << axs->at(i) << '\t';
}
os << std::endl;
os << "AY\t";
for (size_t i = 0; i < ays->size(); i++)
for (int i = 0; i < ays->size(); i++)
{
os << ays->at(i) << '\t';
}
os << std::endl;
os << "AZ\t";
for (size_t i = 0; i < azs->size(); i++)
for (int i = 0; i < azs->size(); i++)
{
os << azs->at(i) << '\t';
}
os << std::endl;
os << "AlphaX\t";
for (size_t i = 0; i < alpxs->size(); i++)
for (int i = 0; i < alpxs->size(); i++)
{
os << alpxs->at(i) << '\t';
}
os << std::endl;
os << "AlphaY\t";
for (size_t i = 0; i < alpys->size(); i++)
for (int i = 0; i < alpys->size(); i++)
{
os << alpys->at(i) << '\t';
}
os << std::endl;
os << "AlphaZ\t";
for (size_t i = 0; i < alpzs->size(); i++)
for (int i = 0; i < alpzs->size(); i++)
{
os << alpzs->at(i) << '\t';
}
os << std::endl;
}
FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(size_t i)
FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(int i)
{
auto vec3 = std::make_shared<FullColumn<double>>(3);
vec3->atiput(0, vxs->at(i));
@@ -719,7 +721,7 @@ FColDsptr MbD::ASMTSpatialContainer::getVelocity3D(size_t i)
return vec3;
}
FColDsptr MbD::ASMTSpatialContainer::getOmega3D(size_t i)
FColDsptr MbD::ASMTSpatialContainer::getOmega3D(int i)
{
auto vec3 = std::make_shared<FullColumn<double>>(3);
vec3->atiput(0, omexs->at(i));

View File

@@ -86,8 +86,8 @@ namespace MbD {
void storeOnLevelRefCurves(std::ofstream& os, int level);
void storeOnLevelRefSurfaces(std::ofstream& os, int level);
void storeOnTimeSeries(std::ofstream& os) override;
FColDsptr getVelocity3D(size_t i);
FColDsptr getOmega3D(size_t i);
FColDsptr getVelocity3D(int i);
FColDsptr getOmega3D(int i);
FColDsptr velocity3D = std::make_shared<FullColumn<double>>(3);
FColDsptr omega3D = std::make_shared<FullColumn<double>>(3);

View File

@@ -131,7 +131,7 @@ void MbD::ASMTSpatialItem::storeOnLevelRotationMatrix(std::ofstream& os, int lev
}
FColDsptr MbD::ASMTSpatialItem::getPosition3D(size_t i)
FColDsptr MbD::ASMTSpatialItem::getPosition3D(int i)
{
auto vec3 = std::make_shared<FullColumn<double>>(3);
vec3->atiput(0, xs->at(i));
@@ -140,7 +140,7 @@ FColDsptr MbD::ASMTSpatialItem::getPosition3D(size_t i)
return vec3;
}
FMatDsptr MbD::ASMTSpatialItem::getRotationMatrix(size_t i)
FMatDsptr MbD::ASMTSpatialItem::getRotationMatrix(int i)
{
auto bryantAngles = std::make_shared<EulerAngles<double>>();
bryantAngles->setRotOrder(1, 2, 3);

View File

@@ -31,8 +31,8 @@ namespace MbD {
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnLevelPosition(std::ofstream& os, int level);
void storeOnLevelRotationMatrix(std::ofstream& os, int level);
FColDsptr getPosition3D(size_t i);
FMatDsptr getRotationMatrix(size_t i);
FColDsptr getPosition3D(int i);
FMatDsptr getRotationMatrix(int i);
FColDsptr position3D = std::make_shared<FullColumn<double>>(3);
FMatDsptr rotationMatrix = std::make_shared<FullMatrixDouble>(ListListD{

View File

@@ -0,0 +1,18 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <fstream>
#include "ASMTSphSphJoint.h"
#include "SphSphJoint.h"
using namespace MbD;
std::shared_ptr<Joint> MbD::ASMTSphSphJoint::mbdClassNew()
{
return CREATE<SphSphJoint>::With();
}

View File

@@ -0,0 +1,21 @@
/***************************************************************************
* Copyright (c) 2023 Ondsel, Inc. *
* *
* This file is part of OndselSolver. *
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#pragma once
#include "ASMTCompoundJoint.h"
namespace MbD {
class EXPORT ASMTSphSphJoint : public ASMTCompoundJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
};
}

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTSphericalJoint.h"
#include "SphericalJoint.h"
using namespace MbD;
@@ -16,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTSphericalJoint::mbdClassNew()
return CREATE<SphericalJoint>::With();
}
void MbD::ASMTSphericalJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "SphericalJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTSphericalJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "SphericalJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,16 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "SphericalJoint.h"
#include "ASMTAtPointJoint.h"
namespace MbD {
class EXPORT ASMTSphericalJoint : public ASMTJoint
class EXPORT ASMTSphericalJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -8,6 +8,7 @@
#include <fstream>
#include "ASMTTranslationalJoint.h"
#include "TranslationalJoint.h"
using namespace MbD;
@@ -16,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTTranslationalJoint::mbdClassNew()
return CREATE<TranslationalJoint>::With();
}
void MbD::ASMTTranslationalJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "TranslationalJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTTranslationalJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "TranslationalJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,16 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "TranslationalJoint.h"
#include "ASMTInLineJoint.h"
namespace MbD {
class EXPORT ASMTTranslationalJoint : public ASMTJoint
class EXPORT ASMTTranslationalJoint : public ASMTInLineJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;

View File

@@ -17,14 +17,6 @@ std::shared_ptr<Joint> MbD::ASMTUniversalJoint::mbdClassNew()
return CREATE<UniversalJoint>::With();
}
void MbD::ASMTUniversalJoint::storeOnLevel(std::ofstream& os, int level)
{
storeOnLevelString(os, level, "UniversalJoint");
storeOnLevelString(os, level + 1, "Name");
storeOnLevelString(os, level + 2, name);
ASMTItemIJ::storeOnLevel(os, level);
}
void MbD::ASMTUniversalJoint::storeOnTimeSeries(std::ofstream& os)
{
os << "UniversalJointSeries\t" << fullName("") << std::endl;

View File

@@ -8,15 +8,14 @@
#pragma once
#include "ASMTJoint.h"
#include "ASMTAtPointJoint.h"
namespace MbD {
class EXPORT ASMTUniversalJoint : public ASMTJoint
class EXPORT ASMTUniversalJoint : public ASMTAtPointJoint
{
//
public:
std::shared_ptr<Joint> mbdClassNew() override;
void storeOnLevel(std::ofstream& os, int level) override;
void storeOnTimeSeries(std::ofstream& os) override;
};

View File

@@ -23,10 +23,10 @@ AbsConstraint::AbsConstraint(int i)
void AbsConstraint::calcPostDynCorrectorIteration()
{
if (axis < 3) {
aG = static_cast<PartFrame*>(owner)->qX->at((size_t)axis);
aG = static_cast<PartFrame*>(owner)->qX->at((int)axis);
}
else {
aG = static_cast<PartFrame*>(owner)->qE->at((size_t)axis - 3);
aG = static_cast<PartFrame*>(owner)->qE->at((int)axis - 3);
}
}
@@ -63,10 +63,10 @@ void AbsConstraint::fillAccICIterError(FColDsptr col)
auto partFrame = static_cast<PartFrame*>(owner);
double sum;
if (axis < 3) {
sum = partFrame->qXddot->at((size_t)axis);
sum = partFrame->qXddot->at((int)axis);
}
else {
sum = partFrame->qEddot->at((size_t)axis - 3);
sum = partFrame->qEddot->at((int)axis - 3);
}
col->atiplusNumber(iG, sum);
}

View File

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

View File

@@ -5,7 +5,7 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include "corecrt_math_defines.h"
#include "AngleZIecJec.h"
@@ -51,6 +51,7 @@ void MbD::AngleZIecJec::initializeGlobally()
void MbD::AngleZIecJec::initializeLocally()
{
if (!aA00IeJe) init_aAijIeJe();
aA00IeJe->initializeLocally();
aA10IeJe->initializeLocally();
}
@@ -59,6 +60,16 @@ void MbD::AngleZIecJec::postInput()
{
aA00IeJe->postInput();
aA10IeJe->postInput();
if (thez == std::numeric_limits<double>::min()) {
auto cthez = aA00IeJe->value();
auto sthez = aA10IeJe->value();
if (cthez > 0.0) {
thez = std::atan2(sthez, cthez);
}
else {
thez = Numeric::arcTan0to2piYoverX(sthez, cthez);
}
}
KinematicIeJe::postInput();
}

View File

@@ -32,7 +32,8 @@ namespace MbD {
void simUpdateAll() override;
double value() override;
double thez, cosOverSSq, sinOverSSq, twoCosSinOverSSqSq, dSqOverSSqSq;
double thez = std::numeric_limits<double>::min();
double cosOverSSq = 0.0, sinOverSSq = 0.0, twoCosSinOverSSqSq = 0.0, dSqOverSSqSq = 0.0;
std::shared_ptr<DirectionCosineIeqcJec> aA00IeJe, aA10IeJe;
};
}

View File

@@ -17,13 +17,15 @@ MbD::AngleZIeqcJec::AngleZIeqcJec()
MbD::AngleZIeqcJec::AngleZIeqcJec(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZIecJec(frmi, frmj)
{
pthezpEI = std::make_shared<FullRow<double>>(4);
ppthezpEIpEI = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::AngleZIeqcJec::calcPostDynCorrectorIteration()
{
AngleZIecJec::calcPostDynCorrectorIteration();
auto pcthezpEI = aA00IeJe->pvaluepEI();
auto psthezpEI = aA10IeJe->pvaluepEI();
pcthezpEI = aA00IeJe->pvaluepEI();
psthezpEI = aA10IeJe->pvaluepEI();
auto ppcthezpEIpEI = aA00IeJe->ppvaluepEIpEI();
auto ppsthezpEIpEI = aA10IeJe->ppvaluepEIpEI();
for (int i = 0; i < 4; i++)

View File

@@ -18,6 +18,9 @@ MbD::AngleZIeqcJeqc::AngleZIeqcJeqc()
MbD::AngleZIeqcJeqc::AngleZIeqcJeqc(EndFrmsptr frmi, EndFrmsptr frmj) : AngleZIeqcJec(frmi, frmj)
{
pthezpEJ = std::make_shared<FullRow<double>>(4);
ppthezpEIpEJ = std::make_shared<FullMatrixDouble>(4, 4);
ppthezpEJpEJ = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::AngleZIeqcJeqc::calcPostDynCorrectorIteration()

View File

@@ -42,7 +42,7 @@ namespace MbD {
virtual double maxMagnitude() = 0;
double maxMagnitudeOfVector();
void equalArrayAt(std::shared_ptr<Array<T>> array, int i);
virtual void atiput(int i, T value);
void atiput(int i, T value);
void magnifySelf(T factor);
void negateSelf();
void atitimes(int i, double factor);
@@ -66,14 +66,14 @@ namespace MbD {
template<typename T>
inline void Array<T>::copyFrom(std::shared_ptr<Array<T>> x)
{
for (size_t i = 0; i < x->size(); i++) {
for (int i = 0; i < x->size(); i++) {
this->at(i) = x->at(i);
}
}
template<typename T>
inline void Array<T>::zeroSelf()
{
for (size_t i = 0; i < this->size(); i++) {
for (int i = 0; i < this->size(); i++) {
this->at(i) = (T)0;
}
}
@@ -98,7 +98,7 @@ namespace MbD {
//inline double Array<double>::maxMagnitude()
//{
// double max = 0.0;
// for (size_t i = 0; i < this->size(); i++)
// for (int i = 0; i < this->size(); i++)
// {
// auto element = this->at(i);
// if (element < 0.0) element = -element;
@@ -110,7 +110,7 @@ namespace MbD {
inline double Array<T>::maxMagnitudeOfVector()
{
double answer = 0.0;
for (size_t i = 0; i < this->size(); i++)
for (int i = 0; i < this->size(); i++)
{
double mag = std::abs(this->at(i));
if (answer < mag) answer = mag;
@@ -120,9 +120,9 @@ namespace MbD {
template<typename T>
inline void Array<T>::equalArrayAt(std::shared_ptr<Array<T>> array, int i)
{
for (size_t ii = 0; ii < this->size(); ii++)
for (int ii = 0; ii < this->size(); ii++)
{
this->at(ii) = array->at((size_t)i + ii);
this->at(ii) = array->at((int)i + ii);
}
}
//template<>
@@ -142,7 +142,7 @@ namespace MbD {
//template<>
//inline void Array<double>::conditionSelfWithTol(double tol)
//{
// for (size_t i = 0; i < this->size(); i++)
// for (int i = 0; i < this->size(); i++)
// {
// double element = this->at(i);
// if (element < 0.0) element = -element;
@@ -158,7 +158,7 @@ namespace MbD {
//inline double Array<double>::length()
//{
// double ssq = 0.0;
// for (size_t i = 0; i < this->size(); i++)
// for (int i = 0; i < this->size(); i++)
// {
// double elem = this->at(i);
// ssq += elem * elem;
@@ -168,7 +168,7 @@ namespace MbD {
template<typename T>
inline void Array<T>::magnifySelf(T factor)
{
for (size_t i = 0; i < this->size(); i++)
for (int i = 0; i < this->size(); i++)
{
this->atitimes(i, factor);
}

View File

@@ -8,6 +8,8 @@
#include "ConstVelConstraintIJ.h"
#include "DirectionCosineIecJec.h"
#include "ConstVelConstraintIqcJqc.h"
#include "EndFrameqc.h"
using namespace MbD;
@@ -15,6 +17,13 @@ ConstVelConstraintIJ::ConstVelConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : C
{
}
std::shared_ptr<ConstVelConstraintIJ> MbD::ConstVelConstraintIJ::With(EndFrmsptr frmi, EndFrmsptr frmj)
{
assert(frmi->isEndFrameqc());
assert(frmj->isEndFrameqc());
return std::make_shared<ConstVelConstraintIqcJqc>(frmi, frmj);
}
void ConstVelConstraintIJ::calcPostDynCorrectorIteration()
{
aG = aA01IeJe->aAijIeJe + aA10IeJe->aAijIeJe - aConstant;

View File

@@ -19,6 +19,8 @@ namespace MbD {
public:
ConstVelConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj);
static std::shared_ptr<ConstVelConstraintIJ> With(EndFrmsptr frmi, EndFrmsptr frmj);
void calcPostDynCorrectorIteration() override;
virtual void initA01IeJe();
virtual void initA10IeJe();

View File

@@ -18,6 +18,8 @@ using namespace MbD;
MbD::ConstVelConstraintIqcJc::ConstVelConstraintIqcJc(EndFrmsptr frmi, EndFrmsptr frmj) : ConstVelConstraintIJ(frmi, frmj)
{
pGpEI = std::make_shared<FullRow<double>>(4);
ppGpEIpEI = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::ConstVelConstraintIqcJc::calcPostDynCorrectorIteration()

View File

@@ -15,6 +15,9 @@ using namespace MbD;
MbD::ConstVelConstraintIqcJqc::ConstVelConstraintIqcJqc(EndFrmsptr frmi, EndFrmsptr frmj) : ConstVelConstraintIqcJc(frmi, frmj)
{
pGpEJ = std::make_shared<FullRow<double>>(4);
ppGpEIpEJ = std::make_shared<FullMatrixDouble>(4, 4);
ppGpEJpEJ = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::ConstVelConstraintIqcJqc::calcPostDynCorrectorIteration()

View File

@@ -22,12 +22,25 @@ MbD::ConstantVelocityJoint::ConstantVelocityJoint(const char* str) : AtPointJoin
{
}
void MbD::ConstantVelocityJoint::initializeLocally()
{
if (!constraints->empty())
{
auto constraint = std::static_pointer_cast<ConstVelConstraintIJ>(constraints->back());
constraint->initA01IeJe();
constraint->initA10IeJe();
}
Joint::initializeLocally();
}
void MbD::ConstantVelocityJoint::initializeGlobally()
{
if (constraints->empty())
{
createAtPointConstraints();
addConstraint(CREATE<ConstVelConstraintIJ>::With(frmI, frmJ));
auto constVelIJ = ConstVelConstraintIJ::With(frmI, frmJ);
constVelIJ->setConstant(0.0);
addConstraint(constVelIJ);
this->root()->hasChanged = true;
}
else {

View File

@@ -17,6 +17,7 @@ namespace MbD {
public:
ConstantVelocityJoint();
ConstantVelocityJoint(const char* str);
void initializeLocally() override;
void initializeGlobally() override;
void connectsItoJ(EndFrmsptr frmI, EndFrmsptr frmJ) override;

View File

@@ -5,7 +5,7 @@
* *
* See LICENSE file for details about copyright. *
***************************************************************************/
#include <functional>
#include <chrono>
@@ -15,8 +15,9 @@
using namespace MbD;
Constraint::Constraint()
Constraint::Constraint() : Item()
{
aConstant = 0.0;
}
Constraint::Constraint(const char* str) : Item(str)
@@ -115,6 +116,7 @@ void Constraint::removeRedundantConstraints(std::shared_ptr<std::vector<int>> re
void MbD::Constraint::setConstant(double value)
{
aConstant = value;
}
void Constraint::reactivateRedundantConstraints()

View File

@@ -21,6 +21,7 @@ namespace MbD {
Constraint();
Constraint(const char* str);
void initialize() override;
virtual void addToJointForceI(FColDsptr col);
virtual void addToJointTorqueI(FColDsptr col);
void fillAccICIterJacob(SpMatDsptr mat) override;
@@ -33,7 +34,6 @@ namespace MbD {
void fillqsuddotlam(FColDsptr col) override;
void fillqsulam(FColDsptr col) override;
virtual void fillRedundantConstraints(std::shared_ptr<Constraint> sptr, std::shared_ptr<std::vector<std::shared_ptr<Constraint>>> redunConstraints);
void initialize() override;
virtual bool isRedundant();
void postInput() override;
void preAccIC() override;
@@ -42,7 +42,7 @@ namespace MbD {
void prePosKine() override;
void reactivateRedundantConstraints() override;
void removeRedundantConstraints(std::shared_ptr<std::vector<int>> redundantEqnNos) override;
virtual void setConstant(double value);
void setConstant(double value);
void setqsudotlam(FColDsptr col) override;
void setqsuddotlam(FColDsptr col) override;
void setqsulam(FColDsptr col) override;
@@ -50,6 +50,7 @@ namespace MbD {
int iG = -1;
double aG = 0.0; //Constraint function
double aConstant = 0.0;
double lam = 0.0; //Lambda is Lagrange Multiplier
double mu = 0.0, lamDeriv = 0.0;
};

View File

@@ -11,7 +11,7 @@
using namespace MbD;
ConstraintIJ::ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : frmI(frmi), frmJ(frmj)
ConstraintIJ::ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj) : frmI(frmi), frmJ(frmj), Constraint()
{
}
@@ -20,8 +20,3 @@ void ConstraintIJ::initialize()
Constraint::initialize();
aConstant = 0.0;
}
void MbD::ConstraintIJ::setConstant(double value)
{
aConstant = value;
}

View File

@@ -22,10 +22,8 @@ namespace MbD {
ConstraintIJ(EndFrmsptr frmi, EndFrmsptr frmj);
void initialize() override;
void setConstant(double value) override;
EndFrmsptr frmI, frmJ;
double aConstant;
};
}

View File

@@ -23,7 +23,7 @@ namespace MbD {
}
void DiagonalMatrix::atiputDiagonalMatrix(int i, std::shared_ptr<DiagonalMatrix> diagMat)
{
for (size_t ii = 0; ii < diagMat->size(); ii++)
for (int ii = 0; ii < diagMat->size(); ii++)
{
this->at(i + ii) = diagMat->at(ii);
}
@@ -53,7 +53,7 @@ namespace MbD {
double DiagonalMatrix::sumOfSquares()
{
double sum = 0.0;
for (size_t i = 0; i < this->size(); i++)
for (int i = 0; i < this->size(); i++)
{
double element = this->at(i);
sum += element * element;
@@ -67,14 +67,14 @@ namespace MbD {
}
void DiagonalMatrix::zeroSelf()
{
for (size_t i = 0; i < this->size(); i++) {
for (int i = 0; i < this->size(); i++) {
this->at(i) = 0.0;
}
}
double DiagonalMatrix::maxMagnitude()
{
double max = 0.0;
for (size_t i = 0; i < this->size(); i++)
for (int i = 0; i < this->size(); i++)
{
double element = this->at(i);
if (element < 0.0) element = -element;
@@ -86,7 +86,7 @@ namespace MbD {
{
s << "DiagMat[";
s << this->at(0);
for (size_t i = 1; i < this->size(); i++)
for (int i = 1; i < this->size(); i++)
{
s << ", " << this->at(i);
}

View File

@@ -18,7 +18,7 @@ using namespace MbD;
FRowDsptr DifferenceOperator::OneOverFactorials = []() {
auto oneOverFactorials = std::make_shared<FullRow<double>>(10);
for (size_t i = 0; i < oneOverFactorials->size(); i++)
for (int i = 0; i < oneOverFactorials->size(); i++)
{
oneOverFactorials->at(i) = 1.0 / std::tgamma(i + 1);
}
@@ -81,7 +81,7 @@ void DifferenceOperator::formTaylorRowwithTimeNodederivative(int i, int ii, int
for (int j = k + 1; j < order + 1; j++)
{
hipower = hipower * hi;
auto aij = hipower * OneOverFactorials->at((size_t)j - k);
auto aij = hipower * OneOverFactorials->at((int)j - k);
rowi->atiput(j, aij);
}
}

View File

@@ -17,6 +17,10 @@ MbD::DispCompIeqcJecIe::DispCompIeqcJecIe()
MbD::DispCompIeqcJecIe::DispCompIeqcJecIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIecJecIe(frmi, frmj, axis)
{
priIeJeIepXI = std::make_shared<FullRow<double>>(3);
priIeJeIepEI = std::make_shared<FullRow<double>>(4);
ppriIeJeIepXIpEI = std::make_shared<FullMatrixDouble>(3, 4);
ppriIeJeIepEIpEI = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::DispCompIeqcJecIe::calc_ppvaluepEIpEI()

View File

@@ -17,6 +17,11 @@ MbD::DispCompIeqcJeqcIe::DispCompIeqcJeqcIe()
MbD::DispCompIeqcJeqcIe::DispCompIeqcJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJecIe(frmi, frmj, axis)
{
priIeJeIepXJ = std::make_shared<FullRow<double>>(3);
priIeJeIepEJ = std::make_shared<FullRow<double>>(4);
ppriIeJeIepEIpXJ = std::make_shared<FullMatrixDouble>(4, 3);
ppriIeJeIepEIpEJ = std::make_shared<FullMatrixDouble>(4, 4);
ppriIeJeIepEJpEJ = std::make_shared<FullMatrixDouble>(4, 4);
}
void MbD::DispCompIeqcJeqcIe::calc_ppvaluepEIpEJ()

View File

@@ -17,6 +17,10 @@ MbD::DispCompIeqctJeqcIe::DispCompIeqctJeqcIe()
MbD::DispCompIeqctJeqcIe::DispCompIeqctJeqcIe(EndFrmsptr frmi, EndFrmsptr frmj, int axis) : DispCompIeqcJeqcIe(frmi, frmj, axis)
{
ppriIeJeIepXIpt = std::make_shared<FullRow<double>>(3);
ppriIeJeIepEIpt = std::make_shared<FullRow<double>>(4);
ppriIeJeIepXJpt = std::make_shared<FullRow<double>>(3);
ppriIeJeIepEJpt = std::make_shared<FullRow<double>>(4);
}
void MbD::DispCompIeqctJeqcIe::calc_ppvaluepEIpt()

View File

@@ -102,3 +102,8 @@ std::shared_ptr<EndFrameqc> MbD::EndFramec::newCopyEndFrameqc()
markerFrame->addEndFrame(frmIeqc);
return frmIeqc;
}
bool MbD::EndFramec::isEndFrameqc()
{
return false;
}

View File

@@ -41,6 +41,7 @@ namespace MbD {
virtual FColFMatDsptr pAOppE();
virtual FMatDsptr aBOp();
std::shared_ptr<EndFrameqc> newCopyEndFrameqc();
virtual bool isEndFrameqc();
MarkerFrame* markerFrame; //Use raw pointer when pointing backwards.
FColDsptr rOeO = std::make_shared<FullColumn<double>>(3);

View File

@@ -155,3 +155,8 @@ FMatDsptr EndFrameqc::aBOp()
{
return markerFrame->aBOp();
}
bool MbD::EndFrameqc::isEndFrameqc()
{
return true;
}

View File

@@ -40,6 +40,7 @@ namespace MbD {
FColDsptr rpep() override;
FColFMatDsptr pAOppE() override;
FMatDsptr aBOp() override;
bool isEndFrameqc() override;
FMatDsptr prOeOpE;
FMatFColDsptr pprOeOpEpE;

View File

@@ -320,4 +320,8 @@ namespace MbD {
pprOeOptpt = aAOm->timesFullColumn(pprmemptpt);
ppAOeptpt = aAOm->timesFullMatrix(ppAmeptpt);
}
bool EndFrameqct::isEndFrameqc()
{
return false;
}
}

View File

@@ -49,8 +49,8 @@ namespace MbD {
virtual void evalppAmeptpt();
FColDsptr rmeO() override;
FColDsptr rpep() override;
void preAccIC() override;
bool isEndFrameqc() override;
std::shared_ptr<FullColumn<Symsptr>> rmemBlks, prmemptBlks, pprmemptptBlks;
std::shared_ptr<FullColumn<Symsptr>> phiThePsiBlks, pPhiThePsiptBlks, ppPhiThePsiptptBlks;

View File

@@ -12,7 +12,10 @@ namespace MbD {
template<typename T>
inline void EulerAngles<T>::initialize()
{
assert(false);
rotOrder = std::make_shared<FullColumn<int>>(3);
rotOrder->at(0) = 0;
rotOrder->at(1) = 1;
rotOrder->at(2) = 2;
}
template<>
inline void EulerAngles<Symsptr>::calc()

View File

@@ -28,7 +28,7 @@ namespace MbD {
std::shared_ptr<EulerAnglesDDot<T>> differentiateWRT(T var);
void calc() override;
EulerAngles<T>* aEulerAngles; //Use raw pointer to point backwards
EulerAngles<T>* aEulerAngles = nullptr; //Use raw pointer to point backwards
FColFMatDsptr cAdot;
FMatDsptr aAdot;
FColDsptr omeF, omef;
@@ -47,8 +47,8 @@ namespace MbD {
inline void EulerAnglesDot<T>::calc()
{
aEulerAngles->calc();
auto rotOrder = aEulerAngles->rotOrder;
auto cA = aEulerAngles->cA;
auto& rotOrder = aEulerAngles->rotOrder;
auto& cA = aEulerAngles->cA;
cAdot = std::make_shared<FullColumn<FMatDsptr>>(3);
for (int i = 0; i < 3; i++)
{
@@ -71,12 +71,12 @@ namespace MbD {
auto phidot = this->at(0)->getValue();
auto thedot = this->at(1)->getValue();
auto psidot = this->at(2)->getValue();
auto phiA = cA->at(0);
auto theA = cA->at(1);
auto psiA = cA->at(2);
auto phiAdot = cAdot->at(0);
auto theAdot = cAdot->at(1);
auto psiAdot = cAdot->at(2);
auto& phiA = cA->at(0);
auto& theA = cA->at(1);
auto& psiA = cA->at(2);
auto& phiAdot = cAdot->at(0);
auto& theAdot = cAdot->at(1);
auto& psiAdot = cAdot->at(2);
aAdot = phiAdot->timesFullMatrix(theA->timesFullMatrix(psiA))
->plusFullMatrix(phiA->timesFullMatrix(theAdot->timesFullMatrix(psiA)))

View File

@@ -43,20 +43,25 @@ void MbD::ExternalSystem::outputFor(AnalysisType type)
void MbD::ExternalSystem::logString(std::string& str)
{
std::cout << str << std::endl;
}
void MbD::ExternalSystem::logString(double value)
{
assert(false);
}
void MbD::ExternalSystem::runOndselPiston()
{
assert(false);
}
void MbD::ExternalSystem::runPiston()
{
assert(false);
}
void MbD::ExternalSystem::postMbDrun()
{
//Do nothing
}

View File

@@ -16,7 +16,7 @@ namespace MbD {
template<typename T>
FColsptr<T> FullColumn<T>::plusFullColumn(FColsptr<T> fullCol)
{
int n = (int) this->size();
int n = (int)this->size();
auto answer = std::make_shared<FullColumn<T>>(n);
for (int i = 0; i < n; i++) {
answer->at(i) = this->at(i) + fullCol->at(i);
@@ -24,9 +24,15 @@ namespace MbD {
return answer;
}
template<typename T>
FColsptr<T> FullColumn<T>::plusFullColumntimes(FColsptr<T> fullCol, double factor)
{
assert(false);
return FColsptr<T>();
}
template<typename T>
FColsptr<T> FullColumn<T>::minusFullColumn(FColsptr<T> fullCol)
{
int n = (int) this->size();
int n = (int)this->size();
auto answer = std::make_shared<FullColumn<T>>(n);
for (int i = 0; i < n; i++) {
answer->at(i) = this->at(i) - fullCol->at(i);
@@ -53,12 +59,12 @@ namespace MbD {
template<typename T>
FColsptr<T> FullColumn<T>::negated()
{
return this->times(-1.0);
return this->times((T) - 1.0);
}
template<typename T>
void FullColumn<T>::atiputFullColumn(int i, FColsptr<T> fullCol)
{
for (size_t ii = 0; ii < fullCol->size(); ii++)
for (int ii = 0; ii < fullCol->size(); ii++)
{
this->at(i + ii) = fullCol->at(ii);
}
@@ -66,7 +72,7 @@ namespace MbD {
template<typename T>
void FullColumn<T>::atiplusFullColumn(int i, FColsptr<T> fullCol)
{
for (size_t ii = 0; ii < fullCol->size(); ii++)
for (int ii = 0; ii < fullCol->size(); ii++)
{
this->at(i + ii) += fullCol->at(ii);
}
@@ -75,7 +81,7 @@ namespace MbD {
void FullColumn<T>::equalSelfPlusFullColumnAt(FColsptr<T> fullCol, int ii)
{
//self is subcolumn of fullCol
for (size_t i = 0; i < this->size(); i++)
for (int i = 0; i < this->size(); i++)
{
this->at(i) += fullCol->at(ii + i);
}
@@ -83,7 +89,7 @@ namespace MbD {
template<typename T>
void FullColumn<T>::atiminusFullColumn(int i1, FColsptr<T> fullCol)
{
for (size_t ii = 0; ii < fullCol->size(); ii++)
for (int ii = 0; ii < fullCol->size(); ii++)
{
int i = i1 + ii;
this->at(i) -= fullCol->at(ii);
@@ -93,7 +99,7 @@ namespace MbD {
void FullColumn<T>::equalFullColumnAt(FColsptr<T> fullCol, int i)
{
this->equalArrayAt(fullCol, i);
//for (size_t ii = 0; ii < this->size(); ii++)
//for (int ii = 0; ii < this->size(); ii++)
//{
// this->at(ii) = fullCol->at(i + ii);
//}
@@ -101,7 +107,7 @@ namespace MbD {
template<>
FColDsptr FullColumn<double>::copy()
{
auto n = (int) this->size();
auto n = (int)this->size();
auto answer = std::make_shared<FullColumn<double>>(n);
for (int i = 0; i < n; i++)
{
@@ -117,7 +123,7 @@ namespace MbD {
template<typename T>
void FullColumn<T>::atiplusFullColumntimes(int i1, FColsptr<T> fullCol, T factor)
{
for (size_t ii = 0; ii < fullCol->size(); ii++)
for (int ii = 0; ii < fullCol->size(); ii++)
{
int i = i1 + ii;
this->at(i) += fullCol->at(ii) * factor;
@@ -151,7 +157,7 @@ namespace MbD {
//template<>
//inline std::shared_ptr<FullColumn<Symsptr>> FullColumn<Symsptr>::simplified()
//{
// auto n = this->size();
// auto n = (int)this->size();
// auto answer = std::make_shared<FullColumn<Symsptr>>(n);
// for (int i = 0; i < n; i++)
// {
@@ -170,13 +176,23 @@ namespace MbD {
template class FullColumn<double>;
template class FullColumn<int>;
template<typename T>
double FullColumn<T>::dot(std::shared_ptr<FullVector<T>> vec)
{
int n = (int)this->size();
double answer = 0.0;
for (int i = 0; i < n; i++) {
answer += this->at(i) * vec->at(i);
}
return answer;
}
template<typename T>
std::shared_ptr<FullVector<T>> FullColumn<T>::dot(std::shared_ptr<std::vector<std::shared_ptr<FullColumn<T>>>> vecvec)
{
int ncol = (int)this->size();
auto nelem = vecvec->at(0)->size();
auto answer = std::make_shared<FullVector<T>>(nelem);
for (int k = 0; k < nelem; k++) {
auto sum = 0.0;
auto sum = (T)0;
for (int i = 0; i < ncol; i++)
{
sum += this->at(i) * vecvec->at(i)->at(k);

View File

@@ -47,6 +47,7 @@ namespace MbD {
void equalSelfPlusFullColumntimes(FColsptr<T> fullCol, T factor);
FColsptr<T> cross(FColsptr<T> fullCol);
FColsptr<T> simplified();
double dot(std::shared_ptr<FullVector<T>> vec);
std::shared_ptr<FullColumn<T>> cloneFcSptr();
double dotVec(std::shared_ptr<FullVector<T>> vec);
std::shared_ptr<FullVector<T>> dot(std::shared_ptr<std::vector<std::shared_ptr<FullColumn<T>>>> vecvec);
@@ -59,7 +60,7 @@ namespace MbD {
{
s << "FullCol{";
s << this->at(0);
for (size_t i = 1; i < this->size(); i++)
for (int i = 1; i < this->size(); i++)
{
s << ", " << this->at(i);
}

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