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
This commit is contained in:
38
applications/test/rigidBodyDynamics/pendulum/pendulum
Normal file
38
applications/test/rigidBodyDynamics/pendulum/pendulum
Normal file
@ -0,0 +1,38 @@
|
||||
bodies0
|
||||
{
|
||||
pendulum
|
||||
{
|
||||
type rigidBody;
|
||||
parent root;
|
||||
mass 1;
|
||||
centreOfMass (0 -1 0);
|
||||
inertia (0.001 0 0 0.001 0 0.001);
|
||||
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;
|
||||
mergeWith hinge;
|
||||
mass 1;
|
||||
radius 0.05;
|
||||
transform (1 0 0 0 1 0 0 0 1) (0 -1 0);
|
||||
}
|
||||
}
|
||||
@ -34,6 +34,7 @@ Description
|
||||
#include "masslessBody.H"
|
||||
#include "sphere.H"
|
||||
#include "joints.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
using namespace RBD;
|
||||
@ -42,7 +43,8 @@ using namespace RBD;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool testMerge = false;
|
||||
/*
|
||||
bool testMerge = true;
|
||||
|
||||
// Create a model for the pendulum
|
||||
rigidBodyModel pendulum;
|
||||
@ -55,7 +57,7 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
pendulum.bodyID("root"),
|
||||
Xt(Zero),
|
||||
joint::New(new joints::Rz(pendulum)),
|
||||
joint::New(new joints::Rz()),
|
||||
autoPtr<rigidBody>(new masslessBody("hinge"))
|
||||
);
|
||||
|
||||
@ -72,10 +74,16 @@ int main(int argc, char *argv[])
|
||||
(
|
||||
pendulum.bodyID("root"),
|
||||
Xt(Zero),
|
||||
joint::New(new joints::Rz(pendulum)),
|
||||
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")()));
|
||||
|
||||
pendulum.write(Info);
|
||||
|
||||
// Create the joint-space state fields
|
||||
scalarField q(pendulum.nDoF(), Zero);
|
||||
@ -110,7 +118,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
qdot += 0.5*deltaT*qddot;
|
||||
|
||||
Info<< "Time << " << t << "s, angle = " << q[0] << "rad" << endl;
|
||||
Info<< "Time " << t << "s, angle = " << q[0] << "rad" << endl;
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
@ -217,7 +217,7 @@ inline Foam::Ostream& Foam::operator<<
|
||||
const spatialTransform& X
|
||||
)
|
||||
{
|
||||
os << X.E() << token::SPACE << X.r() << endl;
|
||||
os << X.E() << token::SPACE << X.r();
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
bodies/rigidBody/rigidBody.C
|
||||
bodies/masslessBody/masslessBody.C
|
||||
bodies/compositeBody/compositeBody.C
|
||||
bodies/subBody/subBody.C
|
||||
bodies/sphere/sphere.C
|
||||
|
||||
|
||||
48
src/rigidBodyDynamics/bodies/compositeBody/compositeBody.C
Normal file
48
src/rigidBodyDynamics/bodies/compositeBody/compositeBody.C
Normal file
@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 "compositeBody.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::compositeBody::~compositeBody()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word& Foam::RBD::compositeBody::type() const
|
||||
{
|
||||
return body_->type();
|
||||
}
|
||||
|
||||
|
||||
void Foam::RBD::compositeBody::write(Ostream& os) const
|
||||
{
|
||||
body_->write(os);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
103
src/rigidBodyDynamics/bodies/compositeBody/compositeBody.H
Normal file
103
src/rigidBodyDynamics/bodies/compositeBody/compositeBody.H
Normal file
@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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::compositeBody
|
||||
|
||||
Description
|
||||
This specialized rigidBody holds the original body after it has been merged
|
||||
into a parent.
|
||||
|
||||
SourceFiles
|
||||
compositeBodyI.H
|
||||
compositeBody.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef RBD_compositeBody_H
|
||||
#define RBD_compositeBody_H
|
||||
|
||||
#include "rigidBody.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace RBD
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class compositeBody Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class compositeBody
|
||||
:
|
||||
public rigidBody
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Original body from which this composite-body was constructed
|
||||
autoPtr<rigidBody> body_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct a merged version of the given rigidBody
|
||||
// providing the ID of the parent body to which this will be merged
|
||||
// and the transform relative to the parent
|
||||
inline compositeBody(const autoPtr<rigidBody>& bodyPtr);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~compositeBody();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the type name of the original body
|
||||
virtual const word& type() const;
|
||||
|
||||
//- Return the original body from which this composite-body
|
||||
// was constructed
|
||||
inline const rigidBody& body() const;
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace RBD
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "compositeBodyI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
46
src/rigidBodyDynamics/bodies/compositeBody/compositeBodyI.H
Normal file
46
src/rigidBodyDynamics/bodies/compositeBody/compositeBodyI.H
Normal file
@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::RBD::compositeBody::compositeBody
|
||||
(
|
||||
const autoPtr<rigidBody>& bodyPtr
|
||||
)
|
||||
:
|
||||
rigidBody(bodyPtr()),
|
||||
body_(bodyPtr)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline const Foam::RBD::rigidBody& Foam::RBD::compositeBody::body() const
|
||||
{
|
||||
return body_();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -24,6 +24,25 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "masslessBody.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace RBD
|
||||
{
|
||||
defineTypeNameAndDebug(masslessBody, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
rigidBody,
|
||||
masslessBody,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -55,6 +55,10 @@ class masslessBody
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("masslessBody");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct a massless body
|
||||
@ -63,6 +67,13 @@ public:
|
||||
//- Construct a named massless body
|
||||
inline masslessBody(const word& name);
|
||||
|
||||
//- Construct from dictionary
|
||||
inline masslessBody
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~masslessBody();
|
||||
|
||||
@ -37,4 +37,15 @@ inline Foam::RBD::masslessBody::masslessBody(const word& name)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::RBD::masslessBody::masslessBody
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
rigidBody(name, rigidBodyInertia())
|
||||
{}
|
||||
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -25,6 +25,26 @@ License
|
||||
|
||||
#include "rigidBody.H"
|
||||
#include "subBody.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace RBD
|
||||
{
|
||||
defineTypeNameAndDebug(rigidBody, 0);
|
||||
defineRunTimeSelectionTable(rigidBody, dictionary);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
rigidBody,
|
||||
rigidBody,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -40,6 +60,31 @@ Foam::autoPtr<Foam::RBD::rigidBody> Foam::RBD::rigidBody::New
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::RBD::rigidBody> Foam::RBD::rigidBody::New
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const word bodyType(dict.lookup("type"));
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(bodyType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown rigidBody type "
|
||||
<< bodyType << nl << nl
|
||||
<< "Valid rigidBody types are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<rigidBody>(cstrIter()(name, dict));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::rigidBody::~rigidBody()
|
||||
@ -72,7 +117,7 @@ void Foam::RBD::rigidBody::write(Ostream& os) const
|
||||
os.writeKeyword("centreOfMass")
|
||||
<< c() << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("Inertia")
|
||||
os.writeKeyword("inertia")
|
||||
<< Ic() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,8 @@ SourceFiles
|
||||
#define RBD_rigidBody_H
|
||||
|
||||
#include "rigidBodyInertia.H"
|
||||
#include "dictionary.H"
|
||||
#include "runTimeSelectionTables.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -62,6 +64,22 @@ class rigidBody
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("rigidBody");
|
||||
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
|
||||
declareRunTimeSelectionTable
|
||||
(
|
||||
autoPtr,
|
||||
rigidBody,
|
||||
dictionary,
|
||||
(const word& name, const dictionary& dict),
|
||||
(name, dict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from mass, centre of mass and moment of inertia tensor
|
||||
@ -81,6 +99,13 @@ public:
|
||||
const rigidBodyInertia& rbi
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
inline rigidBody
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Return clone of this rigidBody
|
||||
inline autoPtr<rigidBody> clone() const;
|
||||
|
||||
@ -96,6 +121,13 @@ public:
|
||||
const symmTensor& Ic
|
||||
);
|
||||
|
||||
//- Select constructed from name and dictionary
|
||||
static autoPtr<rigidBody> New
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~rigidBody();
|
||||
|
||||
@ -43,12 +43,23 @@ inline Foam::RBD::rigidBody::rigidBody
|
||||
const word& name,
|
||||
const rigidBodyInertia& rbi
|
||||
)
|
||||
:
|
||||
:
|
||||
rigidBodyInertia(rbi),
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::RBD::rigidBody::rigidBody
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
rigidBodyInertia(dict),
|
||||
name_(name)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::autoPtr<Foam::RBD::rigidBody> Foam::RBD::rigidBody::clone() const
|
||||
{
|
||||
return autoPtr<rigidBody>(new rigidBody(*this));
|
||||
|
||||
@ -24,6 +24,25 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "sphere.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace RBD
|
||||
{
|
||||
defineTypeNameAndDebug(sphere, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
rigidBody,
|
||||
sphere,
|
||||
dictionary
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -61,11 +61,22 @@ class sphere
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("sphere");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from name, mass and radius
|
||||
inline sphere(const word& name, const scalar m, const scalar r);
|
||||
|
||||
//- Construct from dictionary
|
||||
inline sphere
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~sphere();
|
||||
|
||||
@ -37,6 +37,27 @@ inline Foam::RBD::sphere::sphere
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::RBD::sphere::sphere
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
rigidBody
|
||||
(
|
||||
name,
|
||||
rigidBodyInertia()
|
||||
),
|
||||
r_(readScalar(dict.lookup("radius")))
|
||||
{
|
||||
const scalar m(readScalar(dict.lookup("mass")));
|
||||
rigidBodyInertia::operator=
|
||||
(
|
||||
rigidBodyInertia(m, Zero, (2.0/5.0)*m*sqr(r_)*I)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::scalar Foam::RBD::sphere::r() const
|
||||
|
||||
@ -35,7 +35,7 @@ Foam::RBD::subBody::~subBody()
|
||||
|
||||
void Foam::RBD::subBody::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("parentBody")
|
||||
os.writeKeyword("parent")
|
||||
<< parentName_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("transform")
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
// and the transform relative to the parent
|
||||
inline subBody
|
||||
(
|
||||
autoPtr<rigidBody> bodyPtr,
|
||||
const autoPtr<rigidBody>& bodyPtr,
|
||||
const word& parentName,
|
||||
const label parentID,
|
||||
const spatialTransform& parentXT
|
||||
|
||||
@ -27,7 +27,7 @@ License
|
||||
|
||||
inline Foam::RBD::subBody::subBody
|
||||
(
|
||||
autoPtr<rigidBody> bodyPtr,
|
||||
const autoPtr<rigidBody>& bodyPtr,
|
||||
const word& parentName,
|
||||
const label parentID,
|
||||
const spatialTransform& parentXT
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const vector& axis)
|
||||
Foam::RBD::joints::Pa::Pa(const vector& axis)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(Zero, axis);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Pa::Pa(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(Zero, dict.lookup("axis"));
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model and axis
|
||||
Pa(const rigidBodyModel& model, const vector& axis);
|
||||
Pa(const vector& axis);
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Pa(const rigidBodyModel&, const dictionary& dict);
|
||||
Pa(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Px::Px(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Px::Px()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Px::Px(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Px::Px(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Px(const rigidBodyModel& model);
|
||||
Px();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Px(const rigidBodyModel&, const dictionary& dict);
|
||||
Px(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,9 +50,9 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Pxyz::Pxyz(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Pxyz::Pxyz()
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
|
||||
S_[1] = spatialVector(0, 0, 0, 0, 1, 0);
|
||||
@ -60,13 +60,9 @@ Foam::RBD::joints::Pxyz::Pxyz(const rigidBodyModel& model)
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Pxyz::Pxyz
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::RBD::joints::Pxyz::Pxyz(const dictionary& dict)
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
|
||||
S_[1] = spatialVector(0, 0, 0, 0, 1, 0);
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Pxyz(const rigidBodyModel& model);
|
||||
Pxyz();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Pxyz(const rigidBodyModel&, const dictionary& dict);
|
||||
Pxyz(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Py::Py(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Py::Py()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 0, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Py::Py(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Py::Py(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 0, 1, 0);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Py(const rigidBodyModel& model);
|
||||
Py();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Py(const rigidBodyModel&, const dictionary& dict);
|
||||
Py(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Pz::Pz()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Pz::Pz(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Pz(const rigidBodyModel& model);
|
||||
Pz();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Pz(const rigidBodyModel&, const dictionary& dict);
|
||||
Pz(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const vector& axis)
|
||||
Foam::RBD::joints::Ra::Ra(const vector& axis)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(axis, Zero);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Ra::Ra(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(dict.lookup("axis"), Zero);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model and axis
|
||||
Ra(const rigidBodyModel& model, const vector& axis);
|
||||
Ra(const vector& axis);
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Ra(const rigidBodyModel&, const dictionary& dict);
|
||||
Ra(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,9 +50,9 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Rs::Rs()
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector (0, 1, 0, 0, 0, 0);
|
||||
@ -60,9 +60,9 @@ Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model)
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Rs::Rs(const dictionary& dict)
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector (0, 1, 0, 0, 0, 0);
|
||||
|
||||
@ -73,10 +73,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Rs(const rigidBodyModel& model);
|
||||
Rs();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Rs(const rigidBodyModel&, const dictionary& dict);
|
||||
Rs(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Rx::Rx()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Rx::Rx(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Rx(const rigidBodyModel& model);
|
||||
Rx();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Rx(const rigidBodyModel&, const dictionary& dict);
|
||||
Rx(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,9 +50,9 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Rxyz::Rxyz(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Rxyz::Rxyz()
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
@ -60,13 +60,9 @@ Foam::RBD::joints::Rxyz::Rxyz(const rigidBodyModel& model)
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Rxyz::Rxyz
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::RBD::joints::Rxyz::Rxyz(const dictionary& dict)
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
|
||||
@ -73,10 +73,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Rxyz(const rigidBodyModel& model);
|
||||
Rxyz();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Rxyz(const rigidBodyModel&, const dictionary& dict);
|
||||
Rxyz(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Ry::Ry()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Ry::Ry(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Ry(const rigidBodyModel& model);
|
||||
Ry();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Ry(const rigidBodyModel&, const dictionary& dict);
|
||||
Ry(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,9 +50,9 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Ryxz::Ryxz(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Ryxz::Ryxz()
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
@ -60,13 +60,9 @@ Foam::RBD::joints::Ryxz::Ryxz(const rigidBodyModel& model)
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Ryxz::Ryxz
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::RBD::joints::Ryxz::Ryxz(const dictionary& dict)
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
S_[1] = spatialVector(1, 0, 0, 0, 0, 0);
|
||||
|
||||
@ -73,10 +73,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Ryxz(const rigidBodyModel& model);
|
||||
Ryxz();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Ryxz(const rigidBodyModel&, const dictionary& dict);
|
||||
Ryxz(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,17 +50,17 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Rz::Rz()
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model, const dictionary& dict)
|
||||
Foam::RBD::joints::Rz::Rz(const dictionary& dict)
|
||||
:
|
||||
joint(model, 1)
|
||||
joint(1)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Rz(const rigidBodyModel& model);
|
||||
Rz();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Rz(const rigidBodyModel&, const dictionary& dict);
|
||||
Rz(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -50,9 +50,9 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::Rzyx::Rzyx(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::Rzyx::Rzyx()
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
|
||||
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
@ -60,13 +60,9 @@ Foam::RBD::joints::Rzyx::Rzyx(const rigidBodyModel& model)
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::joints::Rzyx::Rzyx
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::RBD::joints::Rzyx::Rzyx(const dictionary& dict)
|
||||
:
|
||||
joint(model, 3)
|
||||
joint(3)
|
||||
{
|
||||
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
|
||||
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
|
||||
|
||||
@ -73,10 +73,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
Rzyx(const rigidBodyModel& model);
|
||||
Rzyx();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
Rzyx(const rigidBodyModel&, const dictionary& dict);
|
||||
Rzyx(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -49,6 +49,30 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::New(joint* jointPtr)
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::New
|
||||
(
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
const word bodyType(dict.lookup("type"));
|
||||
|
||||
dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(bodyType);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown joint type "
|
||||
<< bodyType << nl << nl
|
||||
<< "Valid joint types are : " << endl
|
||||
<< dictionaryConstructorTablePtr_->sortedToc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<joint>(cstrIter()(dict));
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joint::~joint()
|
||||
@ -57,15 +81,12 @@ Foam::RBD::joint::~joint()
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::PtrList<Foam::RBD::joint> Foam::RBD::joint::floating
|
||||
(
|
||||
const rigidBodyModel& model
|
||||
)
|
||||
Foam::PtrList<Foam::RBD::joint> Foam::RBD::joint::floating()
|
||||
{
|
||||
PtrList<joint> cj(2);
|
||||
cj.set(0, new joints::Pxyz(model));
|
||||
//cj.set(1, new joints::Rs(model));
|
||||
cj.set(1, new joints::Rzyx(model));
|
||||
cj.set(0, new joints::Pxyz());
|
||||
//cj.set(1, new joints::Rs());
|
||||
cj.set(1, new joints::Rzyx());
|
||||
return cj;
|
||||
}
|
||||
|
||||
|
||||
@ -157,20 +157,16 @@ public:
|
||||
autoPtr,
|
||||
joint,
|
||||
dictionary,
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
),
|
||||
(model, dict)
|
||||
(const dictionary& dict),
|
||||
(dict)
|
||||
);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct joint for given rigidBodyModel
|
||||
// setting the size of the motion sub-space
|
||||
//- Construct joint setting the size of the motion sub-space
|
||||
// to the given degrees of freedom of the joint
|
||||
inline joint(const rigidBodyModel&, const label nDoF);
|
||||
inline joint(const label nDoF);
|
||||
|
||||
//- Clone this joint (needed by PtrList)
|
||||
virtual autoPtr<joint> clone() const = 0;
|
||||
@ -185,12 +181,8 @@ public:
|
||||
//- Simple selector to return an autoPtr<joint> of the given joint*
|
||||
static autoPtr<joint> New(joint* jointPtr);
|
||||
|
||||
//- Select constructed from dictionary
|
||||
static autoPtr<joint> New
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
);
|
||||
//- Select from dictionary
|
||||
static autoPtr<joint> New(const dictionary& dict);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -216,7 +208,7 @@ public:
|
||||
inline const List<spatialVector>& S() const;
|
||||
|
||||
//- Return a list of joints needed to emulate a floating body
|
||||
static PtrList<joint> floating(const rigidBodyModel& model);
|
||||
static PtrList<joint> floating();
|
||||
|
||||
//- Update the rigidBodyModel state for the joint given
|
||||
// the joint state q, w and velocity qDot
|
||||
|
||||
@ -25,7 +25,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::RBD::joint::joint(const rigidBodyModel&, const label nDoF)
|
||||
inline Foam::RBD::joint::joint(const label nDoF)
|
||||
:
|
||||
S_(nDoF),
|
||||
index_(0),
|
||||
|
||||
@ -50,19 +50,15 @@ namespace joints
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::RBD::joints::null::null(const rigidBodyModel& model)
|
||||
Foam::RBD::joints::null::null()
|
||||
:
|
||||
joint(model, 0)
|
||||
joint(0)
|
||||
{}
|
||||
|
||||
|
||||
Foam::RBD::joints::null::null
|
||||
(
|
||||
const rigidBodyModel& model,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::RBD::joints::null::null(const dictionary& dict)
|
||||
:
|
||||
joint(model, 0)
|
||||
joint(0)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -72,10 +72,10 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for given model
|
||||
null(const rigidBodyModel& model);
|
||||
null();
|
||||
|
||||
//- Construct for given model from dictionary
|
||||
null(const rigidBodyModel&, const dictionary& dict);
|
||||
null(const dictionary& dict);
|
||||
|
||||
//- Clone this joint
|
||||
virtual autoPtr<joint> clone() const;
|
||||
|
||||
@ -111,6 +111,9 @@ public:
|
||||
const symmTensor& Ic
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
inline rigidBodyInertia(const dictionary& dict);
|
||||
|
||||
//- Construct from the components of a spatial tensor
|
||||
inline explicit rigidBodyInertia(const spatialTensor& st);
|
||||
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "spatialTransform.H"
|
||||
#include "transform.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -61,6 +62,14 @@ inline Foam::RBD::rigidBodyInertia::rigidBodyInertia
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::RBD::rigidBodyInertia::rigidBodyInertia(const dictionary& dict)
|
||||
:
|
||||
m_(readScalar(dict.lookup("mass"))),
|
||||
c_(dict.lookup("centreOfMass")),
|
||||
Ic_(dict.lookup("inertia"))
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::RBD::rigidBodyInertia::rigidBodyInertia(const spatialTensor& st)
|
||||
:
|
||||
m_(st(3, 3)),
|
||||
|
||||
@ -25,6 +25,7 @@ License
|
||||
|
||||
#include "rigidBodyModel.H"
|
||||
#include "masslessBody.H"
|
||||
#include "compositeBody.H"
|
||||
#include "nullJoint.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -42,10 +43,10 @@ namespace RBD
|
||||
|
||||
void Foam::RBD::rigidBodyModel::initializeRootBody()
|
||||
{
|
||||
bodies_.append(new masslessBody);
|
||||
bodies_.append(new masslessBody("root"));
|
||||
lambda_.append(0);
|
||||
bodyIDs_.insert("root", 0);
|
||||
joints_.append(new joints::null(*this));
|
||||
joints_.append(new joints::null());
|
||||
XT_.append(spatialTransform());
|
||||
|
||||
nDoF_ = 0;
|
||||
@ -86,6 +87,41 @@ Foam::RBD::rigidBodyModel::rigidBodyModel()
|
||||
}
|
||||
|
||||
|
||||
Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict)
|
||||
:
|
||||
g_(Zero)
|
||||
{
|
||||
initializeRootBody();
|
||||
|
||||
const dictionary& bodiesDict = dict.subDict("bodies");
|
||||
|
||||
forAllConstIter(IDLList<entry>, bodiesDict, iter)
|
||||
{
|
||||
const dictionary& bodyDict = iter().dict();
|
||||
|
||||
if (bodyDict.found("mergeWith"))
|
||||
{
|
||||
merge
|
||||
(
|
||||
bodyID(bodyDict.lookup("mergeWith")),
|
||||
bodyDict.lookup("transform"),
|
||||
rigidBody::New(iter().keyword(), bodyDict)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
join
|
||||
(
|
||||
bodyID(bodyDict.lookup("parent")),
|
||||
bodyDict.lookup("transform"),
|
||||
joint::New(bodyDict.subDict("joint")),
|
||||
rigidBody::New(iter().keyword(), bodyDict)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::RBD::rigidBodyModel::join
|
||||
@ -168,6 +204,23 @@ Foam::label Foam::RBD::rigidBodyModel::join
|
||||
}
|
||||
|
||||
|
||||
void Foam::RBD::rigidBodyModel::makeComposite(const label bodyID)
|
||||
{
|
||||
if (!isA<compositeBody>(bodies_[bodyID]))
|
||||
{
|
||||
// Retrieve the un-merged body
|
||||
autoPtr<rigidBody> bodyPtr = bodies_.set(bodyID, NULL);
|
||||
|
||||
// Insert the compositeBody containing the original body
|
||||
bodies_.set
|
||||
(
|
||||
bodyID,
|
||||
new compositeBody(bodyPtr)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::label Foam::RBD::rigidBodyModel::merge
|
||||
(
|
||||
const label parentID,
|
||||
@ -183,6 +236,9 @@ Foam::label Foam::RBD::rigidBodyModel::merge
|
||||
if (merged(parentID))
|
||||
{
|
||||
const subBody& sBody = mergedBody(parentID);
|
||||
|
||||
makeComposite(sBody.parentID());
|
||||
|
||||
sBodyPtr.set
|
||||
(
|
||||
new subBody
|
||||
@ -196,6 +252,8 @@ Foam::label Foam::RBD::rigidBodyModel::merge
|
||||
}
|
||||
else
|
||||
{
|
||||
makeComposite(parentID);
|
||||
|
||||
sBodyPtr.set
|
||||
(
|
||||
new subBody
|
||||
@ -238,4 +296,62 @@ Foam::spatialTransform Foam::RBD::rigidBodyModel::X0
|
||||
}
|
||||
|
||||
|
||||
void Foam::RBD::rigidBodyModel::write(Ostream& os) const
|
||||
{
|
||||
os << indent << "bodies" << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
|
||||
for (label i=1; i<nBodies(); i++)
|
||||
{
|
||||
os << indent << bodies_[i].name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
|
||||
|
||||
os.writeKeyword("type")
|
||||
<< bodies_[i].type() << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("parent")
|
||||
<< bodies_[lambda_[i]].name() << token::END_STATEMENT << nl;
|
||||
|
||||
bodies_[i].write(os);
|
||||
|
||||
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 << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
|
||||
forAll (mergedBodies_, i)
|
||||
{
|
||||
os << indent << mergedBodies_[i].name() << nl
|
||||
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
|
||||
|
||||
os.writeKeyword("type")
|
||||
<< mergedBodies_[i].body().type() << token::END_STATEMENT << nl;
|
||||
|
||||
os.writeKeyword("mergeWith")
|
||||
<< mergedBodies_[i].parentName() << token::END_STATEMENT << nl;
|
||||
|
||||
mergedBodies_[i].body().write(os);
|
||||
|
||||
os.writeKeyword("transform")
|
||||
<< mergedBodies_[i].parentXT() << token::END_STATEMENT << nl;
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << endl;
|
||||
}
|
||||
|
||||
os << decrIndent << indent << token::END_BLOCK << nl;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -66,12 +66,17 @@ namespace RBD
|
||||
|
||||
class rigidBodyModel
|
||||
{
|
||||
//- Initialize the model with the root-body which is a fixed massless body
|
||||
// at the origin.
|
||||
void initializeRootBody();
|
||||
// Private member functions
|
||||
|
||||
//- Resize the state fields following the joining of a body
|
||||
void resizeState();
|
||||
//- Initialize the model with the root-body
|
||||
// which is a fixed massless bodyat the origin.
|
||||
void initializeRootBody();
|
||||
|
||||
//- Resize the state fields following the joining of a body
|
||||
void resizeState();
|
||||
|
||||
//- Convert the body with given ID into a composite-body
|
||||
void makeComposite(const label bodyID);
|
||||
|
||||
|
||||
protected:
|
||||
@ -183,6 +188,9 @@ public:
|
||||
//- Null-constructor which adds the single root-body at the origin
|
||||
rigidBodyModel();
|
||||
|
||||
//- Construct from dictionary
|
||||
rigidBodyModel(const dictionary& dict);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~rigidBodyModel()
|
||||
@ -301,6 +309,9 @@ public:
|
||||
const scalarField& qDot,
|
||||
const scalarField& qDdot
|
||||
) const;
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user