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 "sphericalAngularSpring.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <forces/sixDoFRigidBodyMotion.H>
00029
00030
00031
00032 namespace Foam
00033 {
00034 namespace sixDoFRigidBodyMotionRestraints
00035 {
00036 defineTypeNameAndDebug(sphericalAngularSpring, 0);
00037 addToRunTimeSelectionTable
00038 (
00039 sixDoFRigidBodyMotionRestraint,
00040 sphericalAngularSpring,
00041 dictionary
00042 );
00043 };
00044 };
00045
00046
00047
00048
00049 Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::
00050 sphericalAngularSpring
00051 (
00052 const dictionary& sDoFRBMRDict
00053 )
00054 :
00055 sixDoFRigidBodyMotionRestraint(sDoFRBMRDict),
00056 refQ_(),
00057 stiffness_(),
00058 damping_()
00059 {
00060 read(sDoFRBMRDict);
00061 }
00062
00063
00064
00065
00066 Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::
00067 ~sphericalAngularSpring()
00068 {}
00069
00070
00071
00072
00073 void
00074 Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::restrain
00075 (
00076 const sixDoFRigidBodyMotion& motion,
00077 vector& restraintPosition,
00078 vector& restraintForce,
00079 vector& restraintMoment
00080 ) const
00081 {
00082 restraintMoment = vector::zero;
00083
00084 for (direction cmpt=0; cmpt<vector::nComponents; cmpt++)
00085 {
00086 vector axis = vector::zero;
00087
00088 axis[cmpt] = 1;
00089
00090 vector refDir = vector::zero;
00091
00092 refDir[(cmpt + 1) % 3] = 1;
00093
00094 vector newDir = motion.orientation() & refDir;
00095
00096 axis = (refQ_ & axis);
00097
00098 refDir = (refQ_ & refDir);
00099
00100 newDir -= (axis & newDir)*axis;
00101
00102 restraintMoment += -stiffness_*(refDir ^ newDir);
00103 }
00104
00105 restraintMoment += -damping_*motion.omega();
00106
00107 restraintForce = vector::zero;
00108
00109
00110
00111 restraintPosition = motion.centreOfMass();
00112
00113 if (motion.report())
00114 {
00115 Info<< " force " << restraintForce
00116 << " moment " << restraintMoment
00117 << endl;
00118 }
00119 }
00120
00121
00122 bool Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::read
00123 (
00124 const dictionary& sDoFRBMRDict
00125 )
00126 {
00127 sixDoFRigidBodyMotionRestraint::read(sDoFRBMRDict);
00128
00129 refQ_ = sDoFRBMRCoeffs_.lookupOrDefault<tensor>("referenceOrientation", I);
00130
00131 if (mag(mag(refQ_) - sqrt(3.0)) > 1e-9)
00132 {
00133 FatalErrorIn
00134 (
00135 "Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::"
00136 "read"
00137 "("
00138 "const dictionary& sDoFRBMRDict"
00139 ")"
00140 )
00141 << "referenceOrientation " << refQ_ << " is not a rotation tensor. "
00142 << "mag(referenceOrientation) - sqrt(3) = "
00143 << mag(refQ_) - sqrt(3.0) << nl
00144 << exit(FatalError);
00145 }
00146
00147 sDoFRBMRCoeffs_.lookup("stiffness") >> stiffness_;
00148
00149 sDoFRBMRCoeffs_.lookup("damping") >> damping_;
00150
00151 return true;
00152 }
00153
00154
00155 void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::write
00156 (
00157 Ostream& os
00158 ) const
00159 {
00160 os.writeKeyword("referenceOrientation")
00161 << refQ_ << token::END_STATEMENT << nl;
00162
00163 os.writeKeyword("stiffness") << stiffness_ << token::END_STATEMENT << nl;
00164
00165 os.writeKeyword("damping") << damping_ << token::END_STATEMENT << nl;
00166 }
00167
00168
00169