diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index 559b3cc175..3a6db80839 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -204,10 +204,10 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() const pointPatch& ptPatch = this->patch(); // Store the motion state at the beginning of the time-step - if (curTimeIndex_ != this->db().time().timeIndex()) + if (curTimeIndex_ != t.timeIndex()) { motion_.newTime(); - curTimeIndex_ = this->db().time().timeIndex(); + curTimeIndex_ = t.timeIndex(); } // Patch force data is valid for the current positions, so @@ -238,7 +238,7 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() g_ = g.value(); } - // scalar ramp = min(max((this->db().time().value() - 5)/10, 0), 1); + // scalar ramp = min(max((t.value() - 5)/10, 0), 1); scalar ramp = 1.0; motion_.updateAcceleration diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C index aaae359222..bb66a5fb14 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -47,7 +47,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField(p, iF), motion_(), - initialPoints_(p.localPoints()) + initialPoints_(p.localPoints()), + curTimeIndex_(-1) {} @@ -60,7 +61,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField ) : fixedValuePointPatchField(p, iF, dict), - motion_(dict, dict) + motion_(dict, dict), + curTimeIndex_(-1) { if (!dict.found("value")) { @@ -89,7 +91,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField(ptf, p, iF, mapper), motion_(ptf.motion_), - initialPoints_(ptf.initialPoints_, mapper) + initialPoints_(ptf.initialPoints_, mapper), + curTimeIndex_(-1) {} @@ -102,7 +105,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField(ptf, iF), motion_(ptf.motion_), - initialPoints_(ptf.initialPoints_) + initialPoints_(ptf.initialPoints_), + curTimeIndex_(-1) {} @@ -147,6 +151,13 @@ void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() const polyMesh& mesh = this->dimensionedInternalField().mesh()(); const Time& t = mesh.time(); + // Store the motion state at the beginning of the time-step + if (curTimeIndex_ != t.timeIndex()) + { + motion_.newTime(); + curTimeIndex_ = t.timeIndex(); + } + motion_.updatePosition(t.deltaTValue(), t.deltaT0Value()); vector gravity = vector::zero; @@ -163,7 +174,8 @@ void uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() motion_.updateAcceleration ( gravity*motion_.mass(), - vector::zero, t.deltaTValue() + vector::zero, + t.deltaTValue() ); Field::operator= diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H index 3ffaf25bb5..bd7538ad71 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H @@ -59,6 +59,9 @@ class uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField //- Initial positions of points on the patch pointField initialPoints_; + //- Current time index (used for updating) + label curTimeIndex_; + public: