View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003345 | OpenFOAM | Bug | public | 2019-09-10 10:24 | 2019-10-02 15:06 |
Reporter | handrake0724 | Assigned To | henry | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Product Version | dev | ||||
Fixed in Version | dev | ||||
Summary | 0003345: suggestion of including time information in restraint class in sixDoFRigidBodyMotion and rigidBodyDynamics | ||||
Description | In simulating 6 DoF motion, sometimes it comes in handy when time varying external forces to the body are available. for example, step function-like external force will be useful in towing simulation. external forces acting on a body can be implemented with restraint class in sixDoFRigidBodyMotion and rigidBodyDynamics. but in current implementation of restraint class, it is not possible to have a reference to time object. It might be easy to add time support by passing objectRegistry object to restraint class constructor. please check this feature implementation. | ||||
Tags | No tags attached. | ||||
|
The rigidBodyDynamics classes are designed without the need for an objectRegistry so that they can be used in other contexts, e.g. robotics for which an OpenFOAM objectRegistry would not be required. If the current time is needed in the forces and restraint classes it would be better to pass that specifically rather than the high-level objectRegistry which may not exist for all applications of rigidBodyDynamics. |
|
tracing from rigidBodyMeshMotion class, time information is passed into RBD::rigidBodyMotion::solve. in RBD::rigidBodyMotion::solve, time info is stored in motionState and only internal joint force and external force are passed into rigidBodySolver::solve member function. in the rigidBodySolver::solve, those forces are passed into rigidBodyModel's member function applyRestraints. and in the applyRestraints, restraints associated to a body are calculated by restrain member function. So, time parameter will be added in rigidBodySolver::solve, rigidBodyModel::applyRestraints and restraints::restrain in order to pass current time information to restrain class. |
|
Do you mean that the time parameter would need to be added to the rigidBodySolver::solve call or that rigidBodySolver::solve would pass it to rigidBodyModel::applyRestraints? Given that rigidBodySolver::solve already has access to the current time from the rigidBodyModelState() protected member function I would suggest the latter. |
|
A little while ago we added a reference to the rigidBodyModelState to the jcalc method of the joints for a very similar reason (we needed more state information that we previously had). We could do the same for the restraints. This would allow the restraints to access the time, but also potentially any other aspect of the rigid body state. Foam::RBD::restraint::restrain would need the new argument, as would all of it's derivations. Foam::RBD::rigidBodyModel::applyRestraints would also need it. The Foam::RBD::rigidBodySolvers then call applyRestraints with the same set of arguments as they use to call forwardDynamics. Does that make sense? I don't know if the same is possible for sixDoF. |
|
yes, I think that make sense. for the sixDoF, I will study further. |
|
studying sixDoFRigidBodyMotion, sixDoFRigidBodyMotionState has not any information time. access to restraints::restrain member function is maded in sixDoFRigidBodyMotion::applyRestraints() which is called in sixDoFRigidBodyMotion::updateAcceleration(fGlobal, tauGlobal). sixDoFRigidBodyMotion::updateAcceleration is called in sixDoFSolver::updateAcceleration(fGlobal, tauGlobal) sixDoFSolver::updateAcceleration is called in sixDoFSolver::solve(firstIter, fGlobal, tauGlobal, deltaT, deltaT0) so sixDoF is using only time step and it doesn't look like an easy work to hand over time information up to restraint class unless chaning design of sixDoF classes or sixDoFRigidbodyMotionState. maybe best bet is to add time information to sixDoFRigidBodyMotioState and make it accessable. |
|
The longer term plan is to replace sixDoF with the more general and extensible rigidBody system, the only reason why this has not yet been done is that sixDoF supports implicit handling of restraints whereas they are currently handled explicitly in rigidBody and it is non-trivial to change this to an implicit implementation but this will get done eventually, particularly if we can secure funding for it. If your cases are not critically dependent on the implicit treatment of restraints I would recommend using the rigidBody system and update that to provide the time information to the restraints. |
|
I got the feeling rigidBody would replace sixDoF before. in that sense, I agree with Henry. Thank you for letting me know the plan. |
|
I have misunderstood the previous discussion with henry so that I waited until changes were made. I have updated restraint and its subclasses and rigidBodyModel::aplyRestraints and rigidBodySolvers to support time information. patch.diff (9,869 bytes)
diff --git a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C index a4ca22060..30cc3ce33 100644 --- a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C +++ b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.C @@ -74,7 +74,8 @@ Foam::RBD::restraints::linearAxialAngularSpring::~linearAxialAngularSpring() void Foam::RBD::restraints::linearAxialAngularSpring::restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const { vector refDir = rotationTensor(vector(1, 0, 0), axis_) & vector(0, 1, 0); diff --git a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.H b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.H index 1756f865e..c633ed1c8 100644 --- a/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.H +++ b/src/rigidBodyDynamics/restraints/linearAxialAngularSpring/linearAxialAngularSpring.H @@ -106,7 +106,8 @@ public: virtual void restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const; //- Update properties from given dictionary diff --git a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C index dbb5f2292..d68018f37 100644 --- a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C +++ b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.C @@ -74,7 +74,8 @@ Foam::RBD::restraints::linearDamper::~linearDamper() void Foam::RBD::restraints::linearDamper::restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const { vector force = -coeff_*model_.v(model_.master(bodyID_)).l(); diff --git a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.H b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.H index 88de28c08..ba3234498 100644 --- a/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.H +++ b/src/rigidBodyDynamics/restraints/linearDamper/linearDamper.H @@ -97,7 +97,8 @@ public: virtual void restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const; //- Update properties from given dictionary diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C index dc0a1cdfe..2b08c015d 100644 --- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C +++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C @@ -74,7 +74,8 @@ Foam::RBD::restraints::linearSpring::~linearSpring() void Foam::RBD::restraints::linearSpring::restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const { point attachmentPt = bodyPoint(refAttachmentPt_); diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H index 7f9ddd6fa..a4f026d55 100644 --- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H +++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H @@ -110,7 +110,8 @@ public: virtual void restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const; //- Update properties from given dictionary diff --git a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.H b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.H index 4013a038c..a840925ed 100644 --- a/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.H +++ b/src/rigidBodyDynamics/restraints/restraint/rigidBodyRestraint.H @@ -58,6 +58,7 @@ namespace RBD // Forward declaration of classes class rigidBodyModel; +class rigidBodyModelState; /*---------------------------------------------------------------------------*\ Class restraint Declaration @@ -162,7 +163,8 @@ public: virtual void restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const = 0; //- Update properties from given dictionary diff --git a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C index c60cef599..0287af9b3 100644 --- a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C +++ b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.C @@ -74,7 +74,8 @@ Foam::RBD::restraints::sphericalAngularDamper::~sphericalAngularDamper() void Foam::RBD::restraints::sphericalAngularDamper::restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const { vector moment = -coeff_*model_.v(model_.master(bodyID_)).w(); diff --git a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.H b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.H index aedbb063f..332125fa8 100644 --- a/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.H +++ b/src/rigidBodyDynamics/restraints/sphericalAngularDamper/sphericalAngularDamper.H @@ -98,7 +98,8 @@ public: virtual void restrain ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const; //- Update properties from given dictionary diff --git a/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C b/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C index 4067f5365..8b8ae3104 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C +++ b/src/rigidBodyDynamics/rigidBodyModel/forwardDynamics.C @@ -32,7 +32,8 @@ License void Foam::RBD::rigidBodyModel::applyRestraints ( scalarField& tau, - Field<spatialVector>& fx + Field<spatialVector>& fx, + const rigidBodyModelState& state ) const { if (restraints_.empty()) @@ -45,7 +46,7 @@ void Foam::RBD::rigidBodyModel::applyRestraints DebugInfo << "Restraint " << restraints_[ri].name(); // Accumulate the restraint forces - restraints_[ri].restrain(tau, fx); + restraints_[ri].restrain(tau, fx, state); } } diff --git a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H index f35661659..6a32ef8be 100644 --- a/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H +++ b/src/rigidBodyDynamics/rigidBodyModel/rigidBodyModel.H @@ -327,7 +327,7 @@ public: //- Apply the restraints and accumulate the internal joint forces // into the tau field and external forces into the fx field - void applyRestraints(scalarField& tau, Field<spatialVector>& fx) const; + void applyRestraints(scalarField& tau, Field<spatialVector>& fx, const rigidBodyModelState& state) const; //- Calculate the joint acceleration qDdot from the joint state q, // velocity qDot, internal force tau (in the joint frame) and diff --git a/src/rigidBodyDynamics/rigidBodySolvers/CrankNicolson/CrankNicolson.C b/src/rigidBodyDynamics/rigidBodySolvers/CrankNicolson/CrankNicolson.C index 1a73fb177..e6670132f 100644 --- a/src/rigidBodyDynamics/rigidBodySolvers/CrankNicolson/CrankNicolson.C +++ b/src/rigidBodyDynamics/rigidBodySolvers/CrankNicolson/CrankNicolson.C @@ -72,7 +72,7 @@ void Foam::RBD::rigidBodySolvers::CrankNicolson::solve // Accumulate the restraint forces scalarField rtau(tau); Field<spatialVector> rfx(fx); - model_.applyRestraints(rtau, rfx); + model_.applyRestraints(rtau, rfx, state()); // Calculate the accelerations for the given state and forces model_.forwardDynamics(state(), rtau, rfx); diff --git a/src/rigidBodyDynamics/rigidBodySolvers/Newmark/Newmark.C b/src/rigidBodyDynamics/rigidBodySolvers/Newmark/Newmark.C index 4be65978e..a72df8639 100644 --- a/src/rigidBodyDynamics/rigidBodySolvers/Newmark/Newmark.C +++ b/src/rigidBodyDynamics/rigidBodySolvers/Newmark/Newmark.C @@ -79,7 +79,7 @@ void Foam::RBD::rigidBodySolvers::Newmark::solve // Accumulate the restraint forces scalarField rtau(tau); Field<spatialVector> rfx(fx); - model_.applyRestraints(rtau, rfx); + model_.applyRestraints(rtau, rfx, state()); // Calculate the accelerations for the given state and forces model_.forwardDynamics(state(), rtau, rfx); diff --git a/src/rigidBodyDynamics/rigidBodySolvers/symplectic/symplectic.C b/src/rigidBodyDynamics/rigidBodySolvers/symplectic/symplectic.C index fc865e4c6..f21772f4f 100644 --- a/src/rigidBodyDynamics/rigidBodySolvers/symplectic/symplectic.C +++ b/src/rigidBodyDynamics/rigidBodySolvers/symplectic/symplectic.C @@ -81,7 +81,7 @@ void Foam::RBD::rigidBodySolvers::symplectic::solve // Accumulate the restraint forces scalarField rtau(tau); Field<spatialVector> rfx(fx); - model_.applyRestraints(rtau, rfx); + model_.applyRestraints(rtau, rfx, state()); // Calculate the body acceleration for the given state // and restraint forces |
|
Thanks for the contribution. Resolved by commit d32795f0eda78b856846de56759bd02847676ee5 |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-09-10 10:24 | handrake0724 | New Issue | |
2019-09-10 10:33 | henry | Note Added: 0010715 | |
2019-09-10 12:27 | handrake0724 | Note Added: 0010717 | |
2019-09-10 13:44 | henry | Note Added: 0010718 | |
2019-09-10 15:11 | will | Note Added: 0010720 | |
2019-09-10 23:21 | handrake0724 | Note Added: 0010724 | |
2019-09-11 05:45 | handrake0724 | Note Added: 0010725 | |
2019-09-11 08:05 | henry | Note Added: 0010729 | |
2019-09-11 08:49 | handrake0724 | Note Added: 0010730 | |
2019-10-02 14:31 | handrake0724 | File Added: patch.diff | |
2019-10-02 14:31 | handrake0724 | Note Added: 0010787 | |
2019-10-02 15:06 | henry | Category | Feature => Bug |
2019-10-02 15:06 | henry | Assigned To | => henry |
2019-10-02 15:06 | henry | Status | new => resolved |
2019-10-02 15:06 | henry | Resolution | open => fixed |
2019-10-02 15:06 | henry | Fixed in Version | => dev |
2019-10-02 15:06 | henry | Note Added: 0010788 |