60 const rigidBodyModel& model
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"
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_);
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
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.
label bodyID_
ID of the body the restraint is applied to.
restraint(const word &name, const dictionary &dict, const rigidBodyModel &model)
Construct from the dict dictionary and Time.
const word & name() const
Return the name.
label bodyIndex_
Index of the body the force is applied to.
virtual bool read(const dictionary &dict)
Update properties from given dictionary.
dictionary coeffs_
Restraint model specific coefficient dictionary.
virtual void write(Ostream &) const =0
Write.
const rigidBodyModel & model_
Reference to the model.
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 restraint 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 a number of values (eg,...
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 FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Namespace for rigid-body dynamics restraints.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
dimensionedScalar sign(const dimensionedScalar &ds)
tensor rotationTensor(const vector &n1, const vector &n2)
Rotational transformation tensor from vector n1 to n2.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static const Identity< scalar > I
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
errorManip< error > abort(error &err)
static constexpr const zero Zero
Global zero (0).
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
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).