38 if (restraints_.empty())
45 DebugInfo <<
"Restraint " << restraints_[ri].name();
48 restraints_[ri].restrain(tau, fx);
66 <<
"qDot = " << qDot <<
nl 67 <<
"tau = " << tau <<
endl;
74 for (
label i=1; i<nBodies(); i++)
76 const joint& jnt = joints()[i];
77 jnt.
jcalc(J, q, qDot);
82 Xlambda_[i] = J.
X & XT_[i];
84 const label lambdai = lambda_[i];
88 X0_[i] = Xlambda_[i] & X0_[lambdai];
95 v_[i] = (Xlambda_[i] & v_[lambdai]) + J.
v;
96 c_[i] = J.
c + (v_[i] ^ J.
v);
98 pA_[i] = v_[i] ^* (
I(i) & v_[i]);
102 pA_[i] -= *X0_[i] & fx[i];
106 for (
label i=nBodies()-1; i>0; i--)
108 const joint& jnt = joints()[i];
109 const label qi = jnt.qIndex();
113 U1_[i] = IA_[i] & S1_[i];
114 Dinv_[i].xx() = 1/(S1_[i] && U1_[i]);
115 u_[i].x() = tau[qi] - (S1_[i] && pA_[i]);
117 const label lambdai = lambda_[i];
123 IA_[i] - (U1_[i]*(Dinv_[i].xx()*U1_[i]))
128 pA_[i] + (Ia & c_[i]) + U1_[i]*(Dinv_[i].xx()*u_[i].
x())
136 pA_[lambdai] += Xlambda_[i].T() & pa;
141 U_[i] = IA_[i] & S_[i];
142 Dinv_[i] = (S_[i].T() & U_[i]).
inv();
146 const label lambdai = lambda_[i];
153 - (U_[i] & Dinv_[i] & U_[i].
T())
160 + (U_[i] & Dinv_[i] & u_[i])
168 pA_[lambdai] += Xlambda_[i].T() & pa;
175 for (
label i=1; i<nBodies(); i++)
177 const joint& jnt = joints()[i];
178 const label qi = jnt.qIndex();
180 a_[i] = (Xlambda_[i] & a_[lambda_[i]]) + c_[i];
184 qDdot[qi] = Dinv_[i].xx()*(u_[i].x() - (U1_[i] && a_[i]));
185 a_[i] += S1_[i]*qDdot[qi];
189 vector qDdoti(Dinv_[i] & (u_[i] - (U_[i].
T() & a_[i])));
192 qDdot[qi] = qDdoti.
x();
193 qDdot[qi+1] = qDdoti.
y();
194 qDdot[qi+2] = qDdoti.
z();
196 a_[i] += (S_[i] & qDdoti);
201 <<
"qDdot = " << qDdot <<
nl 202 <<
"a = " << a_ <<
endl;
223 for (
label i=1; i<nBodies(); i++)
225 const joint& jnt = joints()[i];
226 const label qi = jnt.qIndex();
228 jnt.
jcalc(J, q, qDot);
233 Xlambda_[i] = J.
X & XT_[i];
235 const label lambdai = lambda_[i];
239 X0_[i] = Xlambda_[i] & X0_[lambdai];
243 X0_[i] = Xlambda_[i];
246 v_[i] = (Xlambda_[i] & v_[lambdai]) + J.
v;
247 c_[i] = J.
c + (v_[i] ^ J.
v);
248 a_[i] = (Xlambda_[i] & a_[lambdai]) + c_[i];
252 a_[i] += S1_[i]*qDdot[qi];
Abstract base-class for all rigid-body joints.
Templated 3D spatial tensor derived from MatrixSpace used to represent transformations of spatial vec...
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void forwardDynamics(rigidBodyModelState &state, const scalarField &tau, const Field< spatialVector > &fx) const
Calculate the joint acceleration qDdot from the joint state q,.
void applyRestraints(scalarField &tau, Field< spatialVector > &fx) const
Apply the restraints and accumulate the internal joint forces.
spatialVector v
The constrained joint velocity.
spatialVector S1
The joint motion sub-space (1-DoF)
compactSpatialTensor S
The joint motion sub-space (3-DoF)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
spatialVector c
The constrained joint acceleration correction.
SpatialTensor< scalar > spatialTensor
SpatialTensor of scalars.
Holds the motion state of rigid-body model.
Joint state returned by jcalc.
static const Identity< scalar > I
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
#define DebugInFunction
Report an information message using Foam::Info.
VSForm block(const label start) const
label nDoF() const
Return the number of degrees of freedom in this joint.
#define DebugInfo
Report an information message using Foam::Info.
virtual void jcalc(XSvc &J, const scalarField &q, const scalarField &qDot) const =0
Update the rigidBodyModel state for the joint given.
spatialTransform X
The joint transformation.
const scalarField & q() const
Return access to the joint position and orientation.
const scalarField & qDot() const
Return access to the joint quaternion.
void forwardDynamicsCorrection(const rigidBodyModelState &state) const
Correct the velocity and acceleration of the bodies in the model.
const scalarField & qDdot() const
Return access to the joint acceleration.