46 linearAxialAngularSpring,
86 vector oldDir = refQ_ & refDir;
87 vector newDir = model_.X0(bodyID_).E() & refDir;
89 if (
mag(oldDir & axis_) > 0.95 ||
mag(newDir & axis_) > 0.95)
93 oldDir = refQ_ & refDir;
94 newDir = model_.X0(bodyID_).E() & refDir;
98 oldDir -= (axis_ & oldDir)*axis_;
99 oldDir /= (
mag(oldDir) + VSMALL);
101 newDir -= (axis_ & newDir)*axis_;
102 newDir /= (
mag(newDir) + VSMALL);
104 scalar theta =
mag(
acos(
min(oldDir & newDir, 1.0)));
107 vector a = (oldDir ^ newDir);
110 a = (a & axis_)*axis_;
112 scalar magA =
mag(a);
128 + damping_*(model_.v(model_.master(bodyID_)).w() & a)
134 Info<<
" angle " << theta*
sign(a & axis_)
135 <<
" moment " << moment
151 refQ_ = coeffs_.getOrDefault<
tensor>(
"referenceOrientation",
I);
156 <<
"referenceOrientation " << refQ_ <<
" is not a rotation tensor. " 157 <<
"mag(referenceOrientation) - sqrt(3) = " 162 coeffs_.readEntry(
"axis", axis_);
164 const scalar magAxis(
mag(axis_));
166 if (magAxis > VSMALL)
173 <<
"axis has zero length" 177 coeffs_.readEntry(
"stiffness", stiffness_);
178 coeffs_.readEntry(
"damping", damping_);
191 os.writeEntry(
"referenceOrientation", refQ_);
192 os.writeEntry(
"axis", axis_);
193 os.writeEntry(
"stiffness", stiffness_);
194 os.writeEntry(
"damping", damping_);
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.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
defineTypeNameAndDebug(externalForce, 0)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Base class for defining restraints for rigid-body dynamics.
constexpr char nl
The newline '\n' character (0x0a)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
Holds the motion state of rigid-body model.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
virtual void write(Ostream &) const
Write.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
static const Identity< scalar > I
A class for handling words, derived from Foam::string.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
virtual void restrain(scalarField &tau, Field< spatialVector > &fx, const rigidBodyModelState &state) const
Accumulate the restraint internal joint forces into the tau field and.
messageStream Info
Information stream (stdout output on master, null elsewhere)
tmp< Field< Type > > T() const
Return the field transpose (only defined for second rank tensors)
Basic rigid-body model representing a system of rigid-bodies connected by 1-6 DoF joints...
virtual void write(Ostream &) const =0
Write.
Tensor of scalars, i.e. Tensor<scalar>.
linearAxialAngularSpring(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from components.
static constexpr const zero Zero
Global zero (0)