rigidBodyDynamics/bodies/sphere: Added support for the centre of mass being offset from the centre of rotation
This commit is contained in:
parent
cca76719d5
commit
51bb50935c
2 changed files with 31 additions and 12 deletions
|
|
@ -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_)));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue