Skip to content
Snippets Groups Projects
Commit ebf00110 authored by Henry Weller's avatar Henry Weller
Browse files

src/rigidBodyDynamics/rigidBodyMotion: Added support for acceleration relaxation

parent 51bb5093
No related branches found
No related tags found
1 merge request!33Merge foundation
Showing with 33 additions and 22 deletions
...@@ -4,6 +4,7 @@ bodies/jointBody/jointBody.C ...@@ -4,6 +4,7 @@ bodies/jointBody/jointBody.C
bodies/compositeBody/compositeBody.C bodies/compositeBody/compositeBody.C
bodies/subBody/subBody.C bodies/subBody/subBody.C
bodies/sphere/sphere.C bodies/sphere/sphere.C
bodies/cuboid/cuboid.C
joints/joint/joint.C joints/joint/joint.C
joints/null/nullJoint.C joints/null/nullJoint.C
......
...@@ -125,6 +125,19 @@ Foam::spatialTransform Foam::RBD::rigidBodyMotion::X00 ...@@ -125,6 +125,19 @@ Foam::spatialTransform Foam::RBD::rigidBodyMotion::X00
} }
void Foam::RBD::rigidBodyMotion::forwardDynamics
(
rigidBodyModelState& state,
const scalarField& tau,
const Field<spatialVector>& fx
) const
{
scalarField qDdotPrev = state.qDdot();
rigidBodyModel::forwardDynamics(state, tau, fx);
state.qDdot() = aDamp_*(aRelax_*state.qDdot() + (1 - aRelax_)*qDdotPrev);
}
void Foam::RBD::rigidBodyMotion::solve void Foam::RBD::rigidBodyMotion::solve
( (
scalar deltaT, scalar deltaT,
......
...@@ -158,6 +158,16 @@ public: ...@@ -158,6 +158,16 @@ public:
// Update state // Update state
//- Calculate and optionally relax the joint acceleration qDdot from
// the joint state q, velocity qDot, internal force tau (in the
// joint frame) and external force fx (in the global frame)
void forwardDynamics
(
rigidBodyModelState& state,
const scalarField& tau,
const Field<spatialVector>& fx
) const;
//- Integrate velocities, orientation and position //- Integrate velocities, orientation and position
// for the given time-step // for the given time-step
void solve void solve
......
...@@ -77,7 +77,7 @@ void Foam::RBD::rigidBodySolvers::CrankNicolson::solve ...@@ -77,7 +77,7 @@ void Foam::RBD::rigidBodySolvers::CrankNicolson::solve
model_.forwardDynamics(state(), tau, rfx); model_.forwardDynamics(state(), tau, rfx);
// Correct velocity // Correct velocity
qDot() = qDot0() + aDamp()*deltaT()*(aoc_*qDdot() + (1 - aoc_)*qDdot0()); qDot() = qDot0() + deltaT()*(aoc_*qDdot() + (1 - aoc_)*qDdot0());
// Correct position // Correct position
q() = q0() + deltaT()*(voc_*qDot() + (1 - voc_)*qDot0()); q() = q0() + deltaT()*(voc_*qDot() + (1 - voc_)*qDot0());
......
...@@ -85,12 +85,12 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve ...@@ -85,12 +85,12 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve
// Correct velocity // Correct velocity
qDot() = qDot0() qDot() = qDot0()
+ aDamp()*deltaT()*(gamma_*qDdot() + (1 - gamma_)*qDdot0()); + deltaT()*(gamma_*qDdot() + (1 - gamma_)*qDdot0());
// Correct position // Correct position
q() = q0() q() = q0()
+ deltaT()*qDot0() + deltaT()*qDot0()
+ sqr(deltaT())*beta_*qDdot() + sqr(deltaT())*(0.5 - beta_)*qDdot0(); + sqr(deltaT())*(beta_*qDdot() + (0.5 - beta_)*qDdot0());
correctQuaternionJoints(); correctQuaternionJoints();
......
...@@ -94,10 +94,6 @@ protected: ...@@ -94,10 +94,6 @@ protected:
//- Return the previous time-step //- Return the previous time-step
inline scalar deltaT0() const; inline scalar deltaT0() const;
//- Acceleration damping coefficient (for steady-state simulations)
inline scalar aDamp() const;
//- Correct the quaternion joints based on the current change in q //- Correct the quaternion joints based on the current change in q
void correctQuaternionJoints(); void correctQuaternionJoints();
......
...@@ -85,10 +85,4 @@ inline Foam::scalar Foam::RBD::rigidBodySolver::deltaT0() const ...@@ -85,10 +85,4 @@ inline Foam::scalar Foam::RBD::rigidBodySolver::deltaT0() const
} }
inline Foam::scalar Foam::RBD::rigidBodySolver::aDamp() const
{
return model_.aDamp_;
}
// ************************************************************************* // // ************************************************************************* //
...@@ -70,7 +70,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve ...@@ -70,7 +70,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve
// First simplectic step: // First simplectic step:
// Half-step for linear and angular velocities // Half-step for linear and angular velocities
// Update position and orientation // Update position and orientation
qDot() = qDot0() + aDamp()*0.5*deltaT0()*qDdot(); qDot() = qDot0() + 0.5*deltaT0()*qDdot();
q() = q0() + deltaT()*qDot(); q() = q0() + deltaT()*qDot();
correctQuaternionJoints(); correctQuaternionJoints();
...@@ -88,7 +88,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve ...@@ -88,7 +88,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve
// Second simplectic step: // Second simplectic step:
// Complete update of linear and angular velocities // Complete update of linear and angular velocities
qDot() += aDamp()*0.5*deltaT()*qDdot(); qDot() += 0.5*deltaT()*qDdot();
} }
......
...@@ -250,19 +250,16 @@ void Foam::rigidBodyMeshMotion::solve() ...@@ -250,19 +250,16 @@ void Foam::rigidBodyMeshMotion::solve()
const label bodyID = bodyMeshes_[bi].bodyID_; const label bodyID = bodyMeshes_[bi].bodyID_;
dictionary forcesDict; dictionary forcesDict;
forcesDict.add("type", forces::typeName); forcesDict.add("type", forces::typeName);
forcesDict.add("patches", bodyMeshes_[bi].patches_); forcesDict.add("patches", bodyMeshes_[bi].patches_);
forcesDict.add("rhoInf", rhoInf_); forcesDict.add("rhoInf", rhoInf_);
forcesDict.add("rhoName", rhoName_); forcesDict.add("rhoName", rhoName_);
forcesDict.add("CofR", model_.X0(bodyID).r()); forcesDict.add("CofR", vector::zero);
forces f("forces", db(), forcesDict); forces f("forces", db(), forcesDict);
f.calcForcesMoment(); f.calcForcesMoment();
fx[bodyID].l() = f.forceEff(); fx[bodyID] = spatialVector(f.momentEff(), f.forceEff());
fx[bodyID].w() = f.momentEff();
} }
model_.solve model_.solve
......
...@@ -96,7 +96,7 @@ void Foam::sixDoFSolvers::Newmark::solve ...@@ -96,7 +96,7 @@ void Foam::sixDoFSolvers::Newmark::solve
tConstraints() tConstraints()
& ( & (
deltaT*v0() deltaT*v0()
+ sqr(deltaT)*beta_*a() + sqr(deltaT)*(0.5 - beta_)*a0() + aDamp()*sqr(deltaT)*(beta_*a() + (0.5 - beta_)*a0())
) )
); );
...@@ -105,7 +105,7 @@ void Foam::sixDoFSolvers::Newmark::solve ...@@ -105,7 +105,7 @@ void Foam::sixDoFSolvers::Newmark::solve
rConstraints() rConstraints()
& ( & (
deltaT*pi0() deltaT*pi0()
+ sqr(deltaT)*beta_*tau() + sqr(deltaT)*(0.5 - beta_)*tau0() + aDamp()*sqr(deltaT)*(beta_*tau() + (0.5 - beta_)*tau0())
); );
Tuple2<tensor, vector> Qpi = rotate(Q0(), piDeltaT, 1); Tuple2<tensor, vector> Qpi = rotate(Q0(), piDeltaT, 1);
Q() = Qpi.first(); Q() = Qpi.first();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment