35 namespace sixDoFRigidBodyMotionRestraints
88 vector oldDir = refQ_ & refDir;
91 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
96 oldDir = refQ_ & refDir;
101 oldDir -= (axis_ & oldDir)*axis_;
102 oldDir /= (
mag(oldDir) + vSmall);
104 newDir -= (axis_ & newDir)*axis_;
105 newDir /= (
mag(newDir) + vSmall);
107 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
110 vector a = (oldDir ^ newDir);
113 a = (a & axis_)*axis_;
115 scalar magA =
mag(a);
127 restraintMoment = -stiffness_*theta*a - damping_*(motion.
omega() & a)*a;
129 restraintForce =
Zero;
137 Info<<
" angle " << theta*
sign(a & axis_)
138 <<
" moment " << restraintMoment
151 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
156 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. "
157 <<
"mag(referenceOrientation) - sqrt(3) = "
162 axis_ = sDoFRBMRCoeffs_.lookup(
"axis");
164 scalar magAxis(
mag(axis_));
166 if (magAxis > vSmall)
173 <<
"axis has zero length"
177 sDoFRBMRCoeffs_.lookup(
"stiffness") >> stiffness_;
178 sDoFRBMRCoeffs_.lookup(
"damping") >> damping_;
189 writeEntry(os,
"referenceOrientation", refQ_);
Macros for easy insertion into run-time selection tables.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keyword definitions, which are a keyword followed by any number of values (e....
Base class for defining restraints for sixDoF motions.
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
virtual ~linearAxialAngularSpring()
Destructor.
virtual void write(Ostream &) const
Write.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
linearAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
Six degree of freedom motion for a rigid body.
bool report() const
Return the report Switch.
const tensor & orientation() const
Return the orientation tensor, Q.
vector omega() const
Return the angular velocity in the global frame.
const point & centreOfRotation() const
Return the current centre of rotation.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
defineTypeNameAndDebug(axialAngularSpring, 0)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, axialAngularSpring, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
dimensionedScalar sign(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
static const Identity< scalar > I
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar acos(const dimensionedScalar &ds)