diff --git a/src/rigidBodyDynamics/Make/files b/src/rigidBodyDynamics/Make/files
index 7fc99c209a..1e658c85e9 100644
--- a/src/rigidBodyDynamics/Make/files
+++ b/src/rigidBodyDynamics/Make/files
@@ -5,7 +5,9 @@ bodies/subBody/subBody.C
bodies/sphere/sphere.C
joints/joint/joint.C
-joints/nullJoint/nullJoint.C
+joints/null/nullJoint.C
+joints/composite/compositeJoint.C
+joints/floating/floatingJoint.C
joints/Rx/Rx.C
joints/Ry/Ry.C
diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.C b/src/rigidBodyDynamics/joints/Pa/Pa.C
index 2263ce3283..0bdfa0a42b 100644
--- a/src/rigidBodyDynamics/joints/Pa/Pa.C
+++ b/src/rigidBodyDynamics/joints/Pa/Pa.C
@@ -54,7 +54,7 @@ Foam::RBD::joints::Pa::Pa(const vector& axis)
:
joint(1)
{
- S_[0] = spatialVector(Zero, axis);
+ S_[0] = spatialVector(Zero, axis/mag(axis));
}
@@ -62,7 +62,8 @@ Foam::RBD::joints::Pa::Pa(const dictionary& dict)
:
joint(1)
{
- S_[0] = spatialVector(Zero, dict.lookup("axis"));
+ vector axis(dict.lookup("axis"));
+ S_[0] = spatialVector(Zero, axis/mag(axis));
}
@@ -95,4 +96,12 @@ void Foam::RBD::joints::Pa::jcalc
}
+void Foam::RBD::joints::Pa::write(Ostream& os) const
+{
+ joint::write(os);
+ os.writeKeyword("axis")
+ << S_[0].l() << token::END_STATEMENT << nl;
+}
+
+
// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/Pa/Pa.H b/src/rigidBodyDynamics/joints/Pa/Pa.H
index 09f7eee753..f27a8c850a 100644
--- a/src/rigidBodyDynamics/joints/Pa/Pa.H
+++ b/src/rigidBodyDynamics/joints/Pa/Pa.H
@@ -95,6 +95,9 @@ public:
const scalarField& w,
const scalarField& qDot
) const;
+
+ //- Write
+ virtual void write(Ostream&) const;
};
diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.C b/src/rigidBodyDynamics/joints/Ra/Ra.C
index 6d9e6aa5fe..926f56a3b8 100644
--- a/src/rigidBodyDynamics/joints/Ra/Ra.C
+++ b/src/rigidBodyDynamics/joints/Ra/Ra.C
@@ -54,7 +54,7 @@ Foam::RBD::joints::Ra::Ra(const vector& axis)
:
joint(1)
{
- S_[0] = spatialVector(axis, Zero);
+ S_[0] = spatialVector(axis/mag(axis), Zero);
}
@@ -62,7 +62,8 @@ Foam::RBD::joints::Ra::Ra(const dictionary& dict)
:
joint(1)
{
- S_[0] = spatialVector(dict.lookup("axis"), Zero);
+ vector axis(dict.lookup("axis"));
+ S_[0] = spatialVector(axis/mag(axis), Zero);
}
@@ -95,4 +96,12 @@ void Foam::RBD::joints::Ra::jcalc
}
+void Foam::RBD::joints::Ra::write(Ostream& os) const
+{
+ joint::write(os);
+ os.writeKeyword("axis")
+ << S_[0].w() << token::END_STATEMENT << nl;
+}
+
+
// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/Ra/Ra.H b/src/rigidBodyDynamics/joints/Ra/Ra.H
index d098b2c82e..def3724c13 100644
--- a/src/rigidBodyDynamics/joints/Ra/Ra.H
+++ b/src/rigidBodyDynamics/joints/Ra/Ra.H
@@ -95,6 +95,9 @@ public:
const scalarField& w,
const scalarField& qDot
) const;
+
+ //- Write
+ virtual void write(Ostream&) const;
};
diff --git a/src/rigidBodyDynamics/joints/composite/compositeJoint.C b/src/rigidBodyDynamics/joints/composite/compositeJoint.C
new file mode 100644
index 0000000000..28044e9493
--- /dev/null
+++ b/src/rigidBodyDynamics/joints/composite/compositeJoint.C
@@ -0,0 +1,115 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "compositeJoint.H"
+#include "rigidBodyModel.H"
+#include "addToRunTimeSelectionTable.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace RBD
+{
+namespace joints
+{
+ defineTypeNameAndDebug(composite, 0);
+
+ addToRunTimeSelectionTable
+ (
+ joint,
+ composite,
+ dictionary
+ );
+}
+}
+}
+
+
+// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
+
+void Foam::RBD::joints::composite::setLastJoint()
+{
+ last().joint::operator=(*this);
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::RBD::joints::composite::composite(const PtrList& joints)
+:
+ PtrList(joints),
+ joint(last())
+{}
+
+
+Foam::RBD::joints::composite::composite(const dictionary& dict)
+:
+ PtrList(dict.lookup("joints")),
+ joint(last())
+{}
+
+
+Foam::autoPtr Foam::RBD::joints::composite::clone() const
+{
+ return autoPtr(new composite(*this));
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::RBD::joints::composite::~composite()
+{}
+
+
+// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+
+Foam::label Foam::RBD::joints::composite::nw() const
+{
+ return last().nw();
+}
+
+
+void Foam::RBD::joints::composite::jcalc
+(
+ joint::XSvc& J,
+ const scalarField& q,
+ const scalarField& w,
+ const scalarField& qDot
+) const
+{
+ last().jcalc(J, q, w, qDot);
+}
+
+
+void Foam::RBD::joints::composite::write(Ostream& os) const
+{
+ joint::write(os);
+ os.writeKeyword("joints");
+ os << static_cast&>(*this);
+}
+
+
+// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/composite/compositeJoint.H b/src/rigidBodyDynamics/joints/composite/compositeJoint.H
new file mode 100644
index 0000000000..c3033b4abd
--- /dev/null
+++ b/src/rigidBodyDynamics/joints/composite/compositeJoint.H
@@ -0,0 +1,131 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+Class
+ Foam::RBD::joints::composite
+
+Description
+ Prismatic joint for translation along the specified arbitrary axis.
+
+ Reference:
+ \verbatim
+ Featherstone, R. (2008).
+ Rigid body dynamics algorithms.
+ Springer.
+ Chapter 4.
+ \endverbatim
+
+SourceFiles
+ composite.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef RBD_joints_composite_H
+#define RBD_joints_composite_H
+
+#include "joint.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace RBD
+{
+
+// Forward declaration of classes
+class rigidBodyModel;
+
+namespace joints
+{
+
+/*---------------------------------------------------------------------------*\
+ Class composite Declaration
+\*---------------------------------------------------------------------------*/
+
+class composite
+:
+ public PtrList,
+ public joint
+{
+ // Private member functions
+
+ //- Set the properties of the last joint following construction
+ // of the body containing the joint
+ void setLastJoint();
+
+
+public:
+
+ //- Runtime type information
+ TypeName("composite");
+
+ //- Allow the rigidBodyModel class to set the last joint state
+ friend class Foam::RBD::rigidBodyModel;
+
+
+ // Constructors
+
+ //- Construct for given PtrList
+ composite(const PtrList& joints);
+
+ //- Construct for given model from dictionary
+ composite(const dictionary& dict);
+
+ //- Clone this joint
+ virtual autoPtr clone() const;
+
+
+ //- Destructor
+ virtual ~composite();
+
+
+ // Member Functions
+
+ //- Return the number of additional state variables need by this joint
+ virtual label nw() const;
+
+ //- Update the model state for this joint
+ virtual void jcalc
+ (
+ joint::XSvc& J,
+ const scalarField& q,
+ const scalarField& w,
+ const scalarField& qDot
+ ) const;
+
+ //- Write
+ virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace joints
+} // End namespace RBD
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/floating/floatingJoint.C b/src/rigidBodyDynamics/joints/floating/floatingJoint.C
new file mode 100644
index 0000000000..766e6504f6
--- /dev/null
+++ b/src/rigidBodyDynamics/joints/floating/floatingJoint.C
@@ -0,0 +1,108 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+\*---------------------------------------------------------------------------*/
+
+#include "floatingJoint.H"
+#include "rigidBodyModel.H"
+#include "addToRunTimeSelectionTable.H"
+
+#include "Rs.H"
+#include "Rzyx.H"
+#include "Pxyz.H"
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace RBD
+{
+namespace joints
+{
+ defineTypeNameAndDebug(floating, 0);
+
+ addToRunTimeSelectionTable
+ (
+ joint,
+ floating,
+ dictionary
+ );
+}
+}
+}
+
+
+// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
+
+Foam::autoPtr
+Foam::RBD::joints::floating::sixDoF()
+{
+ PtrList cj(2);
+ cj.set(0, new joints::Pxyz());
+
+ // The quaternion-based spherical joint could be used
+ // but then w must be set appropriately
+ //cj.set(1, new joints::Rs());
+
+ // Alternatively the Euler-angle joint can be used
+ cj.set(1, new joints::Rzyx());
+
+ return autoPtr(new composite(cj));
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::RBD::joints::floating::floating()
+:
+ composite(sixDoF())
+{}
+
+
+Foam::RBD::joints::floating::floating(const dictionary& dict)
+:
+ composite(sixDoF())
+{}
+
+
+Foam::autoPtr Foam::RBD::joints::floating::clone() const
+{
+ return autoPtr(new floating(*this));
+}
+
+
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+Foam::RBD::joints::floating::~floating()
+{}
+
+
+// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+
+void Foam::RBD::joints::floating::write(Ostream& os) const
+{
+ joint::write(os);
+}
+
+
+// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/floating/floatingJoint.H b/src/rigidBodyDynamics/joints/floating/floatingJoint.H
new file mode 100644
index 0000000000..58c314d784
--- /dev/null
+++ b/src/rigidBodyDynamics/joints/floating/floatingJoint.H
@@ -0,0 +1,110 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / 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 .
+
+Class
+ Foam::RBD::joints::floating
+
+Description
+ Prismatic joint for translation along the specified arbitrary axis.
+
+ Reference:
+ \verbatim
+ Featherstone, R. (2008).
+ Rigid body dynamics algorithms.
+ Springer.
+ Chapter 4.
+ \endverbatim
+
+SourceFiles
+ floating.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef RBD_joints_floating_H
+#define RBD_joints_floating_H
+
+#include "compositeJoint.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+namespace RBD
+{
+namespace joints
+{
+
+/*---------------------------------------------------------------------------*\
+ Class floating Declaration
+\*---------------------------------------------------------------------------*/
+
+class floating
+:
+ public composite
+{
+ // Private member functions
+
+ //- Return a list of joints needed to emulate a floating body
+ static autoPtr sixDoF();
+
+
+public:
+
+ //- Runtime type information
+ TypeName("floating");
+
+
+ // Constructors
+
+ //- Construct
+ floating();
+
+ //- Construct for given model from dictionary
+ floating(const dictionary& dict);
+
+ //- Clone this joint
+ virtual autoPtr clone() const;
+
+
+ //- Destructor
+ virtual ~floating();
+
+
+ // Member Functions
+
+ //- Write
+ virtual void write(Ostream&) const;
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace joints
+} // End namespace RBD
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/joint/joint.C b/src/rigidBodyDynamics/joints/joint/joint.C
index 4374990eb5..f13ee347ea 100644
--- a/src/rigidBodyDynamics/joints/joint/joint.C
+++ b/src/rigidBodyDynamics/joints/joint/joint.C
@@ -25,9 +25,6 @@ License
#include "joint.H"
#include "rigidBodyModel.H"
-#include "Rs.H"
-#include "Rzyx.H"
-#include "Pxyz.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -81,18 +78,10 @@ Foam::RBD::joint::~joint()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
-Foam::PtrList Foam::RBD::joint::floating()
+void Foam::RBD::joint::write(Ostream& os) const
{
- PtrList cj(2);
- cj.set(0, new joints::Pxyz());
- //cj.set(1, new joints::Rs());
- cj.set(1, new joints::Rzyx());
- return cj;
+ os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
}
-void Foam::RBD::joint::write(Ostream& os) const
-{}
-
-
// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/joint/joint.H b/src/rigidBodyDynamics/joints/joint/joint.H
index 58d68190de..64258a3f71 100644
--- a/src/rigidBodyDynamics/joints/joint/joint.H
+++ b/src/rigidBodyDynamics/joints/joint/joint.H
@@ -61,6 +61,12 @@ namespace RBD
// Forward declaration of classes
class rigidBodyModel;
+// Forward declaration of friend functions and operators
+class joint;
+
+inline Ostream& operator<<(Ostream&, const joint&);
+
+
/*---------------------------------------------------------------------------*\
Class joint Declaration
\*---------------------------------------------------------------------------*/
@@ -171,6 +177,17 @@ public:
//- Clone this joint (needed by PtrList)
virtual autoPtr clone() const = 0;
+ class iNew
+ {
+
+ public:
+
+ iNew()
+ {}
+
+ inline autoPtr operator()(Istream& is) const;
+ };
+
//- Destructor
virtual ~joint();
@@ -207,9 +224,6 @@ public:
//- Return the joint motion sub-space
inline const List& S() const;
- //- Return a list of joints needed to emulate a floating body
- static PtrList floating();
-
//- Update the rigidBodyModel state for the joint given
// the joint state q, w and velocity qDot
virtual void jcalc
@@ -242,6 +256,11 @@ public:
scalarField& q,
scalarField& w
) const;
+
+
+ // Ostream Operator
+
+ friend Ostream& operator<<(Ostream&, const joint&);
};
diff --git a/src/rigidBodyDynamics/joints/joint/jointI.H b/src/rigidBodyDynamics/joints/joint/jointI.H
index 47db466a7d..0b33fb9322 100644
--- a/src/rigidBodyDynamics/joints/joint/jointI.H
+++ b/src/rigidBodyDynamics/joints/joint/jointI.H
@@ -107,4 +107,26 @@ inline void Foam::RBD::joint::operator()
}
+Foam::autoPtr Foam::RBD::joint::iNew::operator()
+(
+ Istream& is
+) const
+{
+ dictionary dict(is);
+ return New(dict);
+}
+
+
+// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
+
+inline Foam::Ostream& Foam::RBD::operator<<(Ostream& os, const joint& j)
+{
+ os << indent << token::BEGIN_BLOCK << incrIndent << endl;
+ j.write(os);
+ os << decrIndent << indent << token::END_BLOCK;
+
+ return os;
+}
+
+
// ************************************************************************* //
diff --git a/src/rigidBodyDynamics/joints/joints.H b/src/rigidBodyDynamics/joints/joints.H
index 2ddd6c905c..b95829646b 100644
--- a/src/rigidBodyDynamics/joints/joints.H
+++ b/src/rigidBodyDynamics/joints/joints.H
@@ -1,6 +1,12 @@
// Null joint for the root-body
#include "nullJoint.H"
+// Composite joint to handle combination of rotations and translations
+#include "compositeJoint.H"
+
+// 6-DoF joint for floating bodies
+#include "floatingJoint.H"
+
// Revolute joints
#include "Rx.H"
#include "Ry.H"
diff --git a/src/rigidBodyDynamics/joints/nullJoint/nullJoint.C b/src/rigidBodyDynamics/joints/null/nullJoint.C
similarity index 100%
rename from src/rigidBodyDynamics/joints/nullJoint/nullJoint.C
rename to src/rigidBodyDynamics/joints/null/nullJoint.C
diff --git a/src/rigidBodyDynamics/joints/nullJoint/nullJoint.H b/src/rigidBodyDynamics/joints/null/nullJoint.H
similarity index 100%
rename from src/rigidBodyDynamics/joints/nullJoint/nullJoint.H
rename to src/rigidBodyDynamics/joints/null/nullJoint.H
diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
index af3d70b19a..6d93c8f5b6 100644
--- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
+++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C
@@ -124,12 +124,12 @@ Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict)
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
-Foam::label Foam::RBD::rigidBodyModel::join
+Foam::label Foam::RBD::rigidBodyModel::join_
(
const label parentID,
const spatialTransform& XT,
- const autoPtr& jointPtr,
- const autoPtr& bodyPtr
+ autoPtr jointPtr,
+ autoPtr bodyPtr
)
{
// Append the body
@@ -174,33 +174,71 @@ Foam::label Foam::RBD::rigidBodyModel::join
(
const label parentID,
const spatialTransform& XT,
- const PtrList& compositeJoint,
- const autoPtr& bodyPtr
+ autoPtr jointPtr,
+ autoPtr bodyPtr
+)
+{
+ if (isA(jointPtr()))
+ {
+ return join
+ (
+ parentID,
+ XT,
+ autoPtr
+ (
+ dynamic_cast(jointPtr.ptr())
+ ),
+ bodyPtr
+ );
+ }
+ else
+ {
+ return join_
+ (
+ parentID,
+ XT,
+ jointPtr,
+ bodyPtr
+ );
+ }
+}
+
+
+Foam::label Foam::RBD::rigidBodyModel::join
+(
+ const label parentID,
+ const spatialTransform& XT,
+ autoPtr cJointPtr,
+ autoPtr bodyPtr
)
{
label parent = parentID;
+ joints::composite& cJoint = cJointPtr();
// For all but the final joint in the set add a masslessBody with the
// joint and transform
- for (label j=0; j(new masslessBody)
);
}
// For the final joint in the set add the read body
- return join
+ parent = join_
(
parent,
- compositeJoint.size() == 1 ? XT : spatialTransform(),
- compositeJoint[compositeJoint.size()-1].clone(),
+ cJoint.size() == 1 ? XT : spatialTransform(),
+ autoPtr(cJointPtr.ptr()),
bodyPtr
);
+ cJoint.setLastJoint();
+
+ return parent;
}
@@ -225,7 +263,7 @@ Foam::label Foam::RBD::rigidBodyModel::merge
(
const label parentID,
const spatialTransform& XT,
- const autoPtr& bodyPtr
+ autoPtr bodyPtr
)
{
autoPtr sBodyPtr;
@@ -317,15 +355,7 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const
os.writeKeyword("transform")
<< XT_[i] << token::END_STATEMENT << nl;
- os << indent << "joint" << nl
- << indent << token::BEGIN_BLOCK << incrIndent << endl;
-
- os.writeKeyword("type")
- << joints_[i].type() << token::END_STATEMENT << nl;
-
- joints_[i].write(os);
-
- os << decrIndent << indent << token::END_BLOCK << endl;
+ os << indent << "joint" << nl << joints_[i] << endl;
os << decrIndent << indent << token::END_BLOCK << endl;
}
diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H
index 9c51cd280b..57271d3ff2 100644
--- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H
+++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H
@@ -52,6 +52,7 @@ SourceFiles
#include "rigidBody.H"
#include "subBody.H"
#include "joint.H"
+#include "compositeJoint.H"
#include "PtrList.H"
#include "HashTable.H"
@@ -177,6 +178,19 @@ protected:
mutable DynamicList u_;
+ // Protected member functions
+
+ //- Join the given body to the parent with ID parentID via the given
+ // joint with transform from the parent frame to the joint frame XT.
+ virtual label join_
+ (
+ const label parentID,
+ const spatialTransform& XT,
+ autoPtr jointPtr,
+ autoPtr bodyPtr
+ );
+
+
public:
//- Runtime type information
@@ -237,8 +251,8 @@ public:
(
const label parentID,
const spatialTransform& XT,
- const autoPtr& jointPtr,
- const autoPtr& bodyPtr
+ autoPtr jointPtr,
+ autoPtr bodyPtr
);
//- Join the given body to the parent with ID parentID via the given
@@ -250,8 +264,8 @@ public:
(
const label parentID,
const spatialTransform& XT,
- const PtrList& compositeJoint,
- const autoPtr& bodyPtr
+ autoPtr cJoint,
+ autoPtr bodyPtr
);
//- Merge the given body with transform X into the parent with ID
@@ -262,7 +276,7 @@ public:
(
const label parentID,
const spatialTransform& X,
- const autoPtr& bodyPtr
+ autoPtr bodyPtr
);
//- Return true if the body with given ID has been merged with a parent