38 if (restraints_.empty())
45 DebugInfo <<
"Restraint " << restraints_[ri].name();
48 restraints_[ri].restrain(tau, fx);
63 <<
"q = " << state.
q() <<
nl 64 <<
"qDot = " << state.
qDot() <<
nl 65 <<
"tau = " << tau <<
endl;
72 for (
label i=1; i<nBodies(); i++)
74 const joint& jnt = joints()[i];
80 Xlambda_[i] = J.
X & XT_[i];
82 const label lambdai = lambda_[i];
86 X0_[i] = Xlambda_[i] & X0_[lambdai];
93 v_[i] = (Xlambda_[i] & v_[lambdai]) + J.
v;
94 c_[i] = J.
c + (v_[i] ^ J.
v);
96 pA_[i] = v_[i] ^* (
I(i) & v_[i]);
100 pA_[i] -= *X0_[i] & fx[i];
104 for (
label i=nBodies()-1; i>0; i--)
106 const joint& jnt = joints()[i];
107 const label qi = jnt.qIndex();
114 const label lambdai = lambda_[i];
127 pA_[lambdai] += Xlambda_[i].T() & pa;
130 else if (jnt.
nDoF() == 1)
132 U1_[i] = IA_[i] & S1_[i];
133 Dinv_[i].xx() = 1/(S1_[i] && U1_[i]);
134 u_[i].x() = tau[qi] - (S1_[i] && pA_[i]);
136 const label lambdai = lambda_[i];
142 IA_[i] - (U1_[i]*(Dinv_[i].xx()*U1_[i]))
147 pA_[i] + (Ia & c_[i]) + U1_[i]*(Dinv_[i].xx()*u_[i].
x())
155 pA_[lambdai] += Xlambda_[i].T() & pa;
160 U_[i] = IA_[i] & S_[i];
161 Dinv_[i] = (S_[i].T() & U_[i]).
inv();
164 const label lambdai = lambda_[i];
170 IA_[i] - (U_[i] & Dinv_[i] & U_[i].
T())
175 pA_[i] + (Ia & c_[i]) + (U_[i] & Dinv_[i] & u_[i])
183 pA_[lambdai] += Xlambda_[i].T() & pa;
190 for (
label i=1; i<nBodies(); i++)
192 const joint& jnt = joints()[i];
193 const label qi = jnt.qIndex();
195 a_[i] = (Xlambda_[i] & a_[lambda_[i]]) + c_[i];
201 else if (jnt.
nDoF() == 1)
203 qDdot[qi] = Dinv_[i].xx()*(u_[i].x() - (U1_[i] && a_[i]));
204 a_[i] += S1_[i]*qDdot[qi];
208 vector qDdoti(Dinv_[i] & (u_[i] - (U_[i].
T() & a_[i])));
211 qDdot[qi] = qDdoti.
x();
212 qDdot[qi+1] = qDdoti.
y();
213 qDdot[qi+2] = qDdoti.
z();
215 a_[i] += (S_[i] & qDdoti);
220 <<
"qDdot = " << qDdot <<
nl 221 <<
"a = " << a_ <<
endl;
240 for (
label i=1; i<nBodies(); i++)
242 const joint& jnt = joints()[i];
243 const label qi = jnt.qIndex();
250 Xlambda_[i] = J.
X & XT_[i];
252 const label lambdai = lambda_[i];
256 X0_[i] = Xlambda_[i] & X0_[lambdai];
260 X0_[i] = Xlambda_[i];
263 v_[i] = (Xlambda_[i] & v_[lambdai]) + J.
v;
264 c_[i] = J.
c + (v_[i] ^ J.
v);
265 a_[i] = (Xlambda_[i] & a_[lambdai]) + c_[i];
271 else if (jnt.
nDoF() == 1)
273 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.
spatialVector v
The constrained joint velocity.
spatialVector S1
The joint motion sub-space (1-DoF)
void forwardDynamicsCorrection(const rigidBodyModelState &state) const
Correct the velocity and acceleration of the bodies in the model.
compactSpatialTensor S
The joint motion sub-space (3-DoF)
virtual void jcalc(XSvc &J, const rigidBodyModelState &state) const =0
Update the rigidBodyModel state for the joint given.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
void size(const label)
Override size to be inconsistent with allocated storage.
void applyRestraints(scalarField &tau, Field< spatialVector > &fx) const
Apply the restraints and accumulate the internal joint forces.
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
const scalarField & q() const
Return access to the joint position and orientation.
SpatialVector< scalar > spatialVector
SpatialVector of scalars.
#define DebugInFunction
Report an information message using Foam::Info.
const scalarField & qDot() const
Return access to the joint velocity.
VSForm block(const label start) const
#define DebugInfo
Report an information message using Foam::Info.
label nDoF() const
Return the number of degrees of freedom in this joint.
spatialTransform X
The joint transformation.
const scalarField & qDdot() const
Return access to the joint acceleration.
void forwardDynamics(rigidBodyModelState &state, const scalarField &tau, const Field< spatialVector > &fx) const
Calculate the joint acceleration qDdot from the joint state q,.