rigidBodyDynamics: Added some 0-DoF joints

The new "rigid" joint permits no motion at all, "function" specifies the
position of the joint as a function of the position of it's parent, and
"functionDot" specifies the position of the joint as a function of the
velocity of it's parent. Note that the functions are applied uniformly
to each component of the parent joint's position/motion. Example
specifications are shown below.

    joint
    {
        type    rigid;
    }

    joint
    {
        type    function;
        function table ((-1 0) (0 1) (1 0));
    }

    joint
    {
        type    functionDot;
        function table ((-1 0) (0 1) (1 0));
    }

This work was supported by Caitlin Worden Hodge, at Zyba
This commit is contained in:
Will Bainbridge
2018-05-08 08:36:17 +01:00
parent ae5a31e8b7
commit d501e87ec2
8 changed files with 656 additions and 0 deletions

View File

@ -26,6 +26,10 @@ joints/Pz/Pz.C
joints/Pa/Pa.C joints/Pa/Pa.C
joints/Pxyz/Pxyz.C joints/Pxyz/Pxyz.C
joints/rigid/rigid.C
joints/function/function.C
joints/functionDot/functionDot.C
restraints/restraint/rigidBodyRestraint.C restraints/restraint/rigidBodyRestraint.C
restraints/restraint/rigidBodyRestraintNew.C restraints/restraint/rigidBodyRestraintNew.C
restraints/linearSpring/linearSpring.C restraints/linearSpring/linearSpring.C

View File

@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 "function.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
defineTypeNameAndDebug(function, 0);
addToRunTimeSelectionTable
(
joint,
function,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::function::function
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(model, 0),
f_(Function1<scalar>::New("function", dict))
{}
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joints::function::clone() const
{
return autoPtr<joint>(new function(*this));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::joints::function::~function()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::joints::function::jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const
{
const label lambda = model_.lambda()[index_];
const joint& parent = model_.joints()[lambda];
spatialVector x(Zero), v(Zero), c(Zero);
for(label i = 0; i < model_.joints()[lambda].nDoF(); ++ i)
{
x += f_->value(state.q()[parent.qIndex() + i])*parent.S()[i];
v += f_->value(state.qDot()[parent.qIndex() + i])*parent.S()[i];
c += f_->value(state.qDdot()[parent.qIndex() + i])*parent.S()[i];
}
const scalar magW = mag(x.w());
const tensor X(magW > vSmall ? quaternion(x.w(), magW).R() : tensor::I);
J.X = spatialTransform(X, x.l());
J.S = Zero;
J.S1 = Zero;
J.v = v;
J.c = c;
}
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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::function
Description
Joint in which the position is a function of the parent joint's position
Reference:
\verbatim
Featherstone, R. (2008).
Rigid body dynamics algorithms.
Springer.
Chapter 4.
\endverbatim
SourceFiles
function.C
\*---------------------------------------------------------------------------*/
#ifndef RBD_joints_function_H
#define RBD_joints_function_H
#include "joint.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
/*---------------------------------------------------------------------------*\
Class function Declaration
\*---------------------------------------------------------------------------*/
class function
:
public joint
{
private:
// Private data
//- Function
autoPtr<Function1<scalar>> f_;
public:
//- Runtime type information
TypeName("function");
// Constructors
//- Construct for given model from dictionary
function(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
//- Destructor
virtual ~function();
// Member Functions
//- Update the model state for this joint
virtual void jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace joints
} // End namespace RBD
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,106 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 "functionDot.H"
#include "rigidBodyModelState.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
defineTypeNameAndDebug(functionDot, 0);
addToRunTimeSelectionTable
(
joint,
functionDot,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::functionDot::functionDot
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(model, 0),
f_(Function1<scalar>::New("function", dict))
{}
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joints::functionDot::clone() const
{
return autoPtr<joint>(new functionDot(*this));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::joints::functionDot::~functionDot()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::joints::functionDot::jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const
{
const label lambda = model_.lambda()[index_];
const joint& parent = model_.joints()[lambda];
spatialVector x(Zero), v(Zero);
for(label i = 0; i < model_.joints()[lambda].nDoF(); ++ i)
{
x += f_->value(state.qDot()[parent.qIndex() + i])*parent.S()[i];
v += f_->value(state.qDdot()[parent.qIndex() + i])*parent.S()[i];
}
const scalar magW = mag(x.w());
const tensor X(magW > vSmall ? quaternion(x.w(), magW).R() : tensor::I);
J.X = spatialTransform(X, x.l());
J.S = Zero;
J.S1 = Zero;
J.v = v;
J.c = Zero; // Not enough information to specify this
}
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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::functionDot
Description
Joint in which the position is a function of the parent joint's velocity
Reference:
\verbatim
Featherstone, R. (2008).
Rigid body dynamics algorithms.
Springer.
Chapter 4.
\endverbatim
SourceFiles
functionDot.C
\*---------------------------------------------------------------------------*/
#ifndef RBD_joints_functionDot_H
#define RBD_joints_functionDot_H
#include "joint.H"
#include "Function1.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
/*---------------------------------------------------------------------------*\
Class functionDot Declaration
\*---------------------------------------------------------------------------*/
class functionDot
:
public joint
{
private:
// Private data
//- Function
autoPtr<Function1<scalar>> f_;
public:
//- Runtime type information
TypeName("functionDot");
// Constructors
//- Construct for given model from dictionary
functionDot(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
//- Destructor
virtual ~functionDot();
// Member Functions
//- Update the model state for this joint
virtual void jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace joints
} // End namespace RBD
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -23,3 +23,8 @@
#include "Pz.H" #include "Pz.H"
#include "Pa.H" #include "Pa.H"
#include "Pxyz.H" #include "Pxyz.H"
// 0-DoF joints
#include "rigid.H"
#include "function.H"
#include "functionDot.H"

View File

@ -0,0 +1,97 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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 "rigid.H"
#include "rigidBodyModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
defineTypeNameAndDebug(rigid, 0);
addToRunTimeSelectionTable
(
joint,
rigid,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::joints::rigid::rigid(const rigidBodyModel& model)
:
joint(model, 0)
{}
Foam::RBD::joints::rigid::rigid
(
const rigidBodyModel& model,
const dictionary& dict
)
:
joint(model, 0)
{}
Foam::autoPtr<Foam::RBD::joint> Foam::RBD::joints::rigid::clone() const
{
return autoPtr<joint>(new rigid(*this));
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::joints::rigid::~rigid()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
void Foam::RBD::joints::rigid::jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const
{
J.X = spatialTransform();
J.S = Zero;
J.S1 = Zero;
J.v = Zero;
J.c = Zero;
}
// ************************************************************************* //

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 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::rigid
Description
Rigid joint
Reference:
\verbatim
Featherstone, R. (2008).
Rigid body dynamics algorithms.
Springer.
Chapter 4.
\endverbatim
SourceFiles
rigid.C
\*---------------------------------------------------------------------------*/
#ifndef RBD_joints_rigid_H
#define RBD_joints_rigid_H
#include "joint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace joints
{
/*---------------------------------------------------------------------------*\
Class rigid Declaration
\*---------------------------------------------------------------------------*/
class rigid
:
public joint
{
public:
//- Runtime type information
TypeName("rigid");
// Constructors
//- Construct for given model
rigid(const rigidBodyModel& model);
//- Construct for given model from dictionary
rigid(const rigidBodyModel& model, const dictionary& dict);
//- Clone this joint
virtual autoPtr<joint> clone() const;
//- Destructor
virtual ~rigid();
// Member Functions
//- Update the model state for this joint
virtual void jcalc
(
joint::XSvc& J,
const rigidBodyModelState& state
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace joints
} // End namespace RBD
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //