38namespace sixDoFRigidBodyMotionRestraints
54Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::
55linearAxialAngularSpring
91 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)));
113 vector a = (oldDir ^ newDir);
116 a = (a & axis_)*axis_;
118 scalar magA =
mag(a);
130 restraintMoment = -stiffness_*theta*a - damping_*(motion.
omega() & a)*a;
132 restraintForce =
Zero;
140 Info<<
" angle " << theta*
sign(a & axis_)
141 <<
" moment " << restraintMoment
154 refQ_ = sDoFRBMRCoeffs_.getOrDefault<
tensor>(
"referenceOrientation",
I);
159 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. "
160 <<
"mag(referenceOrientation) - sqrt(3) = "
165 sDoFRBMRCoeffs_.readEntry(
"axis", axis_);
167 const scalar magAxis(
mag(axis_));
169 if (magAxis > VSMALL)
176 <<
"axis has zero length"
180 sDoFRBMRCoeffs_.readEntry(
"stiffness", stiffness_);
181 sDoFRBMRCoeffs_.readEntry(
"damping", damping_);
192 os.writeEntry(
"referenceOrientation", refQ_);
193 os.writeEntry(
"axis", axis_);
194 os.writeEntry(
"stiffness", stiffness_);
195 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.
Base class for defining restraints for sixDoF motions.
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
virtual ~linearAxialAngularSpring()
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)
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)