rigidBodyDynamics: Added dictionary-based IO of the rigidBodyModel

This commit is contained in:
Henry Weller
2016-04-07 21:47:08 +01:00
parent 9aaf17d45d
commit 8ffd700ca6
54 changed files with 700 additions and 144 deletions

View File

@ -0,0 +1,38 @@
bodies0
{
pendulum
{
type rigidBody;
parent root;
mass 1;
centreOfMass (0 -1 0);
inertia (0.001 0 0 0.001 0 0.001);
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
joint
{
type Rz;
}
}
}
bodies
{
hinge
{
type masslessBody;
parent root;
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
joint
{
type Rz;
}
}
weight
{
type sphere;
mergeWith hinge;
mass 1;
radius 0.05;
transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
}
}

View File

@ -34,6 +34,7 @@ Description
#include "masslessBody.H"
#include "sphere.H"
#include "joints.H"
#include "IFstream.H"
using namespace Foam;
using namespace RBD;
@ -42,7 +43,8 @@ using namespace RBD;
int main(int argc, char *argv[])
{
bool testMerge = false;
/*
bool testMerge = true;
// Create a model for the pendulum
rigidBodyModel pendulum;
@ -55,7 +57,7 @@ int main(int argc, char *argv[])
(
pendulum.bodyID("root"),
Xt(Zero),
joint::New(new joints::Rz(pendulum)),
joint::New(new joints::Rz()),
autoPtr<rigidBody>(new masslessBody("hinge"))
);
@ -72,10 +74,16 @@ int main(int argc, char *argv[])
(
pendulum.bodyID("root"),
Xt(Zero),
joint::New(new joints::Rz(pendulum)),
joint::New(new joints::Rz()),
rigidBody::New("pendulum", 1, vector(0, -1, 0), 1e-3*I)
);
}
*/
// Create the pendulum model from dictionary
rigidBodyModel pendulum(dictionary(IFstream("pendulum")()));
pendulum.write(Info);
// Create the joint-space state fields
scalarField q(pendulum.nDoF(), Zero);
@ -110,7 +118,7 @@ int main(int argc, char *argv[])
qdot += 0.5*deltaT*qddot;
Info<< "Time << " << t << "s, angle = " << q[0] << "rad" << endl;
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
}
Info<< "\nEnd\n" << endl;