diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/sixDoFRigidBodyDisplacement/sixDoFRigidBodyDisplacementPointPatchVectorField.C index 559b3cc1752c890b2ce9682cfe50616b7f7bea01..3a6db8083995cdf1385fa5556c38d89d79742dc7 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 aaae3592221f01318d9c20ac01cb3f906f5d030a..bb66a5fb14b9d06eee60a94faf153370d27b9986 100644 --- a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C +++ b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.C @@ -47,7 +47,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(p, iF), motion_(), - initialPoints_(p.localPoints()) + initialPoints_(p.localPoints()), + curTimeIndex_(-1) {} @@ -60,7 +61,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField ) : fixedValuePointPatchField<vector>(p, iF, dict), - motion_(dict, dict) + motion_(dict, dict), + curTimeIndex_(-1) { if (!dict.found("value")) { @@ -89,7 +91,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(ptf, p, iF, mapper), motion_(ptf.motion_), - initialPoints_(ptf.initialPoints_, mapper) + initialPoints_(ptf.initialPoints_, mapper), + curTimeIndex_(-1) {} @@ -102,7 +105,8 @@ uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField : fixedValuePointPatchField<vector>(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<vector>::operator= diff --git a/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H b/src/sixDoFRigidBodyMotion/pointPatchFields/derived/uncoupledSixDoFRigidBodyDisplacement/uncoupledSixDoFRigidBodyDisplacementPointPatchVectorField.H index 3ffaf25bb52b897940ae5892c7deafab7a18ac4f..bd7538ad7127b2bb617c8562c88f07f4e5c67b88 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: