43 linearAxialAngularSpring,
83 vector oldDir = refQ_ & refDir;
84 vector newDir = model_.X0(bodyID_).E() & refDir;
86 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
90 oldDir = refQ_ & refDir;
91 newDir = model_.X0(bodyID_).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(model_.master(bodyID_)).w() & a)
131 Info<<
" angle " << theta*
sign(a & axis_)
132 <<
" moment " << moment
148 refQ_ = coeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
153 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 154 <<
"mag(referenceOrientation) - sqrt(3) = " 159 axis_ = coeffs_.lookup(
"axis");
161 scalar magAxis(
mag(axis_));
163 if (magAxis > vSmall)
170 <<
"axis has zero length" 174 coeffs_.lookup(
"stiffness") >> stiffness_;
175 coeffs_.lookup(
"damping") >> damping_;
188 writeEntry(os,
"referenceOrientation", refQ_);
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
addToRunTimeSelectionTable(restraint, externalForce, dictionary)
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual ~linearAxialAngularSpring()
Destructor.
defineTypeNameAndDebug(externalForce, 0)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Base class for defining restraints for rigid-body dynamics.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Vector< scalar > vector
A scalar version of the templated Vector.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from unit vector n1 to n2.
Macros for easy insertion into run-time selection tables.
Holds the motion state of rigid-body model.
bool read(const char *, int32_t &)
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void write(Ostream &) const
Write.
static const Identity< scalar > I
A class for handling words, derived from string.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the retraint internal joint forces into the tau field and.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
virtual void write(Ostream &) const =0
Write.
linearAxialAngularSpring(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.