applications/test/rigidBodyDynamics/pendulum: Cleanup

This commit is contained in:
Henry Weller
2016-04-10 23:07:23 +01:00
parent 6af11bfa02
commit 01d503b1c0
3 changed files with 11 additions and 12 deletions

View File

@ -1,3 +1,3 @@
pendulum.C pendulum.C
EXE = $(FOAM_USER_APPBIN)/pendulum EXE = $(FOAM_USER_APPBIN)/Test-pendulum

View File

@ -1,4 +1,4 @@
bodies bodies0
{ {
pendulum pendulum
{ {
@ -15,7 +15,7 @@ bodies
} }
} }
bodies0 bodies
{ {
hinge hinge
{ {

View File

@ -81,16 +81,15 @@ int main(int argc, char *argv[])
*/ */
// Create the pendulum model from dictionary // Create the pendulum model from dictionary
rigidBodyModel pendulum1(dictionary(IFstream("pendulum")())); rigidBodyModel pendulum(dictionary(IFstream("pendulum")()));
rigidBodyModel pendulum = pendulum1;
Info<< pendulum << endl; Info<< pendulum << endl;
// Create the joint-space state fields // Create the joint-space state fields
scalarField q(pendulum.nDoF(), Zero); scalarField q(pendulum.nDoF(), Zero);
scalarField w(pendulum.nw(), Zero); scalarField w(pendulum.nw(), Zero);
scalarField qdot(pendulum.nDoF(), Zero); scalarField qDot(pendulum.nDoF(), Zero);
scalarField qddot(pendulum.nDoF(), Zero); scalarField qDdot(pendulum.nDoF(), Zero);
scalarField tau(pendulum.nDoF(), Zero); scalarField tau(pendulum.nDoF(), Zero);
// Set the angle of the pendulum to 0.3rad // Set the angle of the pendulum to 0.3rad
@ -104,20 +103,20 @@ int main(int argc, char *argv[])
scalar deltaT = 0.01; scalar deltaT = 0.01;
for (scalar t=0; t<4.1; t+=deltaT) for (scalar t=0; t<4.1; t+=deltaT)
{ {
qdot += 0.5*deltaT*qddot; qDot += 0.5*deltaT*qDdot;
q += deltaT*qdot; q += deltaT*qDot;
pendulum.forwardDynamics pendulum.forwardDynamics
( (
q, q,
w, w,
qdot, qDot,
tau, tau,
Field<spatialVector>(), Field<spatialVector>(),
qddot qDdot
); );
qdot += 0.5*deltaT*qddot; qDot += 0.5*deltaT*qDdot;
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl; Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
} }