MBDyn classes for reading

This commit is contained in:
Aik-Siong Koh
2023-10-05 07:48:48 -06:00
parent 92b401641f
commit 3387f4c7ae
15 changed files with 223 additions and 338 deletions

View File

@@ -1,4 +1,9 @@
#include "MBDynBody.h"
#include "MBDynReferences.h"
#include "MBDynReference.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "MBDynVariables.h"
using namespace MbD;
@@ -6,7 +11,38 @@ void MbD::MBDynBody::initialize()
{
}
void MbD::MBDynBody::parseMBDyn(std::vector<std::string>& lines)
void MbD::MBDynBody::parseMBDyn(std::string line)
{
bodyString = line;
size_t previousPos = 0;
auto pos = line.find(":");
auto front = line.substr(previousPos, pos - previousPos);
assert(front.find("body") != std::string::npos);
auto arguments = std::make_shared<std::vector<std::string>>();
std::string argument;
while (true) {
previousPos = pos;
pos = line.find(",", pos + 1);
if (pos != std::string::npos) {
argument = line.substr(previousPos + 1, pos - previousPos - 1);
arguments->push_back(argument);
}
else {
argument = line.substr(previousPos + 1);
arguments->push_back(argument);
break;
}
}
auto iss = std::istringstream(arguments->at(0));
iss >> name;
arguments->erase(arguments->begin());
iss = std::istringstream(arguments->at(0));
iss >> node;
arguments->erase(arguments->begin());
rOfO = readPosition(arguments);
readInertiaMatrix(arguments);
}
void MbD::MBDynBody::readInertiaMatrix(std::shared_ptr<std::vector<std::string>>& args)
{
assert(false);
}

View File

@@ -14,7 +14,13 @@ namespace MbD {
{
public:
void initialize() override;
void parseMBDyn(std::vector<std::string>& lines) override;
void parseMBDyn(std::string line);
void readInertiaMatrix(std::shared_ptr<std::vector<std::string>>& args);
std::string bodyString, name, node;
double mass;
FColDsptr rOfO;
FMatDsptr aAOf;
};
}

View File

@@ -1,4 +1,5 @@
#include "MBDynElements.h"
#include "MBDynBody.h"
using namespace MbD;
@@ -8,5 +9,29 @@ void MbD::MBDynElements::initialize()
void MbD::MBDynElements::parseMBDyn(std::vector<std::string>& lines)
{
assert(false);
elements = std::make_shared<std::vector<std::shared_ptr<MBDynElement>>>();
std::vector<std::string> bodyToken{ "body:" };
std::vector<std::string> jointToken{ "joint:" };
std::vector<std::string>::iterator it;
while (true) {
it = findLineWith(lines, bodyToken);
if (it != lines.end()) {
auto body = std::make_shared<MBDynBody>();
body->owner = this;
body->parseMBDyn(*it);
elements->push_back(body);
lines.erase(it);
continue;
}
it = findLineWith(lines, jointToken);
if (it != lines.end()) {
auto body = std::make_shared<MBDynBody>();
body->owner = this;
body->parseMBDyn(*it);
elements->push_back(body);
lines.erase(it);
continue;
}
break;
}
}

View File

@@ -10,11 +10,14 @@
#include "MBDynBlock.h"
namespace MbD {
class MBDynElement;
class MBDynElements : public MBDynBlock
{
public:
void initialize() override;
void parseMBDyn(std::vector<std::string>& lines) override;
std::shared_ptr<std::vector<std::shared_ptr<MBDynElement>>> elements;
};
}

View File

