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" 181 moment_ = interpolationTable<scalar>(sDoFRBMRCoeffs_);
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_);
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const point & centreOfRotation() const
Return the current centre of rotation.
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
Base class for defining restraints for sixDoF motions.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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 Foam::string.
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
const tensor & orientation() const
Return the orientation tensor, Q.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
virtual ~tabulatedAxialAngularSpring()
Destructor.
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
constexpr scalar radToDeg(const scalar rad) noexcept
Conversion from radians to degrees.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
Tensor of scalars, i.e. Tensor<scalar>.
static constexpr const zero Zero
Global zero (0)