diff --git a/applications/test/rigidBodyDynamics/rigidBodyDynamics/Make/files b/applications/test/rigidBodyDynamics/Make/files
similarity index 100%
rename from applications/test/rigidBodyDynamics/rigidBodyDynamics/Make/files
rename to applications/test/rigidBodyDynamics/Make/files
diff --git a/applications/test/rigidBodyDynamics/pendulum/Make/options b/applications/test/rigidBodyDynamics/Make/options
similarity index 100%
rename from applications/test/rigidBodyDynamics/pendulum/Make/options
rename to applications/test/rigidBodyDynamics/Make/options
diff --git a/applications/test/rigidBodyDynamics/pendulum b/applications/test/rigidBodyDynamics/pendulum
new file mode 100644
index 000000000..86214541d
--- /dev/null
+++ b/applications/test/rigidBodyDynamics/pendulum
@@ -0,0 +1,52 @@
+solver
+{
+ type symplectic;
+}
+
+bodies
+{
+ hinge
+ {
+ type masslessBody;
+ parent root;
+ transform (1 0 0 0 1 0 0 0 1) (0 0 0);
+ joint
+ {
+ type Rz;
+ }
+ outline
+ (
+ (0 0 0)
+ (0 -0.95 0)
+ (0.025 -0.95669873 0)
+ (0.04330127 -0.975 0)
+ (0.05 -1 0)
+ (0.04330127 -1.025 0)
+ (0.025 -1.04330127 0)
+ (0 -1.05 0)
+ (-0.025 -1.04330127 0)
+ (-0.04330127 -1.025 0)
+ (-0.05 -1 0)
+ (-0.04330127 -0.975 0)
+ (-0.025 -0.95669873 0)
+ (0 -0.95 0)
+ );
+ }
+ weight
+ {
+ type sphere;
+ mass 1;
+ radius 0.05;
+ centreOfMass (0 0 0);
+ transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
+ mergeWith hinge;
+ }
+}
+
+g (0 -9.81 0);
+
+q (0.3);
+
+deltaT 0.01;
+
+endTime 4.1;
diff --git a/applications/test/rigidBodyDynamics/pendulum/Make/files b/applications/test/rigidBodyDynamics/pendulum/Make/files
deleted file mode 100644
index 471ba2b58..000000000
--- a/applications/test/rigidBodyDynamics/pendulum/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-pendulum.C
-
-EXE = $(FOAM_USER_APPBIN)/Test-pendulum
diff --git a/applications/test/rigidBodyDynamics/pendulum/pendulum b/applications/test/rigidBodyDynamics/pendulum/pendulum
deleted file mode 100644
index d179af443..000000000
--- a/applications/test/rigidBodyDynamics/pendulum/pendulum
+++ /dev/null
@@ -1,38 +0,0 @@
-bodies0
-{
- pendulum
- {
- type rigidBody;
- mass 1;
- centreOfMass (0 -1 0);
- inertia (0.001 0 0 0.001 0 0.001);
- parent root;
- transform (1 0 0 0 1 0 0 0 1) (0 0 0);
- joint
- {
- type Rz;
- }
- }
-}
-
-bodies
-{
- hinge
- {
- type masslessBody;
- parent root;
- transform (1 0 0 0 1 0 0 0 1) (0 0 0);
- joint
- {
- type Rz;
- }
- }
- weight
- {
- type sphere;
- mass 1;
- radius 0.05;
- transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
- mergeWith hinge;
- }
-}
diff --git a/applications/test/rigidBodyDynamics/pendulum/pendulum.C b/applications/test/rigidBodyDynamics/pendulum/pendulum.C
deleted file mode 100644
index cc9fc374e..000000000
--- a/applications/test/rigidBodyDynamics/pendulum/pendulum.C
+++ /dev/null
@@ -1,124 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
- \\/ M anipulation |
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-Application
- pendulum
-
-Description
- Simple swinging pendulum simulation with 1-DoF. The motion is integrated
- using a symplectic method for just over 2-periods.
-
-\*---------------------------------------------------------------------------*/
-
-#include "rigidBodyModel.H"
-#include "masslessBody.H"
-#include "rigidBodyModelState.H"
-#include "sphere.H"
-#include "joints.H"
-#include "IFstream.H"
-
-using namespace Foam;
-using namespace RBD;
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-int main(int argc, char *argv[])
-{
- /*
- bool testMerge = true;
-
- // Create a model for the pendulum
- rigidBodyModel pendulum;
-
- // Join a weight to the origin with a centre of mass -1m below the origin
- // by a hinge which rotates about the z-axis
- if (testMerge)
- {
- pendulum.join
- (
- pendulum.bodyID("root"),
- Xt(Zero),
- joint::New(new joints::Rz()),
- autoPtr(new masslessBody("hinge"))
- );
-
- pendulum.merge
- (
- pendulum.bodyID("hinge"),
- Xt(vector(0, -1, 0)),
- autoPtr(new sphere("weight", 1, 0.05))
- );
- }
- else
- {
- pendulum.join
- (
- pendulum.bodyID("root"),
- Xt(Zero),
- joint::New(new joints::Rz()),
- rigidBody::New("pendulum", 1, vector(0, -1, 0), 1e-3*I)
- );
- }
- */
-
- // Create the pendulum model from dictionary
- rigidBodyModel pendulum(dictionary(IFstream("pendulum")()));
-
- Info<< pendulum << endl;
-
- // Create the joint-space state fields
- 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
- q[0] = 0.3;
-
- // Set the gravitational acceleration
- pendulum.g() = vector(0, -9.81, 0);
-
- // Integrate the motion of the pendulum for 4.1s (~2-periods) using a
- // symplectic method
- scalar deltaT = 0.01;
- for (scalar t=0; t<4.1; t+=deltaT)
- {
- qDot += 0.5*deltaT*qDdot;
- q += deltaT*qDot;
-
- pendulum.forwardDynamics(pendulumState, tau, Field());
-
- qDot += 0.5*deltaT*qDdot;
-
- Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
- }
-
- Info<< "\nEnd\n" << endl;
-
- return 0;
-}
-
-
-// ************************************************************************* //
diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring b/applications/test/rigidBodyDynamics/pendulumAndSpring
similarity index 57%
rename from applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring
rename to applications/test/rigidBodyDynamics/pendulumAndSpring
index ec9c3517b..95a25c42e 100644
--- a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring
+++ b/applications/test/rigidBodyDynamics/pendulumAndSpring
@@ -3,9 +3,6 @@ solver
type Newmark;
}
-// It is necessary to iterate for the Newmark solver
-nIter 2;
-
bodies
{
M
@@ -14,6 +11,7 @@ bodies
parent root;
mass 6e4;
radius 0.01;
+ centreOfMass (0 0 0);
transform (1 0 0 0 1 0 0 0 1) (0 0 0);
joint
{
@@ -29,6 +27,21 @@ bodies
}
);
}
+ outline
+ (
+ (0 0.01 0)
+ (0.005 0.00866025 0)
+ (0.00866025 0.005 0)
+ (0.01 0 0)
+ (0.00866025 -0.005 0)
+ (0.005 -0.00866025 0)
+ (0 -0.01 0)
+ (-0.00866025 -0.005 0)
+ (-0.01 0 0)
+ (-0.00866025 0.005 0)
+ (-0.005 0.00866025 0)
+ (0 0.01 0)
+ );
}
m
@@ -37,8 +50,24 @@ bodies
parent M;
mass 6e3;
radius 0.01;
+ centreOfMass (0 0 0);
transform (1 0 0 0 1 0 0 0 1) (0 -5 0);
mergeWith M;
+ outline
+ (
+ (0 0.01 0)
+ (0.005 0.00866025 0)
+ (0.00866025 0.005 0)
+ (0.01 0 0)
+ (0.00866025 -0.005 0)
+ (0.005 -0.00866025 0)
+ (0 -0.01 0)
+ (-0.00866025 -0.005 0)
+ (-0.01 0 0)
+ (-0.00866025 0.005 0)
+ (-0.005 0.00866025 0)
+ (0 0.01 0)
+ );
}
}
@@ -62,3 +91,10 @@ g (0 -9.81 0);
// Set the initial offset of the pendulum to 1.5m
// and the angle of the pendulum to 30deg
q (1.5 0.5235987);
+
+deltaT 0.01;
+
+// It is necessary to iterate for the Newmark solver
+nIter 2;
+
+endTime 20;
diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.gnuplot b/applications/test/rigidBodyDynamics/pendulumAndSpring.gnuplot
similarity index 89%
rename from applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.gnuplot
rename to applications/test/rigidBodyDynamics/pendulumAndSpring.gnuplot
index 90e5c9b4c..9e7140a59 100644
--- a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.gnuplot
+++ b/applications/test/rigidBodyDynamics/pendulumAndSpring.gnuplot
@@ -2,7 +2,7 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
-# \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
+# \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
@@ -47,7 +47,7 @@ set terminal postscript eps color enhanced solid
set output "pendulumAndSpring.eps"
plot \
- "xVsTime" u 1:2 w l t "x", \
- "omegaVsTime" u 1:(57.29578*$2) w l axes x1y2 t "omega"
+ "pendulumAndSpring.dat" u 1:2 w l t "x", \
+ "pendulumAndSpring.dat" u 1:(57.29578*$2) w l axes x1y2 t "omega"
#------------------------------------------------------------------------------
diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/files b/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/files
deleted file mode 100644
index aef882dc3..000000000
--- a/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/files
+++ /dev/null
@@ -1,3 +0,0 @@
-pendulumAndSpring.C
-
-EXE = $(FOAM_USER_APPBIN)/Test-pendulumAndSpring
diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/options b/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/options
deleted file mode 100644
index 4a9d828b6..000000000
--- a/applications/test/rigidBodyDynamics/pendulumAndSpring/Make/options
+++ /dev/null
@@ -1,5 +0,0 @@
-EXE_INC = \
- -I$(LIB_SRC)/rigidBodyDynamics/lnInclude
-
-EXE_LIBS = \
- -lrigidBodyDynamics
diff --git a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C b/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C
deleted file mode 100644
index b775b59bb..000000000
--- a/applications/test/rigidBodyDynamics/pendulumAndSpring/pendulumAndSpring.C
+++ /dev/null
@@ -1,92 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
- \\/ M anipulation |
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software: you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM. If not, see .
-
-Application
- pendulumAndSpring
-
-Description
- Simple 2-DoF pendulum and spring simulation.
-
-\*---------------------------------------------------------------------------*/
-
-#include "rigidBodyMotion.H"
-#include "masslessBody.H"
-#include "sphere.H"
-#include "joints.H"
-#include "rigidBodyRestraint.H"
-#include "rigidBodyModelState.H"
-#include "IFstream.H"
-#include "OFstream.H"
-#include "constants.H"
-
-using namespace Foam;
-using namespace RBD;
-using namespace Foam::constant::mathematical;
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-int main(int argc, char *argv[])
-{
- dictionary pendulumAndSpringDict(IFstream("pendulumAndSpring")());
-
- // Create the pendulumAndSpring model from dictionary
- rigidBodyMotion pendulumAndSpring(pendulumAndSpringDict);
-
- label nIter(readLabel(pendulumAndSpringDict.lookup("nIter")));
-
- Info<< pendulumAndSpring << endl;
- Info<< "// Joint state " << endl;
- pendulumAndSpring.state().write(Info);
-
- // Create the joint-space force field
- scalarField tau(pendulumAndSpring.nDoF(), Zero);
-
- // Create the external body force field
- Field fx(pendulumAndSpring.nBodies(), Zero);
-
- OFstream xFile("xVsTime");
- OFstream omegaFile("omegaVsTime");
-
- // Integrate the motion of the pendulumAndSpring for 100s
- scalar deltaT = 0.01;
- for (scalar t=0; t<20; t+=deltaT)
- {
- pendulumAndSpring.newTime();
-
- for (label i=0; i.
+
+Application
+ RBD
+
+Description
+ Does an RBD simulation and outputs the result as a gnuplot animation
+
+\*---------------------------------------------------------------------------*/
+
+#include "rigidBodyMotion.H"
+#include "IFstream.H"
+#include "OFstream.H"
+#include "boundBox.H"
+#include "argList.H"
+
+using namespace Foam;
+using namespace RBD;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+int main(int argc, char *argv[])
+{
+ // Create the input dictionary
+ argList::validArgs.append("dictionary");
+ argList args(argc, argv);
+ const word dictName(args[1]);
+ Info<< "Reading " << dictName << nl << endl;
+ const dictionary dict = IFstream(dictName)();
+
+ // Read the model, time controls and plot outlines from the dictionary
+ rigidBodyMotion motion(dict);
+ const scalar deltaT(readScalar(dict.lookup("deltaT")));
+ const label nIter(dict.lookupOrDefault