36 namespace sixDoFRigidBodyMotionRestraints
42 sixDoFRigidBodyMotionRestraint,
43 tabulatedAxialAngularSpring,
90 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)));
114 theta *=
sign((oldDir ^ newDir) & axis_);
118 if (convertToDegrees_)
124 moment = moment_(theta);
128 restraintMoment = moment*axis_ - damping_*(motion.
omega() & axis_)*axis_;
138 Info<<
" angle " << theta
139 <<
" moment " << restraintMoment
152 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
158 "Foam::sixDoFRigidBodyMotionRestraints::" 159 "tabulatedAxialAngularSpring::read" 161 "const dictionary& sDoFRBMRDict" 164 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 165 <<
"mag(referenceOrientation) - sqrt(3) = " 170 axis_ = sDoFRBMRCoeffs_.lookup(
"axis");
172 scalar magAxis(
mag(axis_));
174 if (magAxis > VSMALL)
182 "Foam::sixDoFRigidBodyMotionRestraints::" 183 "tabulatedAxialAngularSpring::read" 185 "const dictionary& sDoFRBMCDict" 188 <<
"axis has zero length" 194 const word angleFormat = sDoFRBMRCoeffs_.lookup(
"angleFormat");
196 if (angleFormat ==
"degrees" || angleFormat ==
"degree")
198 convertToDegrees_ =
true;
200 else if (angleFormat ==
"radians" || angleFormat ==
"radian")
202 convertToDegrees_ =
false;
208 "Foam::sixDoFRigidBodyMotionRestraints::" 209 "tabulatedAxialAngularSpring::read" 214 <<
"angleFormat must be degree, degrees, radian or radians" 218 sDoFRBMRCoeffs_.lookup(
"damping") >> damping_;
239 if (convertToDegrees_)
dimensionedScalar sqrt(const dimensionedScalar &ds)
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...
tabulatedAxialAngularSpring(const word &name, const dictionary &sDoFRBMRDict)
Construct from components.
addToRunTimeSelectionTable(sixDoFRigidBodyMotionRestraint, linearAxialAngularSpring, dictionary)
const double e
Elementary charge.
Ostream & endl(Ostream &os)
Add newline and flush stream.
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
scalar radToDeg(const scalar rad)
Conversion from radians to degrees.
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &sDoFRBMRDict)
Update properties from given dictionary.
Unit conversion functions.
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.
virtual void restrain(const sixDoFRigidBodyMotion &motion, vector &restraintPosition, vector &restraintForce, vector &restraintMoment) const
Calculate the restraint position, force and moment.
vector omega() const
Return the angular velocity in the global frame.
virtual bool read(const dictionary &sDoFRBMRCoeff)
Update properties from given dictionary.
3D tensor transformation operations.
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 &)
virtual ~tabulatedAxialAngularSpring()
Destructor.
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 > &)
const point & centreOfRotation() const
Return the current centre of rotation.