Commit 51bb5093 authored by Henry Weller's avatar Henry Weller
Browse files

rigidBodyDynamics/bodies/sphere: Added support for the centre of mass being...

rigidBodyDynamics/bodies/sphere: Added support for the centre of mass being offset from the centre of rotation
parent cca76719
......@@ -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
......
......@@ -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_)));
}
......
Supports Markdown
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