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

rigidBodyDynamics/restraints: Added linearDamper

parent 11775540
......@@ -28,6 +28,7 @@ joints/Pxyz/Pxyz.C
restraints/restraint/rigidBodyRestraint.C
restraints/restraint/rigidBodyRestraintNew.C
restraints/linearSpring/linearSpring.C
restraints/linearDamper/linearDamper.C
rigidBodyModel/rigidBodyModel.C
rigidBodyModel/forwardDynamics.C
......
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 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 "linearDamper.H"
#include "rigidBodyModel.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace restraints
{
defineTypeNameAndDebug(linearDamper, 0);
addToRunTimeSelectionTable
(
restraint,
linearDamper,
dictionary
);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::RBD::restraints::linearDamper::linearDamper
(
const word& name,
const dictionary& dict,
const rigidBodyModel& model
)
:
restraint(name, dict, model)
{
read(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::restraints::linearDamper::~linearDamper()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::spatialVector Foam::RBD::restraints::linearDamper::restrain() const
{
vector force = -coeff_*model_.v(model_.master(bodyID_)).l();
if (model_.debug)
{
Info<< " force " << force << endl;
}
return spatialVector(Zero, force);
}
bool Foam::RBD::restraints::linearDamper::read
(
const dictionary& dict
)
{
restraint::read(dict);
coeffs_.lookup("coeff") >> coeff_;
return true;
}
void Foam::RBD::restraints::linearDamper::write
(
Ostream& os
) const
{
restraint::write(os);
os.writeKeyword("coeff")
<< coeff_ << token::END_STATEMENT << nl;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::RBD::restraints::linearDamper
Description
Linear damper restraint. Operates in the local frame of the body.
SourceFiles
linearDamper.C
\*---------------------------------------------------------------------------*/
#ifndef RBD_restraints_linearDamper_H
#define RBD_restraints_linearDamper_H
#include "rigidBodyRestraint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace RBD
{
namespace restraints
{
/*---------------------------------------------------------------------------*\
Class linearDamper Declaration
\*---------------------------------------------------------------------------*/
class linearDamper
:
public restraint
{
// Private data
//- Damping coefficient [Ns/m]
scalar coeff_;
public:
//- Runtime type information
TypeName("linearDamper");
// Constructors
//- Construct from components
linearDamper
(
const word& name,
const dictionary& dict,
const rigidBodyModel& model
);
//- Construct and return a clone
virtual autoPtr<restraint> clone() const
{
return autoPtr<restraint>
(
new linearDamper(*this)
);
}
//- Destructor
virtual ~linearDamper();
// Member Functions
//- Return the external force applied to the body by this restraint
virtual spatialVector restrain() const;
//- Update properties from given dictionary
virtual bool read(const dictionary& dict);
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace restraints
} // End namespace RBD
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
......@@ -57,12 +57,7 @@ Foam::RBD::restraints::linearSpring::linearSpring
const rigidBodyModel& model
)
:
restraint(name, dict, model),
anchor_(),
refAttachmentPt_(),
stiffness_(),
damping_(),
restLength_()
restraint(name, dict, model)
{
read(dict);
}
......@@ -88,9 +83,16 @@ Foam::spatialVector Foam::RBD::restraints::linearSpring::restrain() const
// 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 - model_.X0(bodyIndex_).r()) ^ force;
// Force and moment on the master body including optional damping
vector force
(
(-stiffness_*(magR - restLength_) - damping_*(r & v))*r
);
vector moment
(
(attachmentPt - model_.X0(model_.master(bodyID_)).r()) ^ force
);
if (model_.debug)
{
......
......@@ -63,10 +63,10 @@ class linearSpring
//- Reference point of attachment to the solid body
point refAttachmentPt_;
//- Spring stiffness coefficient (N/m)
//- Spring stiffness coefficient [N/m]
scalar stiffness_;
//- Damping coefficient (Ns/m)
//- Damping coefficient [Ns/m]
scalar damping_;
//- Rest length - length of spring when no forces are applied to it
......
......@@ -48,7 +48,7 @@ Foam::RBD::restraint::restraint
)
:
name_(name),
bodyIndex_(model.bodyID(dict.lookup("body"))),
bodyID_(model.bodyID(dict.lookup("body"))),
coeffs_(dict),
model_(model)
{}
......@@ -80,7 +80,7 @@ void Foam::RBD::restraint::write(Ostream& os) const
os.writeKeyword("type")
<< type() << token::END_STATEMENT << nl;
os.writeKeyword("body")
<< model_.name(bodyIndex_) << token::END_STATEMENT << nl;
<< model_.name(bodyID_) << token::END_STATEMENT << nl;
}
......
......@@ -72,8 +72,8 @@ protected:
//- Name of the restraint
word name_;
//- Index of the body the restraint is applied to
label bodyIndex_;
//- ID of the body the restraint is applied to
label bodyID_;
//- Restraint model specific coefficient dictionary
dictionary coeffs_;
......@@ -148,9 +148,9 @@ public:
return name_;
}
label bodyIndex() const
label bodyID() const
{
return bodyIndex_;
return bodyID_;
}
//- Return the external force applied to the body by this restraint
......
......@@ -32,7 +32,7 @@ inline Foam::point Foam::RBD::restraint::bodyPoint
const point& p
) const
{
return (model_.X0(bodyIndex_).inv() && spatialVector(Zero, p)).l();
return (model_.X0(bodyID_).inv() && spatialVector(Zero, p)).l();
}
......@@ -41,7 +41,7 @@ inline Foam::spatialVector Foam::RBD::restraint::bodyPointVelocity
const point& p
) const
{
return model_.v(bodyIndex_, p);
return model_.v(bodyID_, p);
}
......
......@@ -40,7 +40,7 @@ void Foam::RBD::rigidBodyModel::applyRestraints(Field<spatialVector>& fx) const
DebugInfo << "Restraint " << restraints_[ri].name();
// Accumulate the restraint forces
fx[restraints_[ri].bodyIndex()] += restraints_[ri].restrain();
fx[master(restraints_[ri].bodyID())] += restraints_[ri].restrain();
}
}
......
......@@ -162,6 +162,12 @@ Foam::RBD::rigidBodyModel::rigidBodyModel(const dictionary& dict)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::RBD::rigidBodyModel::~rigidBodyModel()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::label Foam::RBD::rigidBodyModel::join_
......
......@@ -89,7 +89,6 @@ class rigidBodyModel
//- Add restraints to the motion
void addRestraints(const dictionary& dict);
protected:
// Protected data representing the model structure
......@@ -220,8 +219,7 @@ public:
//- Destructor
virtual ~rigidBodyModel()
{}
virtual ~rigidBodyModel();
// Member Functions
......@@ -261,6 +259,9 @@ public:
//- Return the inertia of body i
inline const rigidBodyInertia& I(const label i) const;
//- Return the spatial velocity of the bodies
inline const spatialVector& v(const label i) const;
//- Join the given body to the parent with ID parentID via the given
// joint with transform from the parent frame to the joint frame XT.
virtual label join
......
......@@ -99,6 +99,13 @@ Foam::RBD::rigidBodyModel::I(const label i) const
}
inline const Foam::spatialVector&
Foam::RBD::rigidBodyModel::v(const label i) const
{
return v_[i];
}
inline bool Foam::RBD::rigidBodyModel::merged(label bodyID) const
{
return bodyID < 0;
......
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