MBDyn spherical hinge (#33)
* moved misc files to project resource * MBDyn Sperical Hinge * Werner compil warning (#32) * Replace int by size_t in for loops. * Various dtor missing and some other warning fixes. * fixed size_t vs int * fixed size_t vs int --------- Co-authored-by: Paddle <PaddleStroke@users.noreply.github.com> Co-authored-by: Aik-Siong Koh <askoh@askoh.com> * moved misc files to project resource * MBDyn Sperical Hinge * gravity fix --------- Co-authored-by: PaddleStroke <pierrelouis.boyer@gmail.com> Co-authored-by: Paddle <PaddleStroke@users.noreply.github.com>
This commit is contained in:
58
OndselSolver/MBDynGravity.cpp
Normal file
58
OndselSolver/MBDynGravity.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
#include <regex>
|
||||
|
||||
#include "MBDynGravity.h"
|
||||
#include "ASMTConstantGravity.h"
|
||||
#include "ASMTAssembly.h"
|
||||
|
||||
using namespace MbD;
|
||||
|
||||
void MbD::MBDynGravity::parseMBDyn(std::string line)
|
||||
{
|
||||
gravityString = line;
|
||||
size_t previousPos = 0;
|
||||
auto pos = line.find(":");
|
||||
auto front = line.substr(previousPos, pos - previousPos);
|
||||
assert(front.find("gravity") != std::string::npos);
|
||||
auto arguments = 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;
|
||||
}
|
||||
}
|
||||
assert(arguments.at(0).find("uniform") != std::string::npos);
|
||||
arguments.erase(arguments.begin());
|
||||
gvec = readPosition(arguments);
|
||||
assert(arguments.at(0).find("string") != std::string::npos);
|
||||
arguments.erase(arguments.begin());
|
||||
auto iss = std::istringstream(arguments.at(0));
|
||||
iss >> formula;
|
||||
formula = std::regex_replace(formula, std::regex("\""), "");
|
||||
double mag;
|
||||
iss = std::istringstream(formula);
|
||||
iss >> mag;
|
||||
|
||||
arguments.erase(arguments.begin());
|
||||
gvec->normalizeSelf();
|
||||
gvec->magnifySelf(mag);
|
||||
}
|
||||
|
||||
void MbD::MBDynGravity::readFunction(std::vector<std::string>& args)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
void MbD::MBDynGravity::createASMT()
|
||||
{
|
||||
auto asmtGravity = std::make_shared<ASMTConstantGravity>();
|
||||
asmtGravity->setg(gvec);
|
||||
asmtAssembly()->setConstantGravity(asmtGravity);
|
||||
}
|
||||
Reference in New Issue
Block a user