35 namespace sixDoFRigidBodyMotionRestraints
88 vector oldDir = refQ_ & refDir;
91 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
96 oldDir = refQ_ & refDir;
101 oldDir -= (axis_ & oldDir)*axis_;
102 oldDir /= (
mag(oldDir) + VSMALL);
104 newDir -= (axis_ & newDir)*axis_;
105 newDir /= (
mag(newDir) + VSMALL);
107 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
110 vector a = (oldDir ^ newDir);
113 a = (a & axis_)*axis_;
115 scalar magA =
mag(a);
127 restraintMoment = -stiffness_*theta*a - damping_*(motion.
omega() & a)*a;
137 Info<<
" angle " << theta*
sign(a & axis_)
138 <<
" moment " << restraintMoment
151 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
157 "Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::" 160 "const dictionary& sDoFRBMRDict" 163 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 164 <<
"mag(referenceOrientation) - sqrt(3) = " 169 axis_ = sDoFRBMRCoeffs_.lookup(
"axis");
171 scalar magAxis(
mag(axis_));
173 if (magAxis > VSMALL)
181 "Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::" 184 "const dictionary& sDoFRBMCDict" 187 <<
"axis has zero length" 191 sDoFRBMRCoeffs_.lookup(
"stiffness") >> stiffness_;
192 sDoFRBMRCoeffs_.lookup(
"damping") >> damping_;
dimensionedScalar sqrt(const dimensionedScalar &ds)
linearAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
virtual void write(Ostream &) const
Write.
dimensioned< scalar > mag(const dimensioned< Type > &)
const tensor & orientation() const
Return the orientation tensor, Q.
static const sphericalTensor I(1)
A class for handling words, derived from string.
Base class for defining restraints for sixDoF motions.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar sign(const dimensionedScalar &ds)
bool report() const
Return the report Switch.
A list of keyword definitions, which are a keyword followed by any number of values (e...
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
virtual ~linearAxialAngularSpring()
Destructor.
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
dimensionedScalar acos(const dimensionedScalar &ds)
errorManip< error > abort(error &err)
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
vector omega() const
Return the angular velocity in the global frame.
3D tensor transformation operations.
sixDoFRigidBodyMotionRestraints model. Linear axial angular spring.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Vector< scalar > vector
A scalar version of the templated Vector.
bool read(const char *, int32_t &)
Six degree of freedom motion for a rigid body.
tensor rotationTensor(const vector &n1, const vector &n2)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
const point & centreOfRotation() const
Return the current centre of rotation.