@@ -1,5 +1,13 @@
#include "MBDynItem.h"
#include "MBDynSystem.h"
#include "MBDynVariables.h"
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "EulerAngles.h"
#include "Constant.h"
#include "MBDynReferences.h"
#include "MBDynReference.h"
using namespace MbD;
@@ -41,3 +49,104 @@ std::shared_ptr<MBDynVariables> MbD::MBDynItem::mbdynVariables()
{
return owner->mbdynVariables();
}
std::shared_ptr<MBDynReferences> MbD::MBDynItem::mbdynReferences()
{
return owner->mbdynReferences();
}
FColDsptr MbD::MBDynItem::readPosition(std::shared_ptr<std::vector<std::string>>& args)
{
auto rOfO = std::make_shared<FullColumn<double>>(3);
auto str = args->at(0);
if (str.find("reference") != std::string::npos) {
args->erase(args->begin());
std::string refName;
std::istringstream iss(args->at(0));
iss >> refName;
auto ref = mbdynReferences()->references->at(refName);
args->erase(args->begin());
auto rFfF = readBasicPosition(args);
auto rOFO = ref->rOfO;
auto aAOF = ref->aAOf;
rOfO = rOFO->plusFullColumn(aAOF->timesFullColumn(rFfF));
}
else {
rOfO = readBasicPosition(args);
}
return rOfO;
}
FColDsptr MbD::MBDynItem::readBasicPosition(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto rFfF = std::make_shared<FullColumn<double>>(3);
std::string str;
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
rFfF->at(i) = sym->getValue();
}
return rFfF;
}
FMatDsptr MbD::MBDynItem::readOrientation(std::shared_ptr<std::vector<std::string>>& args)
{
auto aAOf = std::make_shared<FullMatrix<double>>(3, 3);
auto str = args->at(0);
if (str.find("reference") != std::string::npos) {
args->erase(args->begin());
std::string refName;
std::istringstream iss(args->at(0));
iss >> refName;
auto ref = mbdynReferences()->references->at(refName);
args->erase(args->begin());
auto aAFf = readBasicOrientation(args);
auto aAOF = ref->aAOf;
aAOf = aAOF->timesFullMatrix(aAFf);
}
else {
aAOf = readBasicOrientation(args);
}
return aAOf;
}
FMatDsptr MbD::MBDynItem::readBasicOrientation(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto euler = std::make_shared<EulerAngles<Symsptr>>();
auto str = args->at(0);
if (str.find("euler") != std::string::npos) {
args->erase(args->begin());
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
euler->at(i) = sym;
}
}
else if (str.find("eye") != std::string::npos) {
args->erase(args->begin());
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
euler->at(i) = std::make_shared<Constant>(0.0);
}
}
else {
assert(false);
}
euler->calc();
auto aAFf = euler->aA;
return aAFf;
}

View File

