83 vector oldDir = refQ_ & refDir;
84 vector newDir = model_.X0(masterBodyIndex_).E() & refDir;
86 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
90 oldDir = refQ_ & refDir;
91 newDir = model_.X0(masterBodyIndex_).E() & refDir;
95 oldDir -= (axis_ & oldDir)*axis_;
96 oldDir /= (
mag(oldDir) + vSmall);
98 newDir -= (axis_ & newDir)*axis_;
99 newDir /= (
mag(newDir) + vSmall);
101 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
104 vector a = (oldDir ^ newDir);
107 a = (a & axis_)*axis_;
109 scalar magA =
mag(a);
125 + damping_*(model_.v(masterBodyIndex_).w() & a)
131 Info<<
" angle " << theta*
sign(a & axis_)
132 <<
" moment " << moment
137 fx[masterBodyIndex_] +=
138 model_.X0(masterBodyIndex_).
T()
150 refQ_ = coeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
155 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. "
156 <<
"mag(referenceOrientation) - sqrt(3) = "
161 axis_ = coeffs_.lookup(
"axis");
163 scalar magAxis(
mag(axis_));
165 if (magAxis > vSmall)
172 <<
"axis has zero length"
176 coeffs_.lookup(
"stiffness") >> stiffness_;
177 coeffs_.lookup(
"damping") >> damping_;
190 writeEntry(os,
"referenceOrientation", refQ_);
Macros for easy insertion into run-time selection tables.
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Base class for defining restraints for rigid-body dynamics.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void write(Ostream &) const =0
Write.
Linear axial angular spring restraint.
virtual ~linearAxialAngularSpring()
Destructor.
virtual void write(Ostream &) const
Write.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the retraint internal joint forces into the tau field and.
linearAxialAngularSpring(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
Holds the motion state of rigid-body model.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints.
A list of keyword definitions, which are a keyword followed by any number of values (e....
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
addToRunTimeSelectionTable(restraint, externalForce, dictionary)
defineTypeNameAndDebug(externalForce, 0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
dimensionedScalar sign(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
errorManip< error > abort(error &err)
static const Identity< scalar > I
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensionedScalar sqrt(const dimensionedScalar &ds)
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensionedScalar acos(const dimensionedScalar &ds)