rigidBodyDynamics: Simplified the interface to the solvers

This commit is contained in:
Henry Weller 2016-04-12 12:57:31 +01:00
parent 5cfd0fbd47
commit 9e24a9b5e2
12 changed files with 47 additions and 40 deletions

View file

@ -71,13 +71,7 @@ int main(int argc, char *argv[])
for (label i=0; i<nIter; i++) for (label i=0; i<nIter; i++)
{ {
spring.update spring.solve(deltaT, tau, fx);
(
deltaT,
deltaT,
tau,
fx
);
} }
// Write the results for graph generation // Write the results for graph generation

View file

@ -79,17 +79,18 @@ Foam::RBD::rigidBodyMotion::~rigidBodyMotion()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::rigidBodyMotion::update void Foam::RBD::rigidBodyMotion::solve
( (
scalar deltaT, scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
) )
{ {
deltaT_ = deltaT;
if (Pstream::master()) if (Pstream::master())
{ {
solver_->solve(deltaT, deltaT0, tau, fx); solver_->solve(tau, fx);
if (report_) if (report_)
{ {

View file

@ -79,6 +79,12 @@ class rigidBodyMotion
//- Motion state data object for previous time-step //- Motion state data object for previous time-step
rigidBodyModelState motionState0_; rigidBodyModelState motionState0_;
//- The current time-step
scalar deltaT_;
//- The previous time-step
scalar deltaT0_;
//- Acceleration relaxation coefficient //- Acceleration relaxation coefficient
scalar aRelax_; scalar aRelax_;
@ -140,11 +146,11 @@ public:
// Update state // Update state
//- Integration of velocities, orientation and position. //- Integrate velocities, orientation and position
void update // for the given time-step
void solve
( (
scalar deltaT, scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
); );

View file

@ -41,8 +41,10 @@ Foam::RBD::rigidBodyMotion::state() const
inline void Foam::RBD::rigidBodyMotion::newTime() inline void Foam::RBD::rigidBodyMotion::newTime()
{ {
motionState0_ = motionState_; motionState0_ = motionState_;
deltaT0_ = deltaT_;
} }
/* /*
inline Foam::point Foam::RBD::rigidBodyMotion::transform inline Foam::point Foam::RBD::rigidBodyMotion::transform
( (

View file

@ -65,8 +65,6 @@ Foam::RBD::rigidBodySolvers::CrankNicolson::~CrankNicolson()
void Foam::RBD::rigidBodySolvers::CrankNicolson::solve void Foam::RBD::rigidBodySolvers::CrankNicolson::solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
) )
@ -79,10 +77,10 @@ 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() + aDamp()*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());
// Update the body-state // Update the body-state
model_.forwardDynamicsCorrection(state()); model_.forwardDynamicsCorrection(state());

View file

@ -104,11 +104,9 @@ public:
// Member Functions // Member Functions
//- Integrate the rigid-body joint-state one time-step //- Integrate the rigid-body motion for one time-step
virtual void solve virtual void solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
); );

View file

@ -72,8 +72,6 @@ Foam::RBD::rigidBodySolvers::Newmark::~Newmark()
void Foam::RBD::rigidBodySolvers::Newmark::solve void Foam::RBD::rigidBodySolvers::Newmark::solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
) )
@ -86,12 +84,13 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve
model_.forwardDynamics(state(), tau, rfx); model_.forwardDynamics(state(), tau, rfx);
// Correct velocity // Correct velocity
qDot() = qDot0() + aDamp()*deltaT*(gamma_*qDdot() + (1 - gamma_)*qDdot0()); qDot() = qDot0()
+ aDamp()*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() + sqr(deltaT())*(0.5 - beta_)*qDdot0();
// Update the body-state // Update the body-state
model_.forwardDynamicsCorrection(state()); model_.forwardDynamicsCorrection(state());

View file

@ -102,11 +102,9 @@ public:
// Member Functions // Member Functions
//- Integrate the rigid-body joint-state one time-step //- Integrate the rigid-body motion for one time-step
virtual void solve virtual void solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
); );

View file

@ -62,9 +62,14 @@ protected:
//- Return the motion state //- Return the motion state
inline rigidBodyModelState& state(); inline rigidBodyModelState& state();
//- Return the motion state //- Return the previous motion state
inline const rigidBodyModelState& state0() const; inline const rigidBodyModelState& state0() const;
//- Return the current time-step
inline scalar deltaT() const;
//- Return the previous time-step
inline scalar deltaT0() const;
//- Return the current joint position and orientation //- Return the current joint position and orientation
inline scalarField& q(); inline scalarField& q();
@ -138,11 +143,9 @@ public:
// Member Functions // Member Functions
//- Integrate the rigid-body joint-state one time-step //- Integrate the rigid-body motion for one time-step
virtual void solve virtual void solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
) = 0; ) = 0;

View file

@ -38,6 +38,18 @@ Foam::RBD::rigidBodySolver::state0() const
} }
inline Foam::scalar Foam::RBD::rigidBodySolver::deltaT() const
{
return model_.deltaT_;
}
inline Foam::scalar Foam::RBD::rigidBodySolver::deltaT0() const
{
return model_.deltaT0_;
}
inline Foam::scalarField& Foam::RBD::rigidBodySolver::q() inline Foam::scalarField& Foam::RBD::rigidBodySolver::q()
{ {
return state().q(); return state().q();

View file

@ -63,8 +63,6 @@ Foam::RBD::rigidBodySolvers::symplectic::~symplectic()
void Foam::RBD::rigidBodySolvers::symplectic::solve void Foam::RBD::rigidBodySolvers::symplectic::solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
) )
@ -72,8 +70,8 @@ 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() + aDamp()*0.5*deltaT0()*qDdot();
q() = q0() + deltaT*qDot(); q() = q0() + deltaT()*qDot();
// Update the body-state prior to the evaluation of the restraints // Update the body-state prior to the evaluation of the restraints
model_.forwardDynamicsCorrection(state()); model_.forwardDynamicsCorrection(state());
@ -88,7 +86,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() += aDamp()*0.5*deltaT()*qDdot();
} }

View file

@ -101,11 +101,9 @@ public:
// Member Functions // Member Functions
//- Integrate the rigid-body joint-state one time-step //- Integrate the rigid-body motion for one time-step
virtual void solve virtual void solve
( (
scalar deltaT,
scalar deltaT0,
const scalarField& tau, const scalarField& tau,
const Field<spatialVector>& fx const Field<spatialVector>& fx
); );