diff --git a/applications/test/rigidBodyDynamics/pendulum/pendulum b/applications/test/rigidBodyDynamics/pendulum/pendulum index d179af4438..ca72a083a1 100644 --- a/applications/test/rigidBodyDynamics/pendulum/pendulum +++ b/applications/test/rigidBodyDynamics/pendulum/pendulum @@ -1,4 +1,4 @@ -bodies0 +bodies { pendulum { @@ -10,12 +10,12 @@ bodies0 transform (1 0 0 0 1 0 0 0 1) (0 0 0); joint { - type Rz; + type floating; } } } -bodies +bodies0 { hinge { diff --git a/src/rigidBodyDynamics/Make/files b/src/rigidBodyDynamics/Make/files index 1e658c85e9..5849d63b1e 100644 --- a/src/rigidBodyDynamics/Make/files +++ b/src/rigidBodyDynamics/Make/files @@ -1,5 +1,6 @@ bodies/rigidBody/rigidBody.C bodies/masslessBody/masslessBody.C +bodies/jointBody/jointBody.C bodies/compositeBody/compositeBody.C bodies/subBody/subBody.C bodies/sphere/sphere.C diff --git a/src/rigidBodyDynamics/bodies/jointBody/jointBody.C b/src/rigidBodyDynamics/bodies/jointBody/jointBody.C new file mode 100644 index 0000000000..01a4a68c1d --- /dev/null +++ b/src/rigidBodyDynamics/bodies/jointBody/jointBody.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "jointBody.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RBD +{ + defineTypeNameAndDebug(jointBody, 0); + + addToRunTimeSelectionTable + ( + rigidBody, + jointBody, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::RBD::jointBody::clone() const +{ + return autoPtr(new jointBody(*this)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::RBD::jointBody::~jointBody() +{} + + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/bodies/jointBody/jointBody.H b/src/rigidBodyDynamics/bodies/jointBody/jointBody.H new file mode 100644 index 0000000000..1784de009d --- /dev/null +++ b/src/rigidBodyDynamics/bodies/jointBody/jointBody.H @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\3 + ========= | + \\ / 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 . + +Class + Foam::jointBody + +Description + +SourceFiles + jointBodyI.H + jointBody.C + +\*---------------------------------------------------------------------------*/ + +#ifndef RBD_jointBody_H +#define RBD_jointBody_H + +#include "masslessBody.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace RBD +{ + +/*---------------------------------------------------------------------------*\ + Class jointBody Declaration +\*---------------------------------------------------------------------------*/ + +class jointBody +: + public masslessBody +{ + +public: + + //- Runtime type information + TypeName("jointBody"); + + + // Constructors + + //- Construct a joint body + inline jointBody(); + + //- Construct a named joint body + inline jointBody(const word& name); + + //- Construct from dictionary + inline jointBody + ( + const word& name, + const dictionary& dict + ); + + //- Return clone of this jointBody + virtual autoPtr clone() const; + + + //- Destructor + virtual ~jointBody(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RBD +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "jointBodyI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/bodies/jointBody/jointBodyI.H b/src/rigidBodyDynamics/bodies/jointBody/jointBodyI.H new file mode 100644 index 0000000000..52f5e3bb6b --- /dev/null +++ b/src/rigidBodyDynamics/bodies/jointBody/jointBodyI.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::RBD::jointBody::jointBody() +{} + + +inline Foam::RBD::jointBody::jointBody(const word& name) +: + masslessBody(name) +{} + + +inline Foam::RBD::jointBody::jointBody +( + const word& name, + const dictionary& dict +) +: + masslessBody(name, dict) +{} + + + +// ************************************************************************* // diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C index 47c7983939..6e38206b51 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.C @@ -26,6 +26,7 @@ License #include "rigidBodyModel.H" #include "masslessBody.H" #include "compositeBody.H" +#include "jointBody.H" #include "nullJoint.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -215,7 +216,7 @@ Foam::label Foam::RBD::rigidBodyModel::join label parent = parentID; joints::composite& cJoint = cJointPtr(); - // For all but the final joint in the set add a masslessBody with the + // For all but the final joint in the set add a jointBody with the // joint and transform for (label j=0; j(new masslessBody) + autoPtr(new jointBody) ); } @@ -341,24 +342,26 @@ void Foam::RBD::rigidBodyModel::write(Ostream& os) const for (label i=1; i(bodies_[i])) + { + os << indent << bodies_[i].name() << nl + << indent << token::BEGIN_BLOCK << incrIndent << endl; - bodies_[i].write(os); + bodies_[i].write(os); - os.writeKeyword("parent") - << bodies_[lambda_[i]].name() << token::END_STATEMENT << nl; + os.writeKeyword("parent") + << bodies_[lambda_[i]].name() << token::END_STATEMENT << nl; - os.writeKeyword("transform") - << XT_[i] << token::END_STATEMENT << nl; + os.writeKeyword("transform") + << XT_[i] << token::END_STATEMENT << nl; - os << indent << "joint" << nl << joints_[i] << endl; + os << indent << "joint" << nl << joints_[i] << endl; - os << decrIndent << indent << token::END_BLOCK << endl; + os << decrIndent << indent << token::END_BLOCK << endl; + } } - - forAll (mergedBodies_, i) + forAll(mergedBodies_, i) { os << indent << mergedBodies_[i].name() << nl << indent << token::BEGIN_BLOCK << incrIndent << endl;