1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/joint.h,v 1.59 2017/01/12 14:46:43 masarati Exp $ */ 2 /* 3 * MBDyn (C) is a multibody analysis code. 4 * http://www.mbdyn.org 5 * 6 * Copyright (C) 1996-2017 7 * 8 * Pierangelo Masarati <masarati@aero.polimi.it> 9 * Paolo Mantegazza <mantegazza@aero.polimi.it> 10 * 11 * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano 12 * via La Masa, 34 - 20156 Milano, Italy 13 * http://www.aero.polimi.it 14 * 15 * Changing this copyright notice is forbidden. 16 * 17 * This program is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License as published by 19 * the Free Software Foundation (version 2 of the License). 20 * 21 * 22 * This program is distributed in the hope that it will be useful, 23 * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 * GNU General Public License for more details. 26 * 27 * You should have received a copy of the GNU General Public License 28 * along with this program; if not, write to the Free Software 29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 */ 31 32 /* vincoli, tipo: Elem::Type JOINT */ 33 34 #ifndef JOINT_H 35 #define JOINT_H 36 37 /* include per derivazione della classe */ 38 39 #include <cfloat> 40 41 #include "strnode.h" 42 #include "elem.h" 43 #include "gravity.h" 44 #include "hint_impl.h" 45 46 extern const char* psJointNames[]; 47 48 /* Joint - begin */ 49 50 class Joint 51 : virtual public Elem, public ElemGravityOwner, 52 public ElemWithDofs, public InitialAssemblyElem 53 { 54 protected: 55 #ifdef USE_NETCDF 56 NcVar *Var_F_local; 57 NcVar *Var_M_local; 58 NcVar *Var_F_global; 59 NcVar *Var_M_global; 60 #endif // USE_NETCDF 61 62 virtual void OutputPrepare_int(const std::string& type, OutputHandler &OH, std::string& name); 63 64 public: 65 /* Tipi di Joint */ 66 enum Type { 67 UNKNOWN = -1, 68 69 DISTANCE = 0, 70 DISTANCEWITHOFFSET, 71 CLAMP, 72 SPHERICALHINGE, 73 PIN, 74 UNIVERSALHINGE, 75 UNIVERSALROTATION, 76 UNIVERSALPIN, 77 PLANEHINGE, 78 PLANEROTATION, 79 PLANEPIN, 80 AXIALROTATION, 81 PLANEDISP, 82 PLANEDISPPIN, 83 INPLANE, 84 INPLANECONTACT, 85 J_INLINE, 86 ROD, 87 RODBEZIER, 88 DEFORMABLEHINGE, 89 DEFORMABLEDISPJOINT, 90 DEFORMABLEJOINT, 91 DEFORMABLEAXIALJOINT, 92 VISCOUSBODY, 93 LINEARVELOCITY, 94 ANGULARVELOCITY, 95 LINEARACCELERATION, 96 ANGULARACCELERATION, 97 PRISMATIC, 98 DRIVEHINGE, 99 DRIVEDISP, 100 DRIVEDISPPIN, 101 IMPOSEDORIENTATION, 102 IMPOSEDDISP, 103 IMPOSEDDISPPIN, 104 IMPOSEDKINEMATICS, 105 BEAMSLIDER, 106 BRAKE, 107 GIMBAL, 108 POINT_SURFACE_CONTACT, 109 TOTALJOINT, 110 TOTALPINJOINT, 111 TOTALEQUATION, 112 TOTALREACTION, 113 114 MODAL, 115 SCREWJOINT, 116 117 LASTJOINTTYPE 118 }; 119 120 public: 121 struct JointHint : public Hint { ~JointHintJointHint122 virtual ~JointHint(void) {}; 123 }; 124 125 template <int i> 126 struct OffsetHint : public Joint::JointHint {}; 127 128 template <int i> 129 struct HingeHint : public Joint::JointHint {}; 130 template <int i> 131 struct PositionHingeHint : public Joint::HingeHint<i> {}; 132 template <int i> 133 struct OrientationHingeHint : public Joint::HingeHint<i> {}; 134 135 template <class T> 136 struct JointDriveHint : public Joint::JointHint { 137 TplDriveHint<T> *pTDH; JointDriveHintJointDriveHint138 JointDriveHint(TplDriveHint<T> *pTDH) : pTDH(pTDH) {}; ~JointDriveHintJointDriveHint139 ~JointDriveHint(void) { 140 if (pTDH) { 141 delete pTDH; 142 } 143 }; 144 }; 145 template <class T> 146 struct PositionDriveHint : public Joint::JointDriveHint<T> { PositionDriveHintPositionDriveHint147 PositionDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 148 }; 149 template <class T> 150 struct VelocityDriveHint : public Joint::JointDriveHint<T> { VelocityDriveHintVelocityDriveHint151 VelocityDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 152 }; 153 template <class T> 154 struct AccelerationDriveHint : public Joint::JointDriveHint<T> { AccelerationDriveHintAccelerationDriveHint155 AccelerationDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 156 }; 157 template <class T> 158 struct OrientationDriveHint : public Joint::JointDriveHint<T> { OrientationDriveHintOrientationDriveHint159 OrientationDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 160 }; 161 template <class T> 162 struct AngularVelocityDriveHint : public Joint::JointDriveHint<T> { AngularVelocityDriveHintAngularVelocityDriveHint163 AngularVelocityDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 164 }; 165 template <class T> 166 struct AngularAccelerationDriveHint : public Joint::JointDriveHint<T> { AngularAccelerationDriveHintAngularAccelerationDriveHint167 AngularAccelerationDriveHint(TplDriveHint<T> *pTDH) : Joint::JointDriveHint<T>(pTDH) {}; 168 }; 169 170 struct ReactionsHint : public Joint::JointHint {}; 171 struct ForcesHint : public Joint::ReactionsHint {}; 172 struct MomentsHint : public Joint::ReactionsHint {}; 173 174 public: 175 class ErrGeneric : public MBDynErrBase { 176 public: ErrGeneric(MBDYN_EXCEPT_ARGS_DECL)177 ErrGeneric(MBDYN_EXCEPT_ARGS_DECL) : MBDynErrBase(MBDYN_EXCEPT_ARGS_PASSTHRU) {}; 178 }; 179 180 public: 181 Joint(unsigned int uL, const DofOwner* pD, flag fOut); 182 virtual ~Joint(void); 183 184 /* Derivate da Elem */ 185 186 /* Tipo dell'elemento (usato solo per debug ecc.) */ GetElemType(void)187 virtual Elem::Type GetElemType(void) const { 188 return Elem::JOINT; 189 }; 190 191 /* Tipo di joint */ 192 virtual Joint::Type GetJointType(void) const = 0; 193 194 /* Contributo al file di restart */ Restart(std::ostream & out)195 virtual std::ostream& Restart(std::ostream& out) const { 196 return out << " joint: " << GetLabel(); 197 }; 198 199 /* Output specifico dei vincoli */ 200 std::ostream& 201 Output(std::ostream& out, const char* sJointName, 202 unsigned int uLabel, 203 const Vec3& FLocal, const Vec3& MLocal, 204 const Vec3& FGlobal, const Vec3& MGlobal) const; 205 206 /* Derivate da ElemWith Dofs */ 207 208 /* Setta il valore iniziale delle proprie variabili */ SetInitialValue(VectorHandler &)209 virtual void SetInitialValue(VectorHandler& /* X */ ) { 210 NO_OP; 211 }; 212 213 virtual void SetValue(DataManager *pDM, 214 VectorHandler& /* X */ , VectorHandler& /* Xp */ , 215 SimulationEntity::Hints *ph = 0) 216 { 217 NO_OP; 218 }; 219 220 // inverse dynamics 221 /* inverse dynamics update */ 222 virtual void Update(const VectorHandler& XCurr, InverseDynamics::Order iOrder = InverseDynamics::INVERSE_DYNAMICS); 223 224 bool bIsPrescribedMotion(void) const; 225 bool bIsTorque(void) const; 226 // end of inverse dynamics 227 228 /* per la lettura dei dati dell'elemento modale */ 229 230 friend Joint * 231 ReadModal(DataManager* pDM,MBDynParser& HP, const DofOwner* pD0, 232 unsigned int uLabel, const StructNode* pModalNode); 233 }; 234 235 /* Joint - end */ 236 237 238 /* Lettura Joints */ 239 class DataManager; 240 class MBDynParser; 241 242 extern Elem* ReadJoint(DataManager* pDM, 243 MBDynParser& HP, 244 const DofOwner* pDO, 245 unsigned int uLabel); 246 247 #endif // JOINT_H 248