Commit 11775540 authored by Henry Weller's avatar Henry Weller
Browse files

rigidBodyDynamics/restraints: Complete dictionary IO

parent c0190716
......@@ -33,6 +33,7 @@ Description
#include "masslessBody.H"
#include "sphere.H"
#include "joints.H"
#include "rigidBodyRestraint.H"
#include "IFstream.H"
#include "OFstream.H"
......
......@@ -78,22 +78,19 @@ Foam::RBD::restraints::linearSpring::~linearSpring()
Foam::spatialVector Foam::RBD::restraints::linearSpring::restrain() const
{
spatialVector attachmentPt
(
model_.X0(bodyIndex_).inv() && spatialVector(Zero, refAttachmentPt_)
);
point attachmentPt = bodyPoint(refAttachmentPt_);
// Current axis of the spring
vector r = attachmentPt.l() - anchor_;
vector r = attachmentPt - anchor_;
scalar magR = mag(r);
r /= (magR + VSMALL);
// Velocity of the end of the spring
vector v = model_.v(bodyIndex_, refAttachmentPt_).l();
// Velocity of the attached end of the spring
vector v = bodyPointVelocity(refAttachmentPt_).l();
// Force and moment including optional damping
vector force = (-stiffness_*(magR - restLength_) - damping_*(r & v))*r;
vector moment = (attachmentPt.l() - model_.X0(bodyIndex_).r()) ^ force;
vector moment = (attachmentPt - model_.X0(bodyIndex_).r()) ^ force;
if (model_.debug)
{
......
......@@ -32,11 +32,10 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef linearSpring_H
#define linearSpring_H
#ifndef RBD_restraints_linearSpring_H
#define RBD_restraints_linearSpring_H
#include "rigidBodyRestraint.H"
#include "point.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -77,7 +77,10 @@ bool Foam::RBD::restraint::read(const dictionary& dict)
void Foam::RBD::restraint::write(Ostream& os) const
{
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
os.writeKeyword("type")
<< type() << token::END_STATEMENT << nl;
os.writeKeyword("body")
<< model_.name(bodyIndex_) << token::END_STATEMENT << nl;
}
......
......@@ -39,12 +39,13 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef RBD_restraint_H
#define RBD_restraint_H
#ifndef RBD_rigidBodyRestraint_H
#define RBD_rigidBodyRestraint_H
#include "dictionary.H"
#include "autoPtr.H"
#include "spatialVector.H"
#include "point.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -80,6 +81,13 @@ protected:
//- Reference to the model
const rigidBodyModel& model_;
//- Transform the given point on the restrained body to the global frame
inline point bodyPoint(const point& p) const;
//- Transform the velocity of the given point on the restrained body
// to the global frame
inline spatialVector bodyPointVelocity(const point& p) const;
public:
......@@ -166,6 +174,10 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "rigidBodyRestraintI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "rigidBodyModel.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::point Foam::RBD::restraint::bodyPoint
(
const point& p
) const
{
return (model_.X0(bodyIndex_).inv() && spatialVector(Zero, p)).l();
}
inline Foam::spatialVector Foam::RBD::restraint::bodyPointVelocity
(
const point& p
) const
{
return model_.v(bodyIndex_, p);
}
// ************************************************************************* //
......@@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "rigidBodyModel.H"
#include "rigidBodyRestraint.H"
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
......
......@@ -28,6 +28,7 @@ License
#include "compositeBody.H"
#include "jointBody.H"
#include "nullJoint.H"
#include "rigidBodyRestraint.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
......
......@@ -53,7 +53,6 @@ SourceFiles
#include "subBody.H"
#include "joint.H"
#include "compositeJoint.H"
#include "rigidBodyRestraint.H"
#include "PtrList.H"
#include "HashTable.H"
......@@ -64,6 +63,7 @@ namespace RBD
// Forward declaration of friend functions and operators
class rigidBodyModel;
class restraint;
Ostream& operator<<(Ostream&, const rigidBodyModel&);
......@@ -255,6 +255,9 @@ public:
// after model construction
inline vector& g();
//- Return the name of body with the given ID
inline const word& name(const label bodyID) const;
//- Return the inertia of body i
inline const rigidBodyInertia& I(const label i) const;
......
......@@ -38,6 +38,13 @@ Foam::RBD::rigidBodyModel::bodies() const
}
inline const Foam::DynamicList<Foam::label>&
Foam::RBD::rigidBodyModel::lambda() const
{
return lambda_;
}
inline const Foam::PtrList<Foam::RBD::joint>&
Foam::RBD::rigidBodyModel::joints() const
{
......@@ -69,10 +76,19 @@ inline Foam::vector& Foam::RBD::rigidBodyModel::g()
}
inline const Foam::DynamicList<Foam::label>&
Foam::RBD::rigidBodyModel::lambda() const
inline const Foam::word& Foam::RBD::rigidBodyModel::name
(
const label bodyID
) const
{
return lambda_;
if (merged(bodyID))
{
return mergedBody(bodyID).name();
}
else
{
return bodies_[bodyID].name();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment