38 namespace sixDoFRigidBodyMotionConstraints
54 Foam::label Foam::sixDoFRigidBodyMotionConstraints::axis::rotationSector
60 const scalar thetaDir = (oldDir ^ newDir) & axis_;
62 if (
equal(thetaDir, 0))
67 return label(
sign(thetaDir));
71 bool Foam::sixDoFRigidBodyMotionConstraints::axis::calcDir
74 const bool rotationSector
77 const scalar fmDir = axis_ & fm;
81 return rotationSector;
84 return (label(
sign(fmDir)) == 1) ? true :
false;
122 if (!(maxCWThetaPtr_ && maxCCWThetaPtr_))
136 (refQ_ & refDir).removeCollinear(axis_).normalise()
140 (motion().orientation() & refDir).removeCollinear(axis_).normalise()
145 const label rotationSectorIndex = rotationSector(oldDir, newDir);
147 if (!rotationSectorIndex)
154 const bool rotationSector = (rotationSectorIndex == 1) ?
true :
false;
158 const bool angularMomentumDir =
161 motion().state().
pi(),
164 const bool torqueDir = calcDir(motion().state().tau(), rotationSector);
168 const scalar theta =
mag(
acos(
min(oldDir & newDir, scalar(1))));
173 const scalar maxCWTheta =
176 :
mag(maxCWThetaPtr_->value(t));
178 const scalar maxCCWTheta =
181 :
mag(maxCCWThetaPtr_->value(t));
187 (rotationSector && (theta < maxCCWTheta))
188 || (!rotationSector && (theta < maxCWTheta))
191 pc.
combine(pointConstraint(Tuple2<label, vector>(2, axis_)));
195 if (rotationSector == angularMomentumDir)
197 const scalar magPi =
mag(motion().state().
pi());
199 if (
equal(magPi, scalar(0)) && rotationSector != torqueDir)
201 pc.
combine(pointConstraint(Tuple2<label, vector>(2, axis_)));
206 pc.
combine(pointConstraint(Tuple2<label, vector>(3,
Zero)));
213 pc.
combine(pointConstraint(Tuple2<label, vector>(2, axis_)));
218 if (motion().report())
221 <<
" old direction = " << oldDir <<
nl 222 <<
" new direction = " << newDir <<
nl 223 <<
" rotationSector = " << rotationSector <<
nl 224 <<
" theta = " <<
sign((oldDir ^ newDir) & axis_)*theta <<
nl 225 <<
" torque = " << motion().
state().
tau() <<
nl 226 <<
" torque dir = " << torqueDir <<
nl 227 <<
" angular momentum = " << motion().
state().
pi() <<
nl 228 <<
" angular momentum dir = " << angularMomentumDir <<
nl 244 sDoFRBMCCoeffs_.readEntry(
"axis", axis_);
248 if (
mag(axis_) < VSMALL)
251 <<
"The entry 'axis' cannot have zero length: " << axis_
256 if (sDoFRBMCCoeffs_.found(
"thetaUnits"))
258 const word thetaUnits(sDoFRBMCCoeffs_.getWord(
"thetaUnits"));
260 if (thetaUnits ==
"degrees")
264 else if (thetaUnits ==
"radians")
271 <<
"The units of thetaUnits can be either degrees or radians" 278 Function1<scalar>::New
286 maxCCWThetaPtr_.reset
288 Function1<scalar>::New
290 "maxCounterclockwiseTheta",
298 sDoFRBMCCoeffs_.getOrDefault<
tensor>(
"referenceOrientation",
I);
303 <<
"The entry 'referenceOrientation' " << refQ_
304 <<
" is not a rotation tensor. " 305 <<
"mag(referenceOrientation) - sqrt(3) = " 320 os.writeEntry(
"axis", axis_);
323 if (maxCWThetaPtr_ && maxCCWThetaPtr_)
327 os.writeEntry(
"thetaUnits",
"degrees");
331 os.writeEntry(
"thetaUnits",
"radians");
336 maxCWThetaPtr_->writeData(
os);
341 maxCCWThetaPtr_->writeData(
os);
344 os.writeEntry(
"referenceOrientation", refQ_);
Six degree of freedom motion for a rigid body.
virtual void write(Ostream &) const
Write.
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool equal(const T &a, const T &b)
Compare two values for equality.
Unit conversion functions.
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
addToRunTimeSelectionTable(sixDoFRigidBodyMotionConstraint, axis, dictionary)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
void combine(const pointConstraint &)
Combine constraints.
const vector & tau() const
Return access to torque.
Base class for defining constraints for sixDoF motions.
Macros for easy insertion into run-time selection tables.
const sixDoFRigidBodyMotionState & state() const
Return the motion state.
This constraint imposes an orientation limitation where bodies are restricted to rotate only around a...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
static const Identity< scalar > I
A class for handling words, derived from Foam::string.
const vector & pi() const
Return access to angular momentum.
virtual bool read(const dictionary &sDoFRBMCCoeff)
Update properties from given dictionary.
constexpr scalar pi(M_PI)
Accumulates point constraints through successive applications of the applyConstraint function...
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual bool read(const dictionary &sDoFRBMCDict)
Update properties from given dictionary.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
axis(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Construct from components.
virtual void constrainTranslation(pointConstraint &) const
Apply and accumulate translational constraints.
const Time & time() const
Return time.
scalar timeOutputValue() const
Return current time value.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
messageStream Info
Information stream (stdout output on master, null elsewhere)
virtual void constrainRotation(pointConstraint &) const
Apply and accumulate rotational constraints.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
defineTypeNameAndDebug(axis, 0)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)