rigidBodyDynamics/bodies/sphere: Added support for the centre of mass being offset from the centre of rotation

This commit is contained in:
Henry Weller 2016-04-18 15:39:07 +01:00
parent cca76719d5
commit 51bb50935c
2 changed files with 31 additions and 12 deletions

View file

@ -59,6 +59,12 @@ class sphere
scalar r_;
// Private member functions
// Calculate and return the inertia tensor
inline symmTensor I(const scalar m, const scalar r) const;
public:
//- Runtime type information
@ -67,8 +73,14 @@ public:
// Constructors
//- Construct from name, mass and radius
inline sphere(const word& name, const scalar m, const scalar r);
//- Construct from name, mass, centre of mass and radius
inline sphere
(
const word& name,
const scalar m,
const vector& c,
const scalar r
);
//- Construct from dictionary
inline sphere

View file

@ -23,16 +23,29 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline Foam::symmTensor Foam::RBD::sphere::I
(
const scalar m,
const scalar r
) const
{
return ((2.0/5.0)*m*sqr(r))*Foam::I;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::RBD::sphere::sphere
(
const word& name,
const scalar m,
const vector& c,
const scalar r
)
:
rigidBody(name, m, Zero, (2.0/5.0)*m*sqr(r)*I),
rigidBody(name, m, c, I(m, r)),
r_(r)
{}
@ -43,18 +56,12 @@ inline Foam::RBD::sphere::sphere
const dictionary& dict
)
:
rigidBody
(
name,
rigidBodyInertia()
),
rigidBody(name, rigidBodyInertia()),
r_(readScalar(dict.lookup("radius")))
{
const scalar m(readScalar(dict.lookup("mass")));
rigidBodyInertia::operator=
(
rigidBodyInertia(m, Zero, (2.0/5.0)*m*sqr(r_)*I)
);
const vector c(dict.lookup("centreOfMass"));
rigidBodyInertia::operator=(rigidBodyInertia(m, c, I(m, r_)));
}