Skip to content
Snippets Groups Projects
Commit e50d8ece authored by Henry Weller's avatar Henry Weller
Browse files

applications/test/rigidBodyDynamics/pendulum: Add a test for merging bodies

parent a9b8bb13
Branches
Tags
No related merge requests found
...@@ -31,6 +31,7 @@ Description ...@@ -31,6 +31,7 @@ Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "rigidBodyModel.H" #include "rigidBodyModel.H"
#include "masslessBody.H"
#include "joints.H" #include "joints.H"
using namespace Foam; using namespace Foam;
...@@ -40,18 +41,40 @@ using namespace RBD; ...@@ -40,18 +41,40 @@ using namespace RBD;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool testMerge = false;
// Create a model for the pendulum // Create a model for the pendulum
rigidBodyModel pendulum; rigidBodyModel pendulum;
// Join a weight to the origin with a centre of mass -1m below the origin // Join a weight to the origin with a centre of mass -1m below the origin
// by a hinge which rotates about the z-axis // by a hinge which rotates about the z-axis
pendulum.join if (testMerge)
( {
0, label hingeID = pendulum.join
Xt(vector(0, 0, 0)), (
joint::New(new joints::Rz(pendulum)), 0,
rigidBody::New("hinge", 1, vector(0, -1, 0), 0.02*I) Xt(Zero),
); joint::New(new joints::Rz(pendulum)),
autoPtr<rigidBody>(new masslessBody("hinge"))
);
pendulum.merge
(
hingeID,
Xt(vector(0, -1, 0)),
rigidBody::New("weight", 1, Zero, 0.02*I)
);
}
else
{
pendulum.join
(
0,
Xt(Zero),
joint::New(new joints::Rz(pendulum)),
rigidBody::New("pendulum", 1, vector(0, -1, 0), 0.02*I)
);
}
// Create the joint-space state fields // Create the joint-space state fields
scalarField q(pendulum.nDoF(), Zero); scalarField q(pendulum.nDoF(), Zero);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment