39namespace sixDoFRigidBodyMotionRestraints
55Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::
56tabulatedAxialAngularSpring
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_);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual bool write()
Write the output fields.
An interpolation/look-up table of scalar vs <Type> values. The reference scalar values must be monoto...
Base class for defining restraints for sixDoF motions.
sixDoFRigidBodyMotionRestraints model. Axial angular spring with moment values drawn from an interpol...
virtual ~tabulatedAxialAngularSpring()
Destructor.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
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 Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
dimensionedScalar sign(const dimensionedScalar &ds)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static const Identity< scalar > I
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
constexpr scalar radToDeg() noexcept
Multiplication factor for radians to degrees conversion.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar acos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a)
Unit conversion functions.