35 namespace sixDoFRigidBodyMotionRestraints
41 sixDoFRigidBodyMotionRestraint,
42 linearAxialAngularSpring,
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_);
Six degree of freedom motion for a rigid body.
dimensionedScalar sign(const dimensionedScalar &ds)
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
dimensionedScalar acos(const dimensionedScalar &ds)
bool report() const
Return the report Switch.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const point & centreOfRotation() const
Return the current centre of rotation.
Base class for defining restraints for sixDoF motions.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< scalar > vector
A scalar version of the templated Vector.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
Macros for easy insertion into run-time selection tables.
defineTypeNameAndDebug(axialAngularSpring, 0)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, axialAngularSpring, dictionary)
bool read(const char *, int32_t &)
static const Identity< scalar > I
vector omega() const
Return the angular velocity in the global frame.
A class for handling words, derived from string.
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
const tensor & orientation() const
Return the orientation tensor, Q.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual void write(Ostream &) const
Write.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
virtual ~linearAxialAngularSpring()
Destructor.
linearAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.