Go to the documentation of this file.
39 namespace sixDoFRigidBodyMotionRestraints
45 sixDoFRigidBodyMotionRestraint,
46 tabulatedAxialAngularSpring,
93 vector oldDir = refQ_ & refDir;
97 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
102 oldDir = refQ_ & refDir;
107 oldDir -= (axis_ & oldDir)*axis_;
108 oldDir /= (
mag(oldDir) + VSMALL);
110 newDir -= (axis_ & newDir)*axis_;
111 newDir /= (
mag(newDir) + VSMALL);
113 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
117 theta *=
sign((oldDir ^ newDir) & axis_);
121 if (convertToDegrees_)
127 moment = moment_(theta);
131 restraintMoment = moment*axis_ - damping_*(motion.
omega() & axis_)*axis_;
133 restraintForce =
Zero;
141 Info<<
" angle " << theta
142 <<
" moment " << restraintMoment
155 refQ_ = sDoFRBMRCoeffs_.getOrDefault<
tensor>(
"referenceOrientation",
I);
160 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. "
161 <<
"mag(referenceOrientation) - sqrt(3) = "
166 sDoFRBMRCoeffs_.readEntry(
"axis", axis_);
168 scalar magAxis(
mag(axis_));
170 if (magAxis > VSMALL)
177 <<
"axis has zero length"
183 const word angleFormat(sDoFRBMRCoeffs_.get<
word>(
"angleFormat"));
185 if (angleFormat ==
"degrees" || angleFormat ==
"degree")
187 convertToDegrees_ =
true;
189 else if (angleFormat ==
"radians" || angleFormat ==
"radian")
191 convertToDegrees_ =
false;
196 <<
"angleFormat must be degree, degrees, radian or radians"
200 sDoFRBMRCoeffs_.readEntry(
"damping", damping_);
211 os.writeEntry(
"referenceOrientation", refQ_);
212 os.writeEntry(
"axis", axis_);
216 if (convertToDegrees_)
218 os.writeEntry(
"angleFormat",
"degrees");
222 os.writeEntry(
"angleFormat",
"radians");
225 os.writeEntry(
"damping", damping_);
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
virtual void write(Ostream &) const
Write.
A class for handling words, derived from Foam::string.
static constexpr const zero Zero
Global zero (0)
const tensor & orientation() const
Return the orientation tensor, Q.
virtual ~tabulatedAxialAngularSpring()
Destructor.
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sign(const dimensionedScalar &ds)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
const point & centreOfRotation() const
Return the current centre of rotation.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Base class for defining restraints for sixDoF motions.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Macros for easy insertion into run-time selection tables.
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
errorManipArg< error, int > exit(error &err, const int errNo=1)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Six degree of freedom motion for a rigid body.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
bool report() const
Return the report Switch.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
vector omega() const
Return the angular velocity in the global frame.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
static const Identity< scalar > I
tabulatedAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.