rigidBodyDynamics::restraints::linearSpring: Added switch "allowSlack" to allow no restraint when line is shorter than restLength

Based on patch contributed by SeongMo Yeon
Resolved contribution https://bugs.openfoam.org/view.php?id=3352
This commit is contained in:
Henry Weller
2019-09-30 14:26:57 +01:00
parent 2ebed5ec71
commit f1b975bbb1
2 changed files with 11 additions and 1 deletions

View File

@ -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<Switch>("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_);
}

View File

@ -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: