54Foam::label Foam::sixDoFRigidBodyMotionConstraints::axis::rotationSector
60 const scalar thetaDir = (oldDir ^ newDir) & axis_;
62 if (
equal(thetaDir, 0))
67 return label(
sign(thetaDir));
71bool 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))));
172 const scalar t = motion().time().timeOutputValue();
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_);
constexpr scalar pi(M_PI)
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,...
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Accumulates point constraints through successive applications of the applyConstraint function.
void combine(const pointConstraint &)
Combine constraints.
Base class for defining constraints for sixDoF motions.
const word & name() const
Return the name.
dictionary sDoFRBMCCoeffs_
Constraint model specific coefficient dictionary.
sixDoFRigidBodyMotionConstraint(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Construct from the sDoFRBMCDict dictionary and Time.
const sixDoFRigidBodyMotion & motion() const noexcept
Return const access to motion.
virtual bool read(const dictionary &sDoFRBMCDict)
Update properties from given dictionary.
This constraint imposes an orientation limitation where bodies are restricted to rotate only around a...
virtual void write(Ostream &) const
Write.
virtual void constrainRotation(pointConstraint &) const
Apply and accumulate rotational constraints.
virtual bool read(const dictionary &sDoFRBMCCoeff)
Update properties from given dictionary.
axis(const word &name, const dictionary &sDoFRBMCDict, const sixDoFRigidBodyMotion &motion)
Construct from components.
virtual void constrainTranslation(pointConstraint &) const
Apply and accumulate translational constraints.
Orientation constraint: fixed in global space.
Six degree of freedom motion for a rigid body.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
Namespace for six DoF motion constraints.
bool read(const char *buf, int32_t &val)
Same as readInt32.
dimensionedScalar sign(const dimensionedScalar &ds)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
bool equal(const T &a, const T &b)
Compare two values for equality.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static const Identity< scalar > I
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
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.
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).
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
dimensionedScalar acos(const dimensionedScalar &ds)
constexpr char nl
The newline '\n' character (0x0a).
Unit conversion functions.