36 namespace sixDoFRigidBodyMotionRestraints
90 vector oldDir = refQ_ & refDir;
94 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
99 oldDir = refQ_ & refDir;
104 oldDir -= (axis_ & oldDir)*axis_;
105 oldDir /= (
mag(oldDir) + vSmall);
107 newDir -= (axis_ & newDir)*axis_;
108 newDir /= (
mag(newDir) + vSmall);
110 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
114 theta *=
sign((oldDir ^ newDir) & axis_);
118 if (convertToDegrees_)
120 moment = moment_->value(
radToDeg(theta));
124 moment = moment_->value(theta);
128 restraintMoment = moment*axis_ - damping_*(motion.
omega() & axis_)*axis_;
130 restraintForce =
Zero;
138 Info<<
" angle " << theta
139 <<
" moment " << restraintMoment
152 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
157 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 158 <<
"mag(referenceOrientation) - sqrt(3) = " 163 axis_ = sDoFRBMRCoeffs_.lookup(
"axis");
165 scalar magAxis(
mag(axis_));
167 if (magAxis > vSmall)
174 <<
"axis has zero length" 180 const word angleFormat = sDoFRBMRCoeffs_.lookup(
"angleFormat");
182 if (angleFormat ==
"degrees" || angleFormat ==
"degree")
184 convertToDegrees_ =
true;
186 else if (angleFormat ==
"radians" || angleFormat ==
"radian")
188 convertToDegrees_ =
false;
193 <<
"angleFormat must be degree, degrees, radian or radians" 197 sDoFRBMRCoeffs_.lookup(
"damping") >> damping_;
208 writeEntry(os,
"referenceOrientation", refQ_);
216 if (convertToDegrees_)
Six degree of freedom motion for a rigid body.
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
bool report() const
Return the report Switch.
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
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.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
const point & centreOfRotation() const
Return the current centre of rotation.
Unit conversion functions.
Base class for defining restraints for sixDoF motions.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
axialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
Vector< scalar > vector
A scalar version of the templated Vector.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
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.
Axial angular spring with moment values obtained from a Function1 and linear damping.
defineTypeNameAndDebug(axialAngularSpring, 0)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, axialAngularSpring, dictionary)
bool read(const char *, int32_t &)
virtual ~axialAngularSpring()
Destructor.
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.
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< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
static autoPtr< Function1< Type > > New(const word &name, const dictionary &dict)
Selector.