@@ -12,6 +12,7 @@
namespace MbD {
class MBDynSystem;
class MBDynVariables;
class MBDynReferences;
class MBDynItem
{
@@ -25,22 +26,11 @@ namespace MbD {
std::vector<std::string>::iterator findLineWith(std::vector<std::string>& lines, std::vector<std::string>& tokens);
bool lineHasTokens(const std::string& line, std::vector<std::string>& tokens);
virtual std::shared_ptr<MBDynVariables> mbdynVariables();
//FRowDsptr readRowOfDoubles(std::string& line);
//FColDsptr readColumnOfDoubles(std::string& line);
//double readDouble(std::string& line);
//int readInt(std::string& line);
//bool readBool(std::string& line);
//std::string readString(std::string& line);
//void readName(std::vector<std::string>& lines);
//virtual std::string fullName(std::string partialName);
//void readDoublesInto(std::string& str, std::string label, FRowDsptr& row);
//virtual void deleteMbD();
//virtual void createMbD(std::shared_ptr<System> mbdSys, std::shared_ptr<Units> mbdUnits);
//virtual void updateFromMbD();
//virtual void compareResults(AnalysisType type);
//virtual void outputResults(AnalysisType type);
//std::shared_ptr<Units> mbdUnits();
//std::shared_ptr<Constant> sptrConstant(double value);
virtual std::shared_ptr<MBDynReferences> mbdynReferences();
FColDsptr readPosition(std::shared_ptr<std::vector<std::string>>& args);
FColDsptr readBasicPosition(std::shared_ptr<std::vector<std::string>>& args);
FMatDsptr readOrientation(std::shared_ptr<std::vector<std::string>>& args);
FMatDsptr readBasicOrientation(std::shared_ptr<std::vector<std::string>>& args);
std::string name;
MBDynItem* owner;

View File

@@ -15,7 +15,7 @@ void MbD::MBDynNodes::parseMBDyn(std::vector<std::string>& lines)
while (true) {
auto it = findLineWith(lines, tokens);
if (it != lines.end()) {
auto structural = CREATE<MBDynStructural>::With();
auto structural = std::make_shared<MBDynStructural>();
structural->owner = this;
structural->parseMBDyn(*it);
nodes->push_back(structural);

View File

@@ -36,161 +36,12 @@ void MbD::MBDynReference::parseMBDyn(std::string line)
iss >> name;
arguments->erase(arguments->begin());
readPosition(arguments);
readOrientation(arguments);
rOfO = readPosition(arguments);
aAOf = readOrientation(arguments);
readVelocity(arguments);
readOmega(arguments);
}
//void MbD::MBDynReference::parseMBDyn(std::string line)
//{
// refString = line;
// std::replace(line.begin(), line.end(), ',', ' ');
// std::istringstream iss(line);
// std::string str;
// iss >> str;
// assert(str == "reference:");
// iss >> name;
// readPosition(iss);
// readOrientation(iss);
// readVelocity(iss);
// readOmega(iss);
//}
void MbD::MBDynReference::readPosition(std::istringstream& iss)
{
auto dddd = iss.str();
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
rOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
rOfO->at(i) = sym->getValue();
}
}
void MbD::MBDynReference::readOrientation(std::istringstream& iss)
{
std::string str;
iss >> str;
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto euler = std::make_shared<EulerAngles<Symsptr>>();
if (str.find("euler") != std::string::npos) {
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
euler->at(i) = sym;
double ddd = sym->getValue();
}
}
else {
assert(false);
}
euler->calc();
aAOf = euler->aA;
}
void MbD::MBDynReference::readVelocity(std::istringstream& iss)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
vOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
auto p = iss.tellg();
iss >> str;
if (str.find("null") != std::string::npos) {
return;
}
else {
iss.seekg(p);
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
vOfO->at(i) = sym->getValue();
}
}
}
void MbD::MBDynReference::readOmega(std::istringstream& iss)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
omeOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
auto p = iss.tellg();
iss >> str;
if (str.find("null") != std::string::npos) {
return;
}
else {
iss.seekg(p);
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
omeOfO->at(i) = sym->getValue();
}
}
}
void MbD::MBDynReference::readPosition(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
rOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
rOfO->at(i) = sym->getValue();
}
}
void MbD::MBDynReference::readOrientation(std::shared_ptr<std::vector<std::string>>& args)
{
auto str = args->at(0);
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto euler = std::make_shared<EulerAngles<Symsptr>>();
if (str.find("euler") != std::string::npos) {
args->erase(args->begin());
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
euler->at(i) = sym;
}
}
else {
assert(false);
}
euler->calc();
aAOf = euler->aA;
}
void MbD::MBDynReference::readVelocity(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();

View File

@@ -16,12 +16,6 @@ namespace MbD {
public:
void initialize() override;
void parseMBDyn(std::string line);
void readPosition(std::istringstream& iss);
void readOrientation(std::istringstream& iss);
void readVelocity(std::istringstream& iss);
void readOmega(std::istringstream& iss);
void readPosition(std::shared_ptr<std::vector<std::string>>& args);
void readOrientation(std::shared_ptr<std::vector<std::string>>& args);
void readVelocity(std::shared_ptr<std::vector<std::string>>& args);
void readOmega(std::shared_ptr<std::vector<std::string>>& args);

View File

@@ -16,7 +16,7 @@ void MbD::MBDynReferences::parseMBDyn(std::vector<std::string>& lines)
while (true) {
auto it = findLineWith(lines, tokens);
if (it != lines.end()) {
auto reference = CREATE<MBDynReference>::With();
auto reference = std::make_shared<MBDynReference>();
reference->owner = this;
reference->parseMBDyn(*it);
references->insert(std::make_pair(reference->name, reference));

View File

@@ -3,6 +3,9 @@
#include "SymbolicParser.h"
#include "BasicUserFunction.h"
#include "EulerAngles.h"
#include "Constant.h"
#include "MBDynReferences.h"
#include "MBDynReference.h"
using namespace MbD;
@@ -39,153 +42,12 @@ void MbD::MBDynStructural::parseMBDyn(std::string line)
iss >> type;
arguments->erase(arguments->begin());
readPosition(arguments);
readOrientation(arguments);
rOfO = readPosition(arguments);
aAOf = readOrientation(arguments);
readVelocity(arguments);
readOmega(arguments);
}
void MbD::MBDynStructural::readPosition(std::istringstream& iss)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
rOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
rOfO->at(i) = sym->getValue();
}
}
void MbD::MBDynStructural::readOrientation(std::istringstream& iss)
{
std::string str;
iss >> str;
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto euler = std::make_shared<EulerAngles<Symsptr>>();
if (str.find("eye") != std::string::npos) {
aAOf = std::make_shared<FullMatrix<double>>(3, 3);
aAOf->identity();
return;
}
else if (str.find("euler") != std::string::npos) {
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
euler->at(i) = sym;
}
}
else {
assert(false);
}
euler->calc();
aAOf = euler->aA;
}
void MbD::MBDynStructural::readVelocity(std::istringstream& iss)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
vOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
auto p = iss.tellg();
iss >> str;
if (str.find("null") != std::string::npos) {
return;
}
else {
iss.seekg(p);
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
vOfO->at(i) = sym->getValue();
}
}
}
void MbD::MBDynStructural::readOmega(std::istringstream& iss)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
omeOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
auto p = iss.tellg();
iss >> str;
if (str.find("null") != std::string::npos) {
return;
}
else {
iss.seekg(p);
for (int i = 0; i < 3; i++)
{
iss >> str;
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
omeOfO->at(i) = sym->getValue();
}
}
}
void MbD::MBDynStructural::readPosition(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
rOfO = std::make_shared<FullColumn<double>>(3);
std::string str;
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
rOfO->at(i) = sym->getValue();
}
}
void MbD::MBDynStructural::readOrientation(std::shared_ptr<std::vector<std::string>>& args)
{
auto str = args->at(0);
auto parser = CREATE<SymbolicParser>::With();
parser->variables = mbdynVariables()->variables;
auto euler = std::make_shared<EulerAngles<Symsptr>>();
if (str.find("euler") != std::string::npos) {
args->erase(args->begin());
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
for (int i = 0; i < 3; i++)
{
str = args->at(0);
args->erase(args->begin());
auto userFunc = CREATE<BasicUserFunction>::With(str, 1.0);
parser->parseUserFunction(userFunc);
auto sym = parser->stack->top();
euler->at(i) = sym;
}
}
else if (str.find("eye") != std::string::npos) {
args->erase(args->begin());
euler->rotOrder = std::make_shared<FullColumn<int>>(std::initializer_list<int>{ 1, 2, 3 });
}
else {
assert(false);
}
euler->calc();
aAOf = euler->aA;
}
void MbD::MBDynStructural::readVelocity(std::shared_ptr<std::vector<std::string>>& args)
{
auto parser = CREATE<SymbolicParser>::With();

View File

@@ -15,12 +15,6 @@ namespace MbD {
public:
void initialize() override;
void parseMBDyn(std::string line);
void readPosition(std::istringstream& iss);
void readOrientation(std::istringstream& iss);
void readVelocity(std::istringstream& iss);
void readOmega(std::istringstream& iss);
void readPosition(std::shared_ptr<std::vector<std::string>>& args);
void readOrientation(std::shared_ptr<std::vector<std::string>>& args);
void readVelocity(std::shared_ptr<std::vector<std::string>>& args);
void readOmega(std::shared_ptr<std::vector<std::string>>& args);

View File

@@ -14,6 +14,7 @@
#include "MBDynVariables.h"
#include "MBDynReferences.h"
#include "MBDynNodes.h"
#include "MBDynElements.h"
using namespace MbD;
@@ -28,7 +29,7 @@ void MbD::MBDynSystem::runFile(const char* filename)
eraseComments(lines);
auto statements = collectStatements(lines);
auto system = CREATE<MBDynSystem>::With();
auto system = std::make_shared<MBDynSystem>();
system->setFilename(filename);
system->parseMBDyn(statements);
system->runKINEMATIC();
@@ -52,6 +53,11 @@ std::shared_ptr<MBDynVariables> MbD::MBDynSystem::mbdynVariables()
return variables;
}
std::shared_ptr<MBDynReferences> MbD::MBDynSystem::mbdynReferences()
{
return references;
}
void MbD::MBDynSystem::runKINEMATIC()
{
assert(false);
@@ -69,7 +75,7 @@ void MbD::MBDynSystem::readDataBlock(std::vector<std::string>& lines)
std::vector<std::string> tokens1{"end:", "data;"};
auto endit = findLineWith(lines, tokens1);
std::vector<std::string> blocklines = { beginit, endit + 1 };
dataBlk = CREATE<MBDynData>::With();
dataBlk = std::make_shared<MBDynData>();
dataBlk->owner = this;
dataBlk->parseMBDyn(blocklines);
lines.erase(beginit, endit + 1);
@@ -82,7 +88,7 @@ void MbD::MBDynSystem::readInitialValueBlock(std::vector<std::string>& lines)
std::vector<std::string> tokens1{"end:", "initial", "value"};
auto endit = findLineWith(lines, tokens1);
std::vector<std::string> blocklines = { beginit, endit + 1 };
initialValueBlk = CREATE<MBDynInitialValue>::With();
initialValueBlk = std::make_shared<MBDynInitialValue>();
initialValueBlk->owner = this;
initialValueBlk->parseMBDyn(blocklines);
lines.erase(beginit, endit + 1);
@@ -95,7 +101,7 @@ void MbD::MBDynSystem::readControlDataBlock(std::vector<std::string>& lines)
std::vector<std::string> tokens1{"end:", "control", "data"};
auto endit = findLineWith(lines, tokens1);
std::vector<std::string> blocklines = { beginit, endit + 1 };
controlDataBlk = CREATE<MBDynControlData>::With();
controlDataBlk = std::make_shared<MBDynControlData>();
controlDataBlk->owner = this;
controlDataBlk->parseMBDyn(blocklines);
lines.erase(beginit, endit + 1);
@@ -103,21 +109,21 @@ void MbD::MBDynSystem::readControlDataBlock(std::vector<std::string>& lines)
void MbD::MBDynSystem::readLabels(std::vector<std::string>& lines)
{
labels = CREATE<MBDynLabels>::With();
labels = std::make_shared<MBDynLabels>();
labels->owner = this;
labels->parseMBDyn(lines);
}
void MbD::MBDynSystem::readVariables(std::vector<std::string>& lines)
{
variables = CREATE<MBDynVariables>::With();
variables = std::make_shared<MBDynVariables>();
variables->owner = this;
variables->parseMBDyn(lines);
}
void MbD::MBDynSystem::readReferences(std::vector<std::string>& lines)
{
references = CREATE<MBDynReferences>::With();
references = std::make_shared<MBDynReferences>();
references->owner = this;
references->parseMBDyn(lines);
}
@@ -129,7 +135,7 @@ void MbD::MBDynSystem::readNodesBlock(std::vector<std::string>& lines)
std::vector<std::string> tokens1{ "end:", "nodes;" };
auto endit = findLineWith(lines, tokens1);
std::vector<std::string> blocklines = { beginit, endit + 1 };
nodesBlk = CREATE<MBDynNodes>::With();
nodesBlk = std::make_shared<MBDynNodes>();
nodesBlk->owner = this;
nodesBlk->parseMBDyn(blocklines);
lines.erase(beginit, endit + 1);
@@ -137,7 +143,15 @@ void MbD::MBDynSystem::readNodesBlock(std::vector<std::string>& lines)
void MbD::MBDynSystem::readElementsBlock(std::vector<std::string>& lines)
{
assert(false);
std::vector<std::string> tokens{ "begin:", "elements;" };
auto beginit = findLineWith(lines, tokens);
std::vector<std::string> tokens1{ "end:", "elements;" };
auto endit = findLineWith(lines, tokens1);
std::vector<std::string> blocklines = { beginit, endit + 1 };
elementsBlk = std::make_shared<MBDynElements>();
elementsBlk->owner = this;
elementsBlk->parseMBDyn(blocklines);
lines.erase(beginit, endit + 1);
}
void MbD::MBDynSystem::eraseComments(std::vector<std::string>& lines)

View File

@@ -31,6 +31,7 @@ namespace MbD {
void initialize() override;
void parseMBDyn(std::vector<std::string>& lines) override;
std::shared_ptr<MBDynVariables> mbdynVariables() override;
std::shared_ptr<MBDynReferences> mbdynReferences() override;
void runKINEMATIC();
void setFilename(std::string filename);

View File

@@ -24,7 +24,7 @@ void runSpMat();
int main()
{
//MBDynSystem::runFile("crank_slider.mbd"); //To be completed
MBDynSystem::runFile("crank_slider.mbd"); //To be completed
//ASMTAssembly::runSinglePendulumSuperSimplified(); //Mass is missing
ASMTAssembly::runSinglePendulumSimplified();
ASMTAssembly::runSinglePendulum();