rigidBodyDynamics/rigidBodyModelState: New class to hold the motion state of the rigid-body model

This is a more convenient way of maintaining the state or multiple
states (for higher-order integration), storing, retrieving and passing
between processors.
This commit is contained in:
Henry Weller
2016-04-11 19:01:16 +01:00
parent 5c4719dea0
commit 33be0fa564
9 changed files with 421 additions and 55 deletions

View File

@ -32,6 +32,7 @@ Description
#include "rigidBodyModel.H"
#include "masslessBody.H"
#include "rigidBodyModelState.H"
#include "sphere.H"
#include "joints.H"
#include "IFstream.H"
@ -86,10 +87,11 @@ int main(int argc, char *argv[])
Info<< pendulum << endl;
// Create the joint-space state fields
scalarField q(pendulum.nDoF(), Zero);
scalarField w(pendulum.nw(), Zero);
scalarField qDot(pendulum.nDoF(), Zero);
scalarField qDdot(pendulum.nDoF(), Zero);
rigidBodyModelState pendulumState(pendulum);
scalarField& q = pendulumState.q();
scalarField& qDot = pendulumState.qDot();
scalarField& qDdot = pendulumState.qDdot();
scalarField tau(pendulum.nDoF(), Zero);
// Set the angle of the pendulum to 0.3rad
@ -106,15 +108,7 @@ int main(int argc, char *argv[])
qDot += 0.5*deltaT*qDdot;
q += deltaT*qDot;
pendulum.forwardDynamics
(
q,
w,
qDot,
tau,
Field<spatialVector>(),
qDdot
);
pendulum.forwardDynamics(pendulumState, tau, Field<spatialVector>());
qDot += 0.5*deltaT*qDdot;

View File

@ -34,6 +34,7 @@ Description
#include "sphere.H"
#include "joints.H"
#include "rigidBodyRestraint.H"
#include "rigidBodyModelState.H"
#include "IFstream.H"
#include "OFstream.H"
@ -50,10 +51,11 @@ int main(int argc, char *argv[])
Info<< spring << endl;
// Create the joint-space state fields
scalarField q(spring.nDoF(), Zero);
scalarField w(spring.nw(), Zero);
scalarField qDot(spring.nDoF(), Zero);
scalarField qDdot(spring.nDoF(), Zero);
rigidBodyModelState springState(spring);
scalarField& q = springState.q();
scalarField& qDot = springState.qDot();
scalarField& qDdot = springState.qDdot();
scalarField tau(spring.nDoF(), Zero);
Field<spatialVector> fx(spring.nBodies(), Zero);
@ -68,13 +70,7 @@ int main(int argc, char *argv[])
q += deltaT*qDot;
// Update the body-state prior to the evaluation of the restraints
spring.forwardDynamicsCorrection
(
q,
w,
qDot,
qDdot
);
spring.forwardDynamicsCorrection(springState);
// Accumulate the restraint forces
fx = Zero;
@ -82,15 +78,7 @@ int main(int argc, char *argv[])
// Calculate the body acceleration for the given state
// and restraint forces
spring.forwardDynamics
(
q,
w,
qDot,
tau,
fx,
qDdot
);
spring.forwardDynamics(springState, tau, fx);
// Update the velocity
qDot += 0.5*deltaT*qDdot;