diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C index dc0a1cdfee..e08501b0f6 100644 --- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C +++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.C @@ -90,7 +90,9 @@ void Foam::RBD::restraints::linearSpring::restrain // Force and moment on the master body including optional damping vector force ( - (-stiffness_*(magR - restLength_) - damping_*(r & v))*r + (allowSlack_ && magR < restLength_) + ? -damping_*(r & v)*r + : (-stiffness_*(magR - restLength_) - damping_*(r & v))*r ); vector moment(attachmentPt ^ force); @@ -100,6 +102,7 @@ void Foam::RBD::restraints::linearSpring::restrain Info<< " attachmentPt " << attachmentPt << " attachmentPt - anchor " << r*magR << " spring length " << magR + << " allow slack " << allowSlack_ << " force " << force << " moment " << moment << endl; @@ -122,6 +125,7 @@ bool Foam::RBD::restraints::linearSpring::read coeffs_.lookup("stiffness") >> stiffness_; coeffs_.lookup("damping") >> damping_; coeffs_.lookup("restLength") >> restLength_; + allowSlack_ = coeffs_.lookupOrDefault("allowSlack", false); return true; } @@ -143,6 +147,8 @@ void Foam::RBD::restraints::linearSpring::write writeEntry(os, "damping", damping_); writeEntry(os, "restLength", restLength_); + + writeEntry(os, "allowSlack", allowSlack_); } diff --git a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H index 7f9ddd6faa..10e7558096 100644 --- a/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H +++ b/src/rigidBodyDynamics/restraints/linearSpring/linearSpring.H @@ -36,6 +36,7 @@ SourceFiles #define RBD_restraints_linearSpring_H #include "rigidBodyRestraint.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,6 +73,9 @@ class linearSpring //- Rest length - length of spring when no forces are applied to it scalar restLength_; + //- Switch to allow no restraint when line is shorter than restLength + Switch allowSlack_; + public: