mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENC: sixDoFRigidBodyMotion. Adding linearAxialAngularSpring restraint.
This commit is contained in:
@ -17,6 +17,7 @@ $(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/sixDoFRigidBodyMotionRestraint.C
|
||||
$(sDoFRBMR)/sixDoFRigidBodyMotionRestraint/newSixDoFRigidBodyMotionRestraint.C
|
||||
$(sDoFRBMR)/linearSpring/linearSpring.C
|
||||
$(sDoFRBMR)/sphericalAngularSpring/sphericalAngularSpring.C
|
||||
$(sDoFRBMR)/linearAxialAngularSpring/linearAxialAngularSpring.C
|
||||
|
||||
sDoFRBMC = $(sDoFRBM)/sixDoFRigidBodyMotionConstraint
|
||||
|
||||
|
||||
@ -139,7 +139,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain
|
||||
constraintMomentIncrement +=
|
||||
-relaxationFactor_
|
||||
*theta*axis
|
||||
*motion.momentOfInertia()[cmpt]/sqr(deltaT);
|
||||
*motion.momentOfInertia()[cmpt]/sqr(deltaT);
|
||||
}
|
||||
|
||||
constraintPosition = motion.centreOfMass();
|
||||
|
||||
@ -64,6 +64,7 @@ class fixedOrientation
|
||||
//- Reference orientation where there is no moment
|
||||
tensor fixedOrientation_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
@ -0,0 +1,193 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "linearAxialAngularSpring.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "sixDoFRigidBodyMotion.H"
|
||||
#include "transform.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
defineTypeNameAndDebug(linearAxialAngularSpring, 0);
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
sixDoFRigidBodyMotionRestraint,
|
||||
linearAxialAngularSpring,
|
||||
dictionary
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::
|
||||
linearAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
:
|
||||
sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
|
||||
refQ_(),
|
||||
axis_(),
|
||||
stiffness_(),
|
||||
damping_()
|
||||
{
|
||||
read(sDoFRBMRDict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::
|
||||
~linearAxialAngularSpring()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||
|
||||
void
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const
|
||||
{
|
||||
vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0);
|
||||
|
||||
vector oldDir = refQ_ & refDir;
|
||||
|
||||
vector newDir = motion.currentOrientation(refDir);
|
||||
|
||||
if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95)
|
||||
{
|
||||
// Directions getting close to the axis, change reference
|
||||
|
||||
refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1);
|
||||
|
||||
vector oldDir = refQ_ & refDir;
|
||||
|
||||
vector newDir = motion.currentOrientation(refDir);
|
||||
}
|
||||
|
||||
// Removing any axis component from oldDir and newDir and normalising
|
||||
oldDir -= (axis_ & oldDir)*axis_;
|
||||
oldDir /= mag(oldDir);
|
||||
|
||||
newDir -= (axis_ & newDir)*axis_;
|
||||
newDir /= mag(newDir);
|
||||
|
||||
scalar theta = mag(acos(oldDir & newDir));
|
||||
|
||||
// Temporary axis with sign information.
|
||||
vector a = (oldDir ^ newDir);
|
||||
|
||||
// Remove any component that is not along axis that may creep in
|
||||
a = (a & axis_)*axis_;
|
||||
|
||||
scalar magA = mag(a);
|
||||
|
||||
if (magA > VSMALL)
|
||||
{
|
||||
a /= magA;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = vector::zero;
|
||||
}
|
||||
|
||||
// Damping of along axis angular velocity only
|
||||
restraintMoment = -stiffness_*theta*a - damping_*(motion.omega() & a)*a;
|
||||
|
||||
restraintForce = vector::zero;
|
||||
|
||||
// Not needed to be altered as restraintForce is zero, but set to
|
||||
// centreOfMass to be sure of no spurious moment
|
||||
restraintPosition = motion.centreOfMass();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::read
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
)
|
||||
{
|
||||
sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
|
||||
|
||||
refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<tensor>("referenceOrientation", I);
|
||||
|
||||
if (mag(mag(refQ_) - sqrt(3.0)) > 1e-9)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
")"
|
||||
)
|
||||
<< "referenceOrientation " << refQ_ << " is not a rotation tensor. "
|
||||
<< "mag(referenceOrientation) - sqrt(3) = "
|
||||
<< mag(refQ_) - sqrt(3.0) << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
axis_ = sDoFRBMRCoeffs_.lookup("axis");
|
||||
|
||||
scalar magAxis(mag(axis_));
|
||||
|
||||
if (magAxis > VSMALL)
|
||||
{
|
||||
axis_ /= magAxis;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMCDict"
|
||||
")"
|
||||
)
|
||||
<< "axis has zero length"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
|
||||
|
||||
sDoFRBMRCoeffs_.lookup("damping") >> damping_;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,129 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
|
||||
\\/ 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 2 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, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring
|
||||
|
||||
Description
|
||||
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
|
||||
|
||||
SourceFiles
|
||||
linearAxialAngularSpring.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef linearAxialAngularSpring_H
|
||||
#define linearAxialAngularSpring_H
|
||||
|
||||
#include "sixDoFRigidBodyMotionRestraint.H"
|
||||
#include "point.H"
|
||||
#include "tensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
namespace sixDoFRigidBodyMotionRestraints
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class linearAxialAngularSpring Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class linearAxialAngularSpring
|
||||
:
|
||||
public sixDoFRigidBodyMotionRestraint
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference orientation where there is no moment
|
||||
tensor refQ_;
|
||||
|
||||
//- Global unit axis around which the motion is sprung
|
||||
vector axis_;
|
||||
|
||||
//- Spring stiffness coefficient (Nm/rad)
|
||||
scalar stiffness_;
|
||||
|
||||
//- Damping coefficient (Nms/rad)
|
||||
scalar damping_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("linearAxialAngularSpring");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
linearAxialAngularSpring
|
||||
(
|
||||
const dictionary& sDoFRBMRDict
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual autoPtr<sixDoFRigidBodyMotionRestraint> clone() const
|
||||
{
|
||||
return autoPtr<sixDoFRigidBodyMotionRestraint>
|
||||
(
|
||||
new linearAxialAngularSpring(*this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~linearAxialAngularSpring();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Calculate the restraint position, force and moment.
|
||||
// Global reference frame vectors.
|
||||
virtual void restrain
|
||||
(
|
||||
const sixDoFRigidBodyMotion& motion,
|
||||
vector& restraintPosition,
|
||||
vector& restraintForce,
|
||||
vector& restraintMoment
|
||||
) const;
|
||||
|
||||
//- Update properties from given dictionary
|
||||
virtual bool read(const dictionary& sDoFRBMRCoeff);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace solidBodyMotionFunctions
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -126,7 +126,7 @@ bool Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::read
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::sixDoFRigidBodyMotionConstraints::sphericalAngularSpring::"
|
||||
"Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::"
|
||||
"read"
|
||||
"("
|
||||
"const dictionary& sDoFRBMRDict"
|
||||
|
||||
Reference in New Issue
Block a user