Commit 9e24a9b5 authored by Henry Weller's avatar Henry Weller
Browse files

rigidBodyDynamics: Simplified the interface to the solvers

parent 5cfd0fbd
......@@ -71,13 +71,7 @@ int main(int argc, char *argv[])
for (label i=0; i<nIter; i++)
{
spring.update
(
deltaT,
deltaT,
tau,
fx
);
spring.solve(deltaT, tau, fx);
}
// Write the results for graph generation
......
......@@ -79,17 +79,18 @@ Foam::RBD::rigidBodyMotion::~rigidBodyMotion()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::rigidBodyMotion::update
void Foam::RBD::rigidBodyMotion::solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
)
{
deltaT_ = deltaT;
if (Pstream::master())
{
solver_->solve(deltaT, deltaT0, tau, fx);
solver_->solve(tau, fx);
if (report_)
{
......
......@@ -79,6 +79,12 @@ class rigidBodyMotion
//- Motion state data object for previous time-step
rigidBodyModelState motionState0_;
//- The current time-step
scalar deltaT_;
//- The previous time-step
scalar deltaT0_;
//- Acceleration relaxation coefficient
scalar aRelax_;
......@@ -140,11 +146,11 @@ public:
// Update state
//- Integration of velocities, orientation and position.
void update
//- Integrate velocities, orientation and position
// for the given time-step
void solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
);
......
......@@ -41,8 +41,10 @@ Foam::RBD::rigidBodyMotion::state() const
inline void Foam::RBD::rigidBodyMotion::newTime()
{
motionState0_ = motionState_;
deltaT0_ = deltaT_;
}
/*
inline Foam::point Foam::RBD::rigidBodyMotion::transform
(
......
......@@ -65,8 +65,6 @@ Foam::RBD::rigidBodySolvers::CrankNicolson::~CrankNicolson()
void Foam::RBD::rigidBodySolvers::CrankNicolson::solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
)
......@@ -79,10 +77,10 @@ void Foam::RBD::rigidBodySolvers::CrankNicolson::solve
model_.forwardDynamics(state(), tau, rfx);
// Correct velocity
qDot() = qDot0() + aDamp()*deltaT*(aoc_*qDdot() + (1 - aoc_)*qDdot0());
qDot() = qDot0() + aDamp()*deltaT()*(aoc_*qDdot() + (1 - aoc_)*qDdot0());
// Correct position
q() = q0() + deltaT*(voc_*qDot() + (1 - voc_)*qDot0());
q() = q0() + deltaT()*(voc_*qDot() + (1 - voc_)*qDot0());
// Update the body-state
model_.forwardDynamicsCorrection(state());
......
......@@ -104,11 +104,9 @@ public:
// Member Functions
//- Integrate the rigid-body joint-state one time-step
//- Integrate the rigid-body motion for one time-step
virtual void solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
);
......
......@@ -72,8 +72,6 @@ Foam::RBD::rigidBodySolvers::Newmark::~Newmark()
void Foam::RBD::rigidBodySolvers::Newmark::solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
)
......@@ -86,12 +84,13 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve
model_.forwardDynamics(state(), tau, rfx);
// Correct velocity
qDot() = qDot0() + aDamp()*deltaT*(gamma_*qDdot() + (1 - gamma_)*qDdot0());
qDot() = qDot0()
+ aDamp()*deltaT()*(gamma_*qDdot() + (1 - gamma_)*qDdot0());
// Correct position
q() = q0()
+ deltaT*qDot0()
+ sqr(deltaT)*beta_*qDdot() + sqr(deltaT)*(0.5 - beta_)*qDdot0();
+ deltaT()*qDot0()
+ sqr(deltaT())*beta_*qDdot() + sqr(deltaT())*(0.5 - beta_)*qDdot0();
// Update the body-state
model_.forwardDynamicsCorrection(state());
......
......@@ -102,11 +102,9 @@ public:
// Member Functions
//- Integrate the rigid-body joint-state one time-step
//- Integrate the rigid-body motion for one time-step
virtual void solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
);
......
......@@ -62,9 +62,14 @@ protected:
//- Return the motion state
inline rigidBodyModelState& state();
//- Return the motion state
//- Return the previous motion state
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
inline scalarField& q();
......@@ -138,11 +143,9 @@ public:
// Member Functions
//- Integrate the rigid-body joint-state one time-step
//- Integrate the rigid-body motion for one time-step
virtual void solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
) = 0;
......
......@@ -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()
{
return state().q();
......
......@@ -63,8 +63,6 @@ Foam::RBD::rigidBodySolvers::symplectic::~symplectic()
void Foam::RBD::rigidBodySolvers::symplectic::solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
)
......@@ -72,8 +70,8 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve
// First simplectic step:
// Half-step for linear and angular velocities
// Update position and orientation
qDot() = qDot0() + aDamp()*0.5*deltaT0*qDdot();
q() = q0() + deltaT*qDot();
qDot() = qDot0() + aDamp()*0.5*deltaT0()*qDdot();
q() = q0() + deltaT()*qDot();
// Update the body-state prior to the evaluation of the restraints
model_.forwardDynamicsCorrection(state());
......@@ -88,7 +86,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve
// Second simplectic step:
// Complete update of linear and angular velocities
qDot() += aDamp()*0.5*deltaT*qDdot();
qDot() += aDamp()*0.5*deltaT()*qDdot();
}
......
......@@ -101,11 +101,9 @@ public:
// Member Functions
//- Integrate the rigid-body joint-state one time-step
//- Integrate the rigid-body motion for one time-step
virtual void solve
(
scalar deltaT,
scalar deltaT0,
const scalarField& tau,
const Field<spatialVector>& fx
);
......
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