rigidBodyDynamics: Generalized the interface to the restraints
Now internal forces and restraints may be applied between bodies within the articulated structure.
This commit is contained in:
parent
9b68e6d80c
commit
90f5cc6b9d
@ -50,8 +50,7 @@ namespace restraints
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::RBD::restraints::linearAxialAngularSpring::
|
Foam::RBD::restraints::linearAxialAngularSpring::linearAxialAngularSpring
|
||||||
linearAxialAngularSpring
|
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
@ -66,15 +65,17 @@ linearAxialAngularSpring
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::RBD::restraints::linearAxialAngularSpring::
|
Foam::RBD::restraints::linearAxialAngularSpring::~linearAxialAngularSpring()
|
||||||
~linearAxialAngularSpring()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::spatialVector
|
void Foam::RBD::restraints::linearAxialAngularSpring::restrain
|
||||||
Foam::RBD::restraints::linearAxialAngularSpring::restrain() const
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
vector refDir = rotationTensor(vector(1, 0, 0), axis_) & vector(0, 1, 0);
|
vector refDir = rotationTensor(vector(1, 0, 0), axis_) & vector(0, 1, 0);
|
||||||
|
|
||||||
@ -131,7 +132,8 @@ Foam::RBD::restraints::linearAxialAngularSpring::restrain() const
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spatialVector(moment, Zero);
|
// Accumulate the force for the restrained body
|
||||||
|
fx[bodyIndex_] += spatialVector(moment, Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,8 +101,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the external force applied to the body by this restraint
|
//- Accumulate the retraint internal joint forces into the tau field and
|
||||||
virtual spatialVector restrain() const;
|
// external forces into the fx field
|
||||||
|
virtual void restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
@ -71,7 +71,11 @@ Foam::RBD::restraints::linearDamper::~linearDamper()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::spatialVector Foam::RBD::restraints::linearDamper::restrain() const
|
void Foam::RBD::restraints::linearDamper::restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
vector force = -coeff_*model_.v(model_.master(bodyID_)).l();
|
vector force = -coeff_*model_.v(model_.master(bodyID_)).l();
|
||||||
|
|
||||||
@ -80,7 +84,8 @@ Foam::spatialVector Foam::RBD::restraints::linearDamper::restrain() const
|
|||||||
Info<< " force " << force << endl;
|
Info<< " force " << force << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spatialVector(Zero, force);
|
// Accumulate the force for the restrained body
|
||||||
|
fx[bodyIndex_] += spatialVector(Zero, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -92,8 +92,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the external force applied to the body by this restraint
|
//- Accumulate the retraint internal joint forces into the tau field and
|
||||||
virtual spatialVector restrain() const;
|
// external forces into the fx field
|
||||||
|
virtual void restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
@ -71,7 +71,11 @@ Foam::RBD::restraints::linearSpring::~linearSpring()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::spatialVector Foam::RBD::restraints::linearSpring::restrain() const
|
void Foam::RBD::restraints::linearSpring::restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
point attachmentPt = bodyPoint(refAttachmentPt_);
|
point attachmentPt = bodyPoint(refAttachmentPt_);
|
||||||
|
|
||||||
@ -101,7 +105,8 @@ Foam::spatialVector Foam::RBD::restraints::linearSpring::restrain() const
|
|||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spatialVector(moment, force);
|
// Accumulate the force for the restrained body
|
||||||
|
fx[bodyIndex_] += spatialVector(moment, force);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,8 +105,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the external force applied to the body by this restraint
|
//- Accumulate the retraint internal joint forces into the tau field and
|
||||||
virtual spatialVector restrain() const;
|
// external forces into the fx field
|
||||||
|
virtual void restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
@ -49,6 +49,7 @@ Foam::RBD::restraint::restraint
|
|||||||
:
|
:
|
||||||
name_(name),
|
name_(name),
|
||||||
bodyID_(model.bodyID(dict.lookup("body"))),
|
bodyID_(model.bodyID(dict.lookup("body"))),
|
||||||
|
bodyIndex_(model.master(bodyID_)),
|
||||||
coeffs_(dict),
|
coeffs_(dict),
|
||||||
model_(model)
|
model_(model)
|
||||||
{}
|
{}
|
||||||
|
@ -46,6 +46,7 @@ SourceFiles
|
|||||||
#include "autoPtr.H"
|
#include "autoPtr.H"
|
||||||
#include "spatialVector.H"
|
#include "spatialVector.H"
|
||||||
#include "point.H"
|
#include "point.H"
|
||||||
|
#include "scalarField.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -75,6 +76,9 @@ protected:
|
|||||||
//- ID of the body the restraint is applied to
|
//- ID of the body the restraint is applied to
|
||||||
label bodyID_;
|
label bodyID_;
|
||||||
|
|
||||||
|
//- Index of the body the force is applied to
|
||||||
|
label bodyIndex_;
|
||||||
|
|
||||||
//- Restraint model specific coefficient dictionary
|
//- Restraint model specific coefficient dictionary
|
||||||
dictionary coeffs_;
|
dictionary coeffs_;
|
||||||
|
|
||||||
@ -153,8 +157,13 @@ public:
|
|||||||
return bodyID_;
|
return bodyID_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Return the external force applied to the body by this restraint
|
//- Accumulate the retraint internal joint forces into the tau field and
|
||||||
virtual spatialVector restrain() const = 0;
|
// external forces into the fx field
|
||||||
|
virtual void restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const = 0;
|
||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
@ -50,8 +50,7 @@ namespace restraints
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::RBD::restraints::sphericalAngularDamper::
|
Foam::RBD::restraints::sphericalAngularDamper::sphericalAngularDamper
|
||||||
sphericalAngularDamper
|
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const dictionary& dict,
|
const dictionary& dict,
|
||||||
@ -66,15 +65,17 @@ sphericalAngularDamper
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::RBD::restraints::sphericalAngularDamper::
|
Foam::RBD::restraints::sphericalAngularDamper::~sphericalAngularDamper()
|
||||||
~sphericalAngularDamper()
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::spatialVector
|
void Foam::RBD::restraints::sphericalAngularDamper::restrain
|
||||||
Foam::RBD::restraints::sphericalAngularDamper::restrain() const
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
vector moment = -coeff_*model_.v(model_.master(bodyID_)).w();
|
vector moment = -coeff_*model_.v(model_.master(bodyID_)).w();
|
||||||
|
|
||||||
@ -83,7 +84,8 @@ Foam::RBD::restraints::sphericalAngularDamper::restrain() const
|
|||||||
Info<< " moment " << moment << endl;
|
Info<< " moment " << moment << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spatialVector(moment, Zero);
|
// Accumulate the force for the restrained body
|
||||||
|
fx[bodyIndex_] += spatialVector(moment, Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,8 +93,13 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
//- Return the external force applied to the body by this restraint
|
//- Accumulate the retraint internal joint forces into the tau field and
|
||||||
virtual spatialVector restrain() const;
|
// external forces into the fx field
|
||||||
|
virtual void restrain
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Update properties from given dictionary
|
//- Update properties from given dictionary
|
||||||
virtual bool read(const dictionary& dict);
|
virtual bool read(const dictionary& dict);
|
||||||
|
@ -29,7 +29,11 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
void Foam::RBD::rigidBodyModel::applyRestraints(Field<spatialVector>& fx) const
|
void Foam::RBD::rigidBodyModel::applyRestraints
|
||||||
|
(
|
||||||
|
scalarField& tau,
|
||||||
|
Field<spatialVector>& fx
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
if (restraints_.empty())
|
if (restraints_.empty())
|
||||||
{
|
{
|
||||||
@ -41,7 +45,7 @@ void Foam::RBD::rigidBodyModel::applyRestraints(Field<spatialVector>& fx) const
|
|||||||
DebugInfo << "Restraint " << restraints_[ri].name();
|
DebugInfo << "Restraint " << restraints_[ri].name();
|
||||||
|
|
||||||
// Accumulate the restraint forces
|
// Accumulate the restraint forces
|
||||||
fx[master(restraints_[ri].bodyID())] += restraints_[ri].restrain();
|
restraints_[ri].restrain(tau, fx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,9 +322,9 @@ public:
|
|||||||
//- Return the velocity of the given point on the given body
|
//- Return the velocity of the given point on the given body
|
||||||
spatialVector v(const label bodyID, const vector& p) const;
|
spatialVector v(const label bodyID, const vector& p) const;
|
||||||
|
|
||||||
//- Apply the restraints and accumulate the external forces
|
//- Apply the restraints and accumulate the internal joint forces
|
||||||
// into the fx field
|
// into the tau field and external forces into the fx field
|
||||||
void applyRestraints(Field<spatialVector>& fx) const;
|
void applyRestraints(scalarField& tau, Field<spatialVector>& fx) const;
|
||||||
|
|
||||||
//- Calculate the joint acceleration qDdot from the joint state q,
|
//- Calculate the joint acceleration qDdot from the joint state q,
|
||||||
// velocity qDot, internal force tau (in the joint frame) and
|
// velocity qDot, internal force tau (in the joint frame) and
|
||||||
|
@ -70,11 +70,12 @@ void Foam::RBD::rigidBodySolvers::CrankNicolson::solve
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Accumulate the restraint forces
|
// Accumulate the restraint forces
|
||||||
|
scalarField rtau(tau);
|
||||||
Field<spatialVector> rfx(fx);
|
Field<spatialVector> rfx(fx);
|
||||||
model_.applyRestraints(rfx);
|
model_.applyRestraints(rtau, rfx);
|
||||||
|
|
||||||
// Calculate the accelerations for the given state and forces
|
// Calculate the accelerations for the given state and forces
|
||||||
model_.forwardDynamics(state(), tau, rfx);
|
model_.forwardDynamics(state(), rtau, rfx);
|
||||||
|
|
||||||
// Correct velocity
|
// Correct velocity
|
||||||
qDot() = qDot0() + deltaT()*(aoc_*qDdot() + (1 - aoc_)*qDdot0());
|
qDot() = qDot0() + deltaT()*(aoc_*qDdot() + (1 - aoc_)*qDdot0());
|
||||||
|
@ -77,11 +77,12 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Accumulate the restraint forces
|
// Accumulate the restraint forces
|
||||||
|
scalarField rtau(tau);
|
||||||
Field<spatialVector> rfx(fx);
|
Field<spatialVector> rfx(fx);
|
||||||
model_.applyRestraints(rfx);
|
model_.applyRestraints(rtau, rfx);
|
||||||
|
|
||||||
// Calculate the accelerations for the given state and forces
|
// Calculate the accelerations for the given state and forces
|
||||||
model_.forwardDynamics(state(), tau, rfx);
|
model_.forwardDynamics(state(), rtau, rfx);
|
||||||
|
|
||||||
// Correct velocity
|
// Correct velocity
|
||||||
qDot() = qDot0()
|
qDot() = qDot0()
|
||||||
|
@ -79,12 +79,13 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve
|
|||||||
model_.forwardDynamicsCorrection(state());
|
model_.forwardDynamicsCorrection(state());
|
||||||
|
|
||||||
// Accumulate the restraint forces
|
// Accumulate the restraint forces
|
||||||
|
scalarField rtau(tau);
|
||||||
Field<spatialVector> rfx(fx);
|
Field<spatialVector> rfx(fx);
|
||||||
model_.applyRestraints(rfx);
|
model_.applyRestraints(rtau, rfx);
|
||||||
|
|
||||||
// Calculate the body acceleration for the given state
|
// Calculate the body acceleration for the given state
|
||||||
// and restraint forces
|
// and restraint forces
|
||||||
model_.forwardDynamics(state(), tau, rfx);
|
model_.forwardDynamics(state(), rtau, rfx);
|
||||||
|
|
||||||
// Second simplectic step:
|
// Second simplectic step:
|
||||||
// Complete update of linear and angular velocities
|
// Complete update of linear and angular velocities
|
||||||
|
Loading…
Reference in New Issue
Block a user