rigidBodyDynamics: Added support for 0-DoF joints

This allows for fixed joints or joints which completely constrain the
motion as a function of some other aspect of the model. The latter has
also been facilitaed by adding a reference to the rigid body model to
the base joint class.
This commit is contained in:
Will Bainbridge
2018-05-04 14:31:47 +01:00
parent c236ab5369
commit f39bf2d84d
37 changed files with 309 additions and 274 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Pa.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Pa::Pa(const vector& axis)
Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const vector& axis)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(Zero, axis/mag(axis));
}
Foam::RBD::joints::Pa::Pa(const dictionary& dict)
Foam::RBD::joints::Pa::Pa(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
vector axis(dict.lookup("axis"));
S_[0] = spatialVector(Zero, axis/mag(axis));
@ -84,13 +84,12 @@ Foam::RBD::joints::Pa::~Pa()
void Foam::RBD::joints::Pa::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.X = Xt(S_[0].l()*state.q()[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.v = S_[0]*state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model and axis
Pa(const vector& axis);
Pa(const rigidBodyModel& model, const vector& axis);
//- Construct for given model from dictionary
Pa(const dictionary& dict);
Pa(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
//- Write

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Px.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Px::Px()
Foam::RBD::joints::Px::Px(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
}
Foam::RBD::joints::Px::Px(const dictionary& dict)
Foam::RBD::joints::Px::Px(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
}
@ -83,13 +83,12 @@ Foam::RBD::joints::Px::~Px()
void Foam::RBD::joints::Px::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.X = Xt(S_[0].l()*state.q()[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.v = S_[0]*state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Px();
Px(const rigidBodyModel& model);
//- Construct for given model from dictionary
Px(const dictionary& dict);
Px(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Pxyz.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,9 +50,9 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Pxyz::Pxyz()
Foam::RBD::joints::Pxyz::Pxyz(const rigidBodyModel& model)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
S_[1] = spatialVector(0, 0, 0, 0, 1, 0);
@ -60,9 +60,13 @@ Foam::RBD::joints::Pxyz::Pxyz()
}
Foam::RBD::joints::Pxyz::Pxyz(const dictionary& dict)
Foam::RBD::joints::Pxyz::Pxyz
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 0, 0, 1, 0, 0);
S_[1] = spatialVector(0, 0, 0, 0, 1, 0);
@ -87,19 +91,18 @@ Foam::RBD::joints::Pxyz::~Pxyz()
void Foam::RBD::joints::Pxyz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X.E() = tensor::I;
J.X.r() = q.block<vector>(qIndex_);
J.X.r() = state.q().block<vector>(qIndex_);
J.S = Zero;
J.S(3,0) = 1;
J.S(4,1) = 1;
J.S(5,2) = 1;
J.v = spatialVector(Zero, qDot.block<vector>(qIndex_));
J.v = spatialVector(Zero, state.qDot().block<vector>(qIndex_));
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Pxyz();
Pxyz(const rigidBodyModel& model);
//- Construct for given model from dictionary
Pxyz(const dictionary& dict);
Pxyz(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Py.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Py::Py()
Foam::RBD::joints::Py::Py(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 0, 1, 0);
}
Foam::RBD::joints::Py::Py(const dictionary& dict)
Foam::RBD::joints::Py::Py(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 0, 1, 0);
}
@ -83,13 +83,12 @@ Foam::RBD::joints::Py::~Py()
void Foam::RBD::joints::Py::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.X = Xt(S_[0].l()*state.q()[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.v = S_[0]*state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Py();
Py(const rigidBodyModel& model);
//- Construct for given model from dictionary
Py(const dictionary& dict);
Py(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Pz.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Pz::Pz()
Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
Foam::RBD::joints::Pz::Pz(const dictionary& dict)
Foam::RBD::joints::Pz::Pz(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 0, 0, 0, 1);
}
@ -83,13 +83,12 @@ Foam::RBD::joints::Pz::~Pz()
void Foam::RBD::joints::Pz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xt(S_[0].l()*q[qIndex_]);
J.X = Xt(S_[0].l()*state.q()[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.v = S_[0]*state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Pz();
Pz(const rigidBodyModel& model);
//- Construct for given model from dictionary
Pz(const dictionary& dict);
Pz(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Ra.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Ra::Ra(const vector& axis)
Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const vector& axis)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(axis/mag(axis), Zero);
}
Foam::RBD::joints::Ra::Ra(const dictionary& dict)
Foam::RBD::joints::Ra::Ra(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
vector axis(dict.lookup("axis"));
S_[0] = spatialVector(axis/mag(axis), Zero);
@ -84,13 +84,12 @@ Foam::RBD::joints::Ra::~Ra()
void Foam::RBD::joints::Ra::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xr(S_[0].w(), q[qIndex_]);
J.X = Xr(S_[0].w(), state.q()[qIndex_]);
J.S1 = S_[0];
J.v = S_[0]*qDot[qIndex_];
J.v = S_[0]*state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model and axis
Ra(const vector& axis);
Ra(const rigidBodyModel& model, const vector& axis);
//- Construct for given model from dictionary
Ra(const dictionary& dict);
Ra(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
//- Write

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Rs.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,9 +50,9 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Rs::Rs()
Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model)
:
joint(3)
joint(model, 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()
}
Foam::RBD::joints::Rs::Rs(const dictionary& dict)
Foam::RBD::joints::Rs::Rs(const rigidBodyModel& model, const dictionary& dict)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
S_[1] = spatialVector (0, 1, 0, 0, 0, 0);
@ -93,11 +93,10 @@ bool Foam::RBD::joints::Rs::unitQuaternion() const
void Foam::RBD::joints::Rs::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X.E() = joint::unitQuaternion(q).R().T();
J.X.E() = joint::unitQuaternion(state.q()).R().T();
J.X.r() = Zero;
J.S = Zero;
@ -105,7 +104,7 @@ void Foam::RBD::joints::Rs::jcalc
J.S.yy() = 1;
J.S.zz() = 1;
J.v = spatialVector(qDot.block<vector>(qIndex_), Zero);
J.v = spatialVector(state.qDot().block<vector>(qIndex_), Zero);
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,10 +73,10 @@ public:
// Constructors
//- Construct for given model
Rs();
Rs(const rigidBodyModel& model);
//- Construct for given model from dictionary
Rs(const dictionary& dict);
Rs(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -95,8 +95,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Rx.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Rx::Rx()
Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
}
Foam::RBD::joints::Rx::Rx(const dictionary& dict)
Foam::RBD::joints::Rx::Rx(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
}
@ -83,14 +83,13 @@ Foam::RBD::joints::Rx::~Rx()
void Foam::RBD::joints::Rx::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xrx(q[qIndex_]);
J.X = Xrx(state.q()[qIndex_]);
J.S1 = S_[0];
J.v = Zero;
J.v.wx() = qDot[qIndex_];
J.v.wx() = state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Rx();
Rx(const rigidBodyModel& model);
//- Construct for given model from dictionary
Rx(const dictionary& dict);
Rx(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Rxyz.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,9 +50,9 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Rxyz::Rxyz()
Foam::RBD::joints::Rxyz::Rxyz(const rigidBodyModel& model)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
@ -60,9 +60,13 @@ Foam::RBD::joints::Rxyz::Rxyz()
}
Foam::RBD::joints::Rxyz::Rxyz(const dictionary& dict)
Foam::RBD::joints::Rxyz::Rxyz
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(1, 0, 0, 0, 0, 0);
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
@ -87,11 +91,10 @@ Foam::RBD::joints::Rxyz::~Rxyz()
void Foam::RBD::joints::Rxyz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
vector qj(q.block<vector>(qIndex_));
vector qj(state.q().block<vector>(qIndex_));
scalar s0 = sin(qj.x());
scalar c0 = cos(qj.x());
@ -116,7 +119,7 @@ void Foam::RBD::joints::Rxyz::jcalc
J.S.zx() = s1;
J.S.zz() = 1;
vector qDotj(qDot.block<vector>(qIndex_));
vector qDotj(state.qDot().block<vector>(qIndex_));
J.v = J.S & qDotj;
J.c = spatialVector

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,10 +73,10 @@ public:
// Constructors
//- Construct for given model
Rxyz();
Rxyz(const rigidBodyModel& model);
//- Construct for given model from dictionary
Rxyz(const dictionary& dict);
Rxyz(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -92,8 +92,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Ry.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Ry::Ry()
Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
}
Foam::RBD::joints::Ry::Ry(const dictionary& dict)
Foam::RBD::joints::Ry::Ry(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
}
@ -83,14 +83,13 @@ Foam::RBD::joints::Ry::~Ry()
void Foam::RBD::joints::Ry::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xry(q[qIndex_]);
J.X = Xry(state.q()[qIndex_]);
J.S1 = S_[0];
J.v = Zero;
J.v.wy() = qDot[qIndex_];
J.v.wy() = state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Ry();
Ry(const rigidBodyModel& model);
//- Construct for given model from dictionary
Ry(const dictionary& dict);
Ry(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Ryxz.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,9 +50,9 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Ryxz::Ryxz()
Foam::RBD::joints::Ryxz::Ryxz(const rigidBodyModel& model)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
S_[1] = spatialVector(1, 0, 0, 0, 0, 0);
@ -60,9 +60,13 @@ Foam::RBD::joints::Ryxz::Ryxz()
}
Foam::RBD::joints::Ryxz::Ryxz(const dictionary& dict)
Foam::RBD::joints::Ryxz::Ryxz
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 1, 0, 0, 0, 0);
S_[1] = spatialVector(1, 0, 0, 0, 0, 0);
@ -87,11 +91,10 @@ Foam::RBD::joints::Ryxz::~Ryxz()
void Foam::RBD::joints::Ryxz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
vector qj(q.block<vector>(qIndex_));
vector qj(state.q().block<vector>(qIndex_));
scalar s0 = sin(qj.x());
scalar c0 = cos(qj.x());
@ -116,7 +119,7 @@ void Foam::RBD::joints::Ryxz::jcalc
J.S.zx() = -s1;
J.S.zz() = 1;
vector qDotj(qDot.block<vector>(qIndex_));
vector qDotj(state.qDot().block<vector>(qIndex_));
J.v = J.S & qDotj;
J.c = spatialVector

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,10 +73,10 @@ public:
// Constructors
//- Construct for given model
Ryxz();
Ryxz(const rigidBodyModel& model);
//- Construct for given model from dictionary
Ryxz(const dictionary& dict);
Ryxz(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -92,8 +92,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Rz.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,17 +50,17 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Rz::Rz()
Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
}
Foam::RBD::joints::Rz::Rz(const dictionary& dict)
Foam::RBD::joints::Rz::Rz(const rigidBodyModel& model, const dictionary& dict)
:
joint(1)
joint(model, 1)
{
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
}
@ -83,14 +83,13 @@ Foam::RBD::joints::Rz::~Rz()
void Foam::RBD::joints::Rz::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
J.X = Xrz(q[qIndex_]);
J.X = Xrz(state.q()[qIndex_]);
J.S1 = S_[0];
J.v = Zero;
J.v.wz() = qDot[qIndex_];
J.v.wz() = state.qDot()[qIndex_];
J.c = Zero;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -72,10 +72,10 @@ public:
// Constructors
//- Construct for given model
Rz();
Rz(const rigidBodyModel& model);
//- Construct for given model from dictionary
Rz(const dictionary& dict);
Rz(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +91,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "Rzyx.H"
#include "rigidBodyModel.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -50,9 +50,9 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::Rzyx::Rzyx()
Foam::RBD::joints::Rzyx::Rzyx(const rigidBodyModel& model)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
@ -60,9 +60,13 @@ Foam::RBD::joints::Rzyx::Rzyx()
}
Foam::RBD::joints::Rzyx::Rzyx(const dictionary& dict)
Foam::RBD::joints::Rzyx::Rzyx
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(3)
joint(model, 3)
{
S_[0] = spatialVector(0, 0, 1, 0, 0, 0);
S_[1] = spatialVector(0, 1, 0, 0, 0, 0);
@ -87,11 +91,10 @@ Foam::RBD::joints::Rzyx::~Rzyx()
void Foam::RBD::joints::Rzyx::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
vector qj(q.block<vector>(qIndex_));
vector qj(state.q().block<vector>(qIndex_));
scalar s0 = sin(qj.x());
scalar c0 = cos(qj.x());
@ -116,7 +119,7 @@ void Foam::RBD::joints::Rzyx::jcalc
J.S.zx() = c1*c2;
J.S.zy() = -s2;
vector qDotj(qDot.block<vector>(qIndex_));
vector qDotj(state.qDot().block<vector>(qIndex_));
J.v = J.S & qDotj;
J.c = spatialVector

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -73,10 +73,10 @@ public:
// Constructors
//- Construct for given model
Rzyx();
Rzyx(const rigidBodyModel& model);
//- Construct for given model from dictionary
Rzyx(const dictionary& dict);
Rzyx(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -92,8 +92,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,7 +52,7 @@ namespace joints
void Foam::RBD::joints::composite::setLastJoint()
{
last().joint::operator=(*this);
//last().joint::operator=(*this);
}
@ -65,9 +65,13 @@ Foam::RBD::joints::composite::composite(const PtrList<joint>& joints)
{}
Foam::RBD::joints::composite::composite(const dictionary& dict)
Foam::RBD::joints::composite::composite
(
const rigidBodyModel& model,
const dictionary& dict
)
:
PtrList<joint>(dict.lookup("joints")),
PtrList<joint>(dict.lookup("joints"), joint::iNew(model)),
joint(last())
{}
@ -89,11 +93,10 @@ Foam::RBD::joints::composite::~composite()
void Foam::RBD::joints::composite::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
last().jcalc(J, q, qDot);
last().jcalc(J, state);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -89,7 +89,7 @@ public:
composite(const PtrList<joint>& joints);
//- Construct for given model from dictionary
composite(const dictionary& dict);
composite(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -105,8 +105,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
//- Write

View File

@ -55,17 +55,17 @@ namespace joints
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
Foam::autoPtr<Foam::RBD::joints::composite>
Foam::RBD::joints::floating::sixDoF()
Foam::RBD::joints::floating::sixDoF(const rigidBodyModel& model)
{
PtrList<joint> cj(2);
cj.set(0, new joints::Pxyz());
cj.set(0, new joints::Pxyz(model));
// The quaternion-based spherical joint could be used
// but then w must be set appropriately
// cj.set(1, new joints::Rs());
// cj.set(1, new joints::Rs(model));
// Alternatively the Euler-angle joint can be used
cj.set(1, new joints::Rzyx());
cj.set(1, new joints::Rzyx(model));
return autoPtr<composite>(new composite(cj));
}
@ -73,15 +73,19 @@ Foam::RBD::joints::floating::sixDoF()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::floating::floating()
Foam::RBD::joints::floating::floating(const rigidBodyModel& model)
:
composite(sixDoF())
composite(sixDoF(model))
{}
Foam::RBD::joints::floating::floating(const dictionary& dict)
Foam::RBD::joints::floating::floating
(
const rigidBodyModel& model,
const dictionary& dict
)
:
composite(sixDoF())
composite(sixDoF(model))
{}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -65,7 +65,7 @@ class floating
// Private member functions
//- Return a list of joints needed to emulate a floating body
static autoPtr<composite> sixDoF();
static autoPtr<composite> sixDoF(const rigidBodyModel& model);
public:
@ -77,10 +77,10 @@ public:
// Constructors
//- Construct
floating();
floating(const rigidBodyModel& model);
//- Construct for given model from dictionary
floating(const dictionary& dict);
floating(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,6 +48,7 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::New(joint* jointPtr)
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::New
(
const rigidBodyModel& model,
const dictionary& dict
)
{
@ -66,7 +67,7 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::New
<< exit(FatalError);
}
return autoPtr<joint>(cstrIter()(dict));
return autoPtr<joint>(cstrIter()(model, dict));
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -66,6 +66,7 @@ namespace RBD
// Forward declaration of classes
class rigidBodyModel;
class rigidBodyModelState;
// Forward declaration of friend functions and operators
class joint;
@ -84,14 +85,17 @@ protected:
// Protected data
//- Joint motion sub-space
List<spatialVector> S_;
//- Reference to the model
const rigidBodyModel& model_;
//- Index of this joint in the rigidBodyModel
label index_;
//- Joint motion sub-space
List<spatialVector> S_;
//- Index of this joints data in the rigidBodyModel state
label qIndex_;
//- Index of this joint in the rigidBodyModel
label index_;
//- Index of this joints data in the rigidBodyModel state
label qIndex_;
private:
@ -160,8 +164,8 @@ public:
autoPtr,
joint,
dictionary,
(const dictionary& dict),
(dict)
(const rigidBodyModel& model, const dictionary& dict),
(model, dict)
);
@ -169,7 +173,7 @@ public:
//- Construct joint setting the size of the motion sub-space
// to the given degrees of freedom of the joint
inline joint(const label nDoF);
inline joint(const rigidBodyModel& model, const label nDoF);
//- Clone this joint (needed by PtrList)
virtual autoPtr<joint> clone() const = 0;
@ -177,9 +181,13 @@ public:
class iNew
{
const rigidBodyModel& model_;
public:
iNew()
iNew(const rigidBodyModel& model)
:
model_(model)
{}
inline autoPtr<joint> operator()(Istream& is) const;
@ -196,7 +204,11 @@ public:
static autoPtr<joint> New(joint* jointPtr);
//- Select from dictionary
static autoPtr<joint> New(const dictionary& dict);
static autoPtr<joint> New
(
const rigidBodyModel& model,
const dictionary& dict
);
// Member Functions
@ -222,8 +234,7 @@ public:
virtual void jcalc
(
XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const = 0;
//- Write

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,8 +25,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
inline Foam::RBD::joint::joint(const label nDoF)
inline Foam::RBD::joint::joint(const rigidBodyModel& model, const label nDoF)
:
model_(model),
S_(nDoF),
index_(0),
qIndex_(0)
@ -104,7 +105,7 @@ Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joint::iNew::operator()
) const
{
dictionary dict(is);
return New(dict);
return New(model_, dict);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -50,15 +50,19 @@ namespace joints
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::null::null()
Foam::RBD::joints::null::null(const rigidBodyModel& model)
:
joint(0)
joint(model, 0)
{}
Foam::RBD::joints::null::null(const dictionary& dict)
Foam::RBD::joints::null::null
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(0)
joint(model, 0)
{}
@ -79,8 +83,7 @@ Foam::RBD::joints::null::~null()
void Foam::RBD::joints::null::jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const
{
FatalErrorInFunction

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -51,6 +51,9 @@ namespace Foam
{
namespace RBD
{
class rigidBodyModel;
namespace joints
{
@ -72,10 +75,10 @@ public:
// Constructors
//- Construct for given model
null();
null(const rigidBodyModel& model);
//- Construct for given model from dictionary
null(const dictionary& dict);
null(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
@ -91,8 +94,7 @@ public:
virtual void jcalc
(
joint::XSvc& J,
const scalarField& q,
const scalarField& qDot
const rigidBodyModelState& state
) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,13 +57,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamics
const Field<spatialVector>& fx
) const
{
const scalarField& q = state.q();
const scalarField& qDot = state.qDot();
scalarField& qDdot = state.qDdot();
DebugInFunction
<< "q = " << q << nl
<< "qDot = " << qDot << nl
<< "q = " << state.q() << nl
<< "qDot = " << state.qDot() << nl
<< "tau = " << tau << endl;
// Joint state returned by jcalc
@ -74,7 +72,7 @@ void Foam::RBD::rigidBodyModel::forwardDynamics
for (label i=1; i<nBodies(); i++)
{
const joint& jnt = joints()[i];
jnt.jcalc(J, q, qDot);
jnt.jcalc(J, state);
S_[i] = J.S;
S1_[i] = J.S1;
@ -108,7 +106,28 @@ void Foam::RBD::rigidBodyModel::forwardDynamics
const joint& jnt = joints()[i];
const label qi = jnt.qIndex();
if (jnt.nDoF() == 1)
if (jnt.nDoF() == 0)
{
U1_[i] = Zero;
u_[i] = Zero;
const label lambdai = lambda_[i];
if (lambdai != 0)
{
const spatialTensor Ia(IA_[i]);
const spatialVector pa(pA_[i] + (Ia & c_[i]));
IA_[lambdai] +=
spatialTensor(Xlambda_[i].T())
& Ia
& spatialTensor(Xlambda_[i]);
pA_[lambdai] += Xlambda_[i].T() & pa;
}
}
else if (jnt.nDoF() == 1)
{
U1_[i] = IA_[i] & S1_[i];
Dinv_[i].xx() = 1/(S1_[i] && U1_[i]);
@ -140,24 +159,20 @@ void Foam::RBD::rigidBodyModel::forwardDynamics
{
U_[i] = IA_[i] & S_[i];
Dinv_[i] = (S_[i].T() & U_[i]).inv();
u_[i] = tau.block<vector>(qi) - (S_[i].T() & pA_[i]);
const label lambdai = lambda_[i];
if (lambdai != 0)
{
spatialTensor Ia
const spatialTensor Ia
(
IA_[i]
- (U_[i] & Dinv_[i] & U_[i].T())
IA_[i] - (U_[i] & Dinv_[i] & U_[i].T())
);
spatialVector pa
const spatialVector pa
(
pA_[i]
+ (Ia & c_[i])
+ (U_[i] & Dinv_[i] & u_[i])
pA_[i] + (Ia & c_[i]) + (U_[i] & Dinv_[i] & u_[i])
);
IA_[lambdai] +=
@ -179,7 +194,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamics
a_[i] = (Xlambda_[i] & a_[lambda_[i]]) + c_[i];
if (jnt.nDoF() == 1)
if (jnt.nDoF() == 0)
{
// do nothing
}
else if (jnt.nDoF() == 1)
{
qDdot[qi] = Dinv_[i].xx()*(u_[i].x() - (U1_[i] && a_[i]));
a_[i] += S1_[i]*qDdot[qi];
@ -208,12 +227,10 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection
const rigidBodyModelState& state
) const
{
DebugInFunction << endl;
const scalarField& q = state.q();
const scalarField& qDot = state.qDot();
const scalarField& qDdot = state.qDdot();
DebugInFunction << endl;
// Joint state returned by jcalc
joint::XSvc J;
@ -225,7 +242,7 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection
const joint& jnt = joints()[i];
const label qi = jnt.qIndex();
jnt.jcalc(J, q, qDot);
jnt.jcalc(J, state);
S_[i] = J.S;
S1_[i] = J.S1;
@ -247,7 +264,11 @@ void Foam::RBD::rigidBodyModel::forwardDynamicsCorrection
c_[i] = J.c + (v_[i] ^ J.v);
a_[i] = (Xlambda_[i] & a_[lambdai]) + c_[i];
if (jnt.nDoF() == 1)
if (jnt.nDoF() == 0)
{
// do nothing
}
else if (jnt.nDoF() == 1)
{
a_[i] += S1_[i]*qDdot[qi];
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,7 @@ void Foam::RBD::rigidBodyModel::initializeRootBody()
bodies_.append(new masslessBody("root"));
lambda_.append(0);
bodyIDs_.insert("root", 0);
joints_.append(new joints::null());
joints_.append(new joints::null(*this));
XT_.append(spatialTransform());
nDoF_ = 0;
@ -198,7 +198,7 @@ Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict)
(
bodyID(bodyDict.lookup("parent")),
bodyDict.lookup("transform"),
joint::New(bodyDict.subDict("joint")),
joint::New(*this, bodyDict.subDict("joint")),
rigidBody::New(iter().keyword(), bodyDict)
);
}