mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
applications/test/rigidBodyDynamics/pendulum: Add a test for merging bodies
This commit is contained in:
@ -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;
|
|||||||
|
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user