36 namespace sixDoFRigidBodyMotionRestraints
42 sixDoFRigidBodyMotionRestraint,
43 tabulatedAxialAngularSpring,
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_)
124 moment = moment_(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_;
218 if (convertToDegrees_)
tabulatedAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
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.
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.
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.
Vector< scalar > vector
A scalar version of the templated Vector.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
Macros for easy insertion into run-time selection tables.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
bool read(const char *, int32_t &)
virtual void write(Ostream &) const
Write.
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.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
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 ~tabulatedAxialAngularSpring()
Destructor.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.