35 namespace sixDoFRigidBodyMotionRestraints
85 vector oldDir = refQ_ & refDir;
89 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
94 oldDir = refQ_ & refDir;
99 oldDir -= (axis_ & oldDir)*axis_;
100 oldDir /= (
mag(oldDir) + vSmall);
102 newDir -= (axis_ & newDir)*axis_;
103 newDir /= (
mag(newDir) + vSmall);
105 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
109 theta *=
sign((oldDir ^ newDir) & axis_);
111 const scalar moment = moment_->value(theta);
114 restraintMoment = moment*axis_ - damping_*(motion.
omega() & axis_)*axis_;
116 restraintForce =
Zero;
124 Info<<
" angle " << theta
125 <<
" moment " << restraintMoment
138 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
143 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. "
144 <<
"mag(referenceOrientation) - sqrt(3) = "
149 axis_ = sDoFRBMRCoeffs_.lookup(
"axis");
151 scalar magAxis(
mag(axis_));
153 if (magAxis > vSmall)
160 <<
"axis has zero length"
175 sDoFRBMRCoeffs_.found(
"angleUnits")
176 || sDoFRBMRCoeffs_.found(
"angleFormat")
180 <<
"Angle units are no longer specified with 'angleUnits' or "
181 <<
"'angleFormat' entries. Instead, parameters of the 'moment' "
182 <<
"function can have their units specified directly."
186 sDoFRBMRCoeffs_.lookup(
"damping") >> damping_;
197 writeEntry(os,
"referenceOrientation", refQ_);
Macros for easy insertion into run-time selection tables.
static autoPtr< Function1< Type > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
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.
Axial angular spring with moment values obtained from a Function1 and linear damping.
virtual void write(Ostream &) const
Write.
virtual ~axialAngularSpring()
Destructor.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
axialAngularSpring(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 FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#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)
const dimensionSet dimLength
static const Identity< scalar > I
const dimensionSet dimForce
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 > &)
const unitConversion unitRadians
dimensionedScalar acos(const dimensionedScalar &ds)