diff --git a/src/rigidBodyDynamics/Make/files b/src/rigidBodyDynamics/Make/files index 07612c103..74b99e7a0 100644 --- a/src/rigidBodyDynamics/Make/files +++ b/src/rigidBodyDynamics/Make/files @@ -26,6 +26,10 @@ joints/Pz/Pz.C joints/Pa/Pa.C joints/Pxyz/Pxyz.C +joints/rigid/rigid.C +joints/function/function.C +joints/functionDot/functionDot.C + restraints/restraint/rigidBodyRestraint.C restraints/restraint/rigidBodyRestraintNew.C restraints/linearSpring/linearSpring.C diff --git a/src/rigidBodyDynamics/joints/function/function.C b/src/rigidBodyDynamics/joints/function/function.C new file mode 100644 index 000000000..4d1ca2798 --- /dev/null +++ b/src/rigidBodyDynamics/joints/function/function.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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::New("function", dict)) +{} + + +Foam::autoPtr Foam::RBD::joints::function::clone() const +{ + return autoPtr(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; +} + + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/joints/function/function.H b/src/rigidBodyDynamics/joints/function/function.H new file mode 100644 index 000000000..4201f833d --- /dev/null +++ b/src/rigidBodyDynamics/joints/function/function.H @@ -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 . + +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> 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 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 + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/joints/functionDot/functionDot.C b/src/rigidBodyDynamics/joints/functionDot/functionDot.C new file mode 100644 index 000000000..95d3c613f --- /dev/null +++ b/src/rigidBodyDynamics/joints/functionDot/functionDot.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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::New("function", dict)) +{} + + +Foam::autoPtr Foam::RBD::joints::functionDot::clone() const +{ + return autoPtr(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 +} + + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/joints/functionDot/functionDot.H b/src/rigidBodyDynamics/joints/functionDot/functionDot.H new file mode 100644 index 000000000..a1a6e08a7 --- /dev/null +++ b/src/rigidBodyDynamics/joints/functionDot/functionDot.H @@ -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 . + +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> 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 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 + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/joints/joints.H b/src/rigidBodyDynamics/joints/joints.H index b95829646..640b612ad 100644 --- a/src/rigidBodyDynamics/joints/joints.H +++ b/src/rigidBodyDynamics/joints/joints.H @@ -23,3 +23,8 @@ #include "Pz.H" #include "Pa.H" #include "Pxyz.H" + +// 0-DoF joints +#include "rigid.H" +#include "function.H" +#include "functionDot.H" diff --git a/src/rigidBodyDynamics/joints/rigid/rigid.C b/src/rigidBodyDynamics/joints/rigid/rigid.C new file mode 100644 index 000000000..9f1abc2c3 --- /dev/null +++ b/src/rigidBodyDynamics/joints/rigid/rigid.C @@ -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 . + +\*---------------------------------------------------------------------------*/ + +#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::joints::rigid::clone() const +{ + return autoPtr(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; +} + + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/joints/rigid/rigid.H b/src/rigidBodyDynamics/joints/rigid/rigid.H new file mode 100644 index 000000000..416d8ea16 --- /dev/null +++ b/src/rigidBodyDynamics/joints/rigid/rigid.H @@ -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 . + +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 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 + +// ************************************************************************* //