Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "linearSpring.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <forces/sixDoFRigidBodyMotion.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034 namespace sixDoFRigidBodyMotionRestraints
00035 {
00036 defineTypeNameAndDebug(linearSpring, 0);
00037 addToRunTimeSelectionTable
00038 (
00039 sixDoFRigidBodyMotionRestraint,
00040 linearSpring,
00041 dictionary
00042 );
00043 };
00044 };
00045
00046
00047
00048
00049 Foam::sixDoFRigidBodyMotionRestraints::linearSpring::linearSpring
00050 (
00051 const dictionary& sDoFRBMRDict
00052 )
00053 :
00054 sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
00055 anchor_(),
00056 refAttachmentPt_(),
00057 stiffness_(),
00058 damping_(),
00059 restLength_()
00060 {
00061 read(sDoFRBMRDict);
00062 }
00063
00064
00065
00066
00067 Foam::sixDoFRigidBodyMotionRestraints::linearSpring::~linearSpring()
00068 {}
00069
00070
00071
00072
00073 void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::restrain
00074 (
00075 const sixDoFRigidBodyMotion& motion,
00076 vector& restraintPosition,
00077 vector& restraintForce,
00078 vector& restraintMoment
00079 ) const
00080 {
00081 restraintPosition = motion.currentPosition(refAttachmentPt_);
00082
00083 vector r = restraintPosition - anchor_;
00084
00085 scalar magR = mag(r);
00086
00087
00088 r /= (magR + VSMALL);
00089
00090 vector v = motion.currentVelocity(restraintPosition);
00091
00092 restraintForce = -stiffness_*(magR - restLength_)*r - damping_*(r & v)*r;
00093
00094 restraintMoment = vector::zero;
00095
00096 if (motion.report())
00097 {
00098 Info<< " attachmentPt - anchor " << r*magR
00099 << " spring length " << magR
00100 << " force " << restraintForce
00101 << " moment " << restraintMoment
00102 << endl;
00103 }
00104 }
00105
00106
00107 bool Foam::sixDoFRigidBodyMotionRestraints::linearSpring::read
00108 (
00109 const dictionary& sDoFRBMRDict
00110 )
00111 {
00112 sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
00113
00114 sDoFRBMRCoeffs_.lookup("anchor") >> anchor_;
00115
00116 sDoFRBMRCoeffs_.lookup("refAttachmentPt") >> refAttachmentPt_;
00117
00118 sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
00119
00120 sDoFRBMRCoeffs_.lookup("damping") >> damping_;
00121
00122 sDoFRBMRCoeffs_.lookup("restLength") >> restLength_;
00123
00124 return true;
00125 }
00126
00127
00128 void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::write
00129 (
00130 Ostream& os
00131 ) const
00132 {
00133 os.writeKeyword("anchor")
00134 << anchor_ << token::END_STATEMENT << nl;
00135
00136 os.writeKeyword("refAttachmentPt")
00137 << refAttachmentPt_ << token::END_STATEMENT << nl;
00138
00139 os.writeKeyword("stiffness")
00140 << stiffness_ << token::END_STATEMENT << nl;
00141
00142 os.writeKeyword("damping")
00143 << damping_ << token::END_STATEMENT << nl;
00144
00145 os.writeKeyword("restLength")
00146 << restLength_ << token::END_STATEMENT << nl;
00147 }
00148
00149