mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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;
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user