82 vector oldDir = refQ_ & refDir;
83 vector newDir = model_.X0(bodyID_).E() & refDir;
85 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
89 oldDir = refQ_ & refDir;
90 newDir = model_.X0(bodyID_).E() & refDir;
94 oldDir -= (axis_ & oldDir)*axis_;
95 oldDir /= (
mag(oldDir) + vSmall);
97 newDir -= (axis_ & newDir)*axis_;
98 newDir /= (
mag(newDir) + vSmall);
100 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
103 vector a = (oldDir ^ newDir);
106 a = (a & axis_)*axis_;
108 scalar magA =
mag(a);
124 + damping_*(model_.v(model_.master(bodyID_)).w() & a)
130 Info<<
" angle " << theta*
sign(a & axis_)
131 <<
" moment " << moment
147 refQ_ = coeffs_.lookupOrDefault<
tensor>(
"referenceOrientation",
I);
152 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 153 <<
"mag(referenceOrientation) - sqrt(3) = " 158 axis_ = coeffs_.lookup(
"axis");
160 scalar magAxis(
mag(axis_));
162 if (magAxis > vSmall)
169 <<
"axis has zero length" 173 coeffs_.lookup(
"stiffness") >> stiffness_;
174 coeffs_.lookup(
"damping") >> damping_;
dimensionedScalar sign(const dimensionedScalar &ds)
dimensionedScalar acos(const dimensionedScalar &ds)
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual ~linearAxialAngularSpring()
Destructor.
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 vector n1 to n2.
Macros for easy insertion into run-time selection tables.
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)
virtual void restrain(scalarField &tau, Field< spatialVector > &fx) const
Accumulate the retraint internal joint forces into the tau field and.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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 > &)
defineTypeNameAndDebug(linearAxialAngularSpring, 0)
Linear axial angular spring restraint.
const doubleScalar e
Elementary charge.
addToRunTimeSelectionTable(restraint, linearAxialAngularSpring, dictionary)
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.