38 namespace sixDoFRigidBodyMotionRestraints
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_);
Six degree of freedom motion for a rigid body.
dimensionedScalar sign(const dimensionedScalar &ds)
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
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.
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
constexpr char nl
The newline '\n' character (0x0a)
Base class for defining restraints for sixDoF motions.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
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 void write(Ostream &) const
Write.
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual ~linearAxialAngularSpring()
Destructor.
linearAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
Tensor of scalars, i.e. Tensor<scalar>.
static constexpr const zero Zero
Global zero (0)