mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
rigidBodyDynamics: Added dictionary-based IO of the rigidBodyModel, bodies and joints
Added support for composite joints including a specialized 6-DoF form for floating bodies.
This commit is contained in:
@ -5,7 +5,9 @@ bodies/subBody/subBody.C
|
|||||||
bodies/sphere/sphere.C
|
bodies/sphere/sphere.C
|
||||||
|
|
||||||
joints/joint/joint.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/Rx/Rx.C
|
||||||
joints/Ry/Ry.C
|
joints/Ry/Ry.C
|
||||||
|
|||||||
@ -54,7 +54,7 @@ Foam::RBD::joints::Pa::Pa(const vector& axis)
|
|||||||
:
|
:
|
||||||
joint(1)
|
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)
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -95,6 +95,9 @@ public:
|
|||||||
const scalarField& w,
|
const scalarField& w,
|
||||||
const scalarField& qDot
|
const scalarField& qDot
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ Foam::RBD::joints::Ra::Ra(const vector& axis)
|
|||||||
:
|
:
|
||||||
joint(1)
|
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)
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -95,6 +95,9 @@ public:
|
|||||||
const scalarField& w,
|
const scalarField& w,
|
||||||
const scalarField& qDot
|
const scalarField& qDot
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
115
src/rigidBodyDynamics/joints/composite/compositeJoint.C
Normal file
115
src/rigidBodyDynamics/joints/composite/compositeJoint.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#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<joint>& joints)
|
||||||
|
:
|
||||||
|
PtrList<joint>(joints),
|
||||||
|
joint(last())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::RBD::joints::composite::composite(const dictionary& dict)
|
||||||
|
:
|
||||||
|
PtrList<joint>(dict.lookup("joints")),
|
||||||
|
joint(last())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joints::composite::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<joint>(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<const PtrList<joint>&>(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
131
src/rigidBodyDynamics/joints/composite/compositeJoint.H
Normal file
131
src/rigidBodyDynamics/joints/composite/compositeJoint.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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<joint>,
|
||||||
|
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<joint>
|
||||||
|
composite(const PtrList<joint>& joints);
|
||||||
|
|
||||||
|
//- Construct for given model from dictionary
|
||||||
|
composite(const dictionary& dict);
|
||||||
|
|
||||||
|
//- Clone this joint
|
||||||
|
virtual autoPtr<joint> 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
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
108
src/rigidBodyDynamics/joints/floating/floatingJoint.C
Normal file
108
src/rigidBodyDynamics/joints/floating/floatingJoint.C
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#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::composite>
|
||||||
|
Foam::RBD::joints::floating::sixDoF()
|
||||||
|
{
|
||||||
|
PtrList<joint> 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<composite>(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::joint> Foam::RBD::joints::floating::clone() const
|
||||||
|
{
|
||||||
|
return autoPtr<joint>(new floating(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::RBD::joints::floating::~floating()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::RBD::joints::floating::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
joint::write(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
110
src/rigidBodyDynamics/joints/floating/floatingJoint.H
Normal file
110
src/rigidBodyDynamics/joints/floating/floatingJoint.H
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
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<composite> 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<joint> clone() const;
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~floating();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Write
|
||||||
|
virtual void write(Ostream&) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace joints
|
||||||
|
} // End namespace RBD
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -25,9 +25,6 @@ License
|
|||||||
|
|
||||||
#include "joint.H"
|
#include "joint.H"
|
||||||
#include "rigidBodyModel.H"
|
#include "rigidBodyModel.H"
|
||||||
#include "Rs.H"
|
|
||||||
#include "Rzyx.H"
|
|
||||||
#include "Pxyz.H"
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -81,18 +78,10 @@ Foam::RBD::joint::~joint()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::PtrList<Foam::RBD::joint> Foam::RBD::joint::floating()
|
void Foam::RBD::joint::write(Ostream& os) const
|
||||||
{
|
{
|
||||||
PtrList<joint> cj(2);
|
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
|
||||||
cj.set(0, new joints::Pxyz());
|
|
||||||
//cj.set(1, new joints::Rs());
|
|
||||||
cj.set(1, new joints::Rzyx());
|
|
||||||
return cj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::RBD::joint::write(Ostream& os) const
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -61,6 +61,12 @@ namespace RBD
|
|||||||
// Forward declaration of classes
|
// Forward declaration of classes
|
||||||
class rigidBodyModel;
|
class rigidBodyModel;
|
||||||
|
|
||||||
|
// Forward declaration of friend functions and operators
|
||||||
|
class joint;
|
||||||
|
|
||||||
|
inline Ostream& operator<<(Ostream&, const joint&);
|
||||||
|
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class joint Declaration
|
Class joint Declaration
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -171,6 +177,17 @@ public:
|
|||||||
//- Clone this joint (needed by PtrList)
|
//- Clone this joint (needed by PtrList)
|
||||||
virtual autoPtr<joint> clone() const = 0;
|
virtual autoPtr<joint> clone() const = 0;
|
||||||
|
|
||||||
|
class iNew
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
iNew()
|
||||||
|
{}
|
||||||
|
|
||||||
|
inline autoPtr<joint> operator()(Istream& is) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~joint();
|
virtual ~joint();
|
||||||
@ -207,9 +224,6 @@ public:
|
|||||||
//- Return the joint motion sub-space
|
//- Return the joint motion sub-space
|
||||||
inline const List<spatialVector>& S() const;
|
inline const List<spatialVector>& S() const;
|
||||||
|
|
||||||
//- Return a list of joints needed to emulate a floating body
|
|
||||||
static PtrList<joint> floating();
|
|
||||||
|
|
||||||
//- Update the rigidBodyModel state for the joint given
|
//- Update the rigidBodyModel state for the joint given
|
||||||
// the joint state q, w and velocity qDot
|
// the joint state q, w and velocity qDot
|
||||||
virtual void jcalc
|
virtual void jcalc
|
||||||
@ -242,6 +256,11 @@ public:
|
|||||||
scalarField& q,
|
scalarField& q,
|
||||||
scalarField& w
|
scalarField& w
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Ostream Operator
|
||||||
|
|
||||||
|
friend Ostream& operator<<(Ostream&, const joint&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -107,4 +107,26 @@ inline void Foam::RBD::joint::operator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::RBD::joint> 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -1,6 +1,12 @@
|
|||||||
// Null joint for the root-body
|
// Null joint for the root-body
|
||||||
#include "nullJoint.H"
|
#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
|
// Revolute joints
|
||||||
#include "Rx.H"
|
#include "Rx.H"
|
||||||
#include "Ry.H"
|
#include "Ry.H"
|
||||||
|
|||||||
@ -124,12 +124,12 @@ Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::label Foam::RBD::rigidBodyModel::join
|
Foam::label Foam::RBD::rigidBodyModel::join_
|
||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& XT,
|
const spatialTransform& XT,
|
||||||
const autoPtr<joint>& jointPtr,
|
autoPtr<joint> jointPtr,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// Append the body
|
// Append the body
|
||||||
@ -174,33 +174,71 @@ Foam::label Foam::RBD::rigidBodyModel::join
|
|||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& XT,
|
const spatialTransform& XT,
|
||||||
const PtrList<joint>& compositeJoint,
|
autoPtr<joint> jointPtr,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (isA<joints::composite>(jointPtr()))
|
||||||
|
{
|
||||||
|
return join
|
||||||
|
(
|
||||||
|
parentID,
|
||||||
|
XT,
|
||||||
|
autoPtr<joints::composite>
|
||||||
|
(
|
||||||
|
dynamic_cast<joints::composite*>(jointPtr.ptr())
|
||||||
|
),
|
||||||
|
bodyPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return join_
|
||||||
|
(
|
||||||
|
parentID,
|
||||||
|
XT,
|
||||||
|
jointPtr,
|
||||||
|
bodyPtr
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::RBD::rigidBodyModel::join
|
||||||
|
(
|
||||||
|
const label parentID,
|
||||||
|
const spatialTransform& XT,
|
||||||
|
autoPtr<joints::composite> cJointPtr,
|
||||||
|
autoPtr<rigidBody> bodyPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
label parent = parentID;
|
label parent = parentID;
|
||||||
|
joints::composite& cJoint = cJointPtr();
|
||||||
|
|
||||||
// For all but the final joint in the set add a masslessBody with the
|
// For all but the final joint in the set add a masslessBody with the
|
||||||
// joint and transform
|
// joint and transform
|
||||||
for (label j=0; j<compositeJoint.size()-1; j++)
|
for (label j=0; j<cJoint.size()-1; j++)
|
||||||
{
|
{
|
||||||
parent = join
|
parent = join_
|
||||||
(
|
(
|
||||||
parent,
|
parent,
|
||||||
j == 0 ? XT : spatialTransform(),
|
j == 0 ? XT : spatialTransform(),
|
||||||
compositeJoint[j].clone(),
|
cJoint[j].clone(),
|
||||||
autoPtr<rigidBody>(new masslessBody)
|
autoPtr<rigidBody>(new masslessBody)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the final joint in the set add the read body
|
// For the final joint in the set add the read body
|
||||||
return join
|
parent = join_
|
||||||
(
|
(
|
||||||
parent,
|
parent,
|
||||||
compositeJoint.size() == 1 ? XT : spatialTransform(),
|
cJoint.size() == 1 ? XT : spatialTransform(),
|
||||||
compositeJoint[compositeJoint.size()-1].clone(),
|
autoPtr<joint>(cJointPtr.ptr()),
|
||||||
bodyPtr
|
bodyPtr
|
||||||
);
|
);
|
||||||
|
cJoint.setLastJoint();
|
||||||
|
|
||||||
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,7 +263,7 @@ Foam::label Foam::RBD::rigidBodyModel::merge
|
|||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& XT,
|
const spatialTransform& XT,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
autoPtr<subBody> sBodyPtr;
|
autoPtr<subBody> sBodyPtr;
|
||||||
@ -317,15 +355,7 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const
|
|||||||
os.writeKeyword("transform")
|
os.writeKeyword("transform")
|
||||||
<< XT_[i] << token::END_STATEMENT << nl;
|
<< XT_[i] << token::END_STATEMENT << nl;
|
||||||
|
|
||||||
os << indent << "joint" << nl
|
os << indent << "joint" << nl << joints_[i] << endl;
|
||||||
<< 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 << decrIndent << indent << token::END_BLOCK << endl;
|
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,7 @@ SourceFiles
|
|||||||
#include "rigidBody.H"
|
#include "rigidBody.H"
|
||||||
#include "subBody.H"
|
#include "subBody.H"
|
||||||
#include "joint.H"
|
#include "joint.H"
|
||||||
|
#include "compositeJoint.H"
|
||||||
#include "PtrList.H"
|
#include "PtrList.H"
|
||||||
#include "HashTable.H"
|
#include "HashTable.H"
|
||||||
|
|
||||||
@ -177,6 +178,19 @@ protected:
|
|||||||
mutable DynamicList<vector> u_;
|
mutable DynamicList<vector> 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<joint> jointPtr,
|
||||||
|
autoPtr<rigidBody> bodyPtr
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -237,8 +251,8 @@ public:
|
|||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& XT,
|
const spatialTransform& XT,
|
||||||
const autoPtr<joint>& jointPtr,
|
autoPtr<joint> jointPtr,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Join the given body to the parent with ID parentID via the given
|
//- Join the given body to the parent with ID parentID via the given
|
||||||
@ -250,8 +264,8 @@ public:
|
|||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& XT,
|
const spatialTransform& XT,
|
||||||
const PtrList<joint>& compositeJoint,
|
autoPtr<joints::composite> cJoint,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Merge the given body with transform X into the parent with ID
|
//- Merge the given body with transform X into the parent with ID
|
||||||
@ -262,7 +276,7 @@ public:
|
|||||||
(
|
(
|
||||||
const label parentID,
|
const label parentID,
|
||||||
const spatialTransform& X,
|
const spatialTransform& X,
|
||||||
const autoPtr<rigidBody>& bodyPtr
|
autoPtr<rigidBody> bodyPtr
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return true if the body with given ID has been merged with a parent
|
//- Return true if the body with given ID has been merged with a parent
|
||||||
|
|||||||
Reference in New Issue
Block a user