1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/body_vm.h,v 1.7 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 /* elementi di massa, tipo: Elem::Type BODY */ 33 34 #ifndef BODY_VM_H 35 #define BODY_VM_H 36 37 /* include per derivazione della classe */ 38 39 #include "elem.h" 40 #include "strnode.h" 41 #include "gravity.h" 42 43 /* VariableBody - begin */ 44 45 class VariableBody : 46 virtual public Elem, public ElemGravityOwner, public InitialAssemblyElem { 47 protected: 48 const StructNode *pNode; 49 50 DriveOwner m_Mass; 51 TplDriveOwner<Vec3> m_Xgc; 52 TplDriveOwner<Mat3x3> m_Jgc_vm; 53 TplDriveOwner<Mat3x3> m_Jgc_vg; 54 55 mutable doublereal dMTmp; 56 mutable Vec3 STmp; 57 mutable Mat3x3 JTmp; 58 59 /* momento statico */ 60 Vec3 GetS_int(void) const; 61 62 /* momento d'inerzia */ 63 Mat3x3 GetJ_int(void) const; 64 65 void 66 AssVecRBK_int(SubVectorHandler& WorkVec); 67 68 void 69 AssMatsRBK_int( 70 FullSubMatrixHandler& WMA, 71 FullSubMatrixHandler& WMB, 72 const doublereal& dCoef, 73 const Vec3& Sc); 74 75 public: 76 /* Costruttore definitivo (da mettere a punto) */ 77 VariableBody(unsigned int uL, const StructNode *pNode, 78 const DriveCaller *pDCMass, 79 const TplDriveCaller<Vec3> *pDCXgc, 80 const TplDriveCaller<Mat3x3> *pDCJgc_vm, 81 const TplDriveCaller<Mat3x3> *pDCJgc_vg, 82 flag fOut); 83 84 virtual ~VariableBody(void); 85 86 /* Scrive il contributo dell'elemento al file di restart */ 87 virtual std::ostream& Restart(std::ostream& out) const; 88 89 /* massa totale */ 90 doublereal dGetM(void) const; 91 92 /* momento statico */ 93 Vec3 GetS(void) const; 94 95 /* momento d'inerzia */ 96 Mat3x3 GetJ(void) const; 97 98 /* nodo */ 99 const StructNode *pGetNode(void) const; 100 101 /* Tipo dell'elemento (usato solo per debug ecc.) */ GetElemType(void)102 virtual Elem::Type GetElemType(void) const { 103 return Elem::BODY; 104 }; 105 106 /* Numero gdl durante l'assemblaggio iniziale */ iGetInitialNumDof(void)107 virtual unsigned int iGetInitialNumDof(void) const { 108 return 0; 109 }; 110 111 virtual void AfterPredict(VectorHandler& X, VectorHandler& XP); 112 113 /* Accesso ai dati privati */ 114 virtual unsigned int iGetNumPrivData(void) const; 115 virtual unsigned int iGetPrivDataIdx(const char *s) const; 116 virtual doublereal dGetPrivData(unsigned int i) const; 117 }; 118 119 /* VariableBody - end */ 120 121 /* DynamicVariableBody - begin */ 122 123 class DynamicVariableBody : 124 virtual public Elem, public VariableBody { 125 private: 126 127 Vec3 GetB_int(void) const; 128 Vec3 GetG_int(void) const; 129 130 /* Assembla le due matrici necessarie per il calcolo degli 131 * autovalori e per lo jacobiano */ 132 void AssMats(FullSubMatrixHandler& WorkMatA, 133 FullSubMatrixHandler& WorkMatB, 134 doublereal dCoef, 135 bool bGravity, 136 const Vec3& GravityAcceleration); 137 138 public: 139 /* Costruttore definitivo (da mettere a punto) */ 140 DynamicVariableBody(unsigned int uL, const DynamicStructNode* pNodeTmp, 141 const DriveCaller *pDCMass, 142 const TplDriveCaller<Vec3> *pDCXgc, 143 const TplDriveCaller<Mat3x3> *pDCJgc_vm, 144 const TplDriveCaller<Mat3x3> *pDCJgc_vg, 145 flag fOut); 146 147 virtual ~DynamicVariableBody(void); 148 WorkSpaceDim(integer * piNumRows,integer * piNumCols)149 void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const { 150 *piNumRows = 12; 151 *piNumCols = 6; 152 }; 153 154 virtual VariableSubMatrixHandler& 155 AssJac(VariableSubMatrixHandler& WorkMat, 156 doublereal dCoef, 157 const VectorHandler& XCurr, 158 const VectorHandler& XPrimeCurr); 159 160 void AssMats(VariableSubMatrixHandler& WorkMatA, 161 VariableSubMatrixHandler& WorkMatB, 162 const VectorHandler& XCurr, 163 const VectorHandler& XPrimeCurr); 164 165 virtual SubVectorHandler& 166 AssRes(SubVectorHandler& WorkVec, 167 doublereal dCoef, 168 const VectorHandler& XCurr, 169 const VectorHandler& XPrimeCurr); 170 171 /* Dimensione del workspace durante l'assemblaggio iniziale. 172 * Occorre tener conto del numero di dof che l'elemento definisce 173 * in questa fase e dei dof dei nodi che vengono utilizzati. 174 * Sono considerati dof indipendenti la posizione e la velocita' 175 * dei nodi */ 176 virtual void InitialWorkSpaceDim(integer * piNumRows,integer * piNumCols)177 InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const { 178 *piNumRows = 12; 179 *piNumCols = 6; 180 }; 181 182 /* Contributo allo jacobiano durante l'assemblaggio iniziale */ 183 virtual VariableSubMatrixHandler& 184 InitialAssJac(VariableSubMatrixHandler& WorkMat, 185 const VectorHandler& XCurr); 186 187 /* Contributo al residuo durante l'assemblaggio iniziale */ 188 virtual SubVectorHandler& 189 InitialAssRes(SubVectorHandler& WorkVec, const VectorHandler& XCurr); 190 191 /* Usata per inizializzare la quantita' di moto */ 192 virtual void SetValue(DataManager *pDM, 193 VectorHandler& X, VectorHandler& XP, 194 SimulationEntity::Hints *ph = 0); 195 196 /******** PER IL SOLUTORE PARALLELO *********/ 197 /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento 198 * utile per l'assemblaggio della matrice di connessione fra i dofs */ 199 virtual void GetConnectedNodes(std::vector<const Node * > & connectedNodes)200 GetConnectedNodes(std::vector<const Node *>& connectedNodes) const { 201 connectedNodes.resize(1); 202 connectedNodes[0] = pNode; 203 }; 204 /**************************************************/ 205 }; 206 207 /* DynamicVariableBody - end */ 208 209 /* StaticVariableBody - begin */ 210 211 class StaticVariableBody : 212 virtual public Elem, public VariableBody { 213 private: 214 /* Assembla le due matrici necessarie per il calcolo degli 215 * autovalori e per lo jacobiano */ 216 bool AssMats(FullSubMatrixHandler& WorkMatA, 217 FullSubMatrixHandler& WorkMatB, 218 doublereal dCoef); 219 220 public: 221 /* Costruttore definitivo (da mettere a punto) */ 222 StaticVariableBody(unsigned int uL, const StaticStructNode* pNode, 223 const DriveCaller *pDCMass, 224 const TplDriveCaller<Vec3> *pDCXgc, 225 const TplDriveCaller<Mat3x3> *pDCJgc_vm, 226 const TplDriveCaller<Mat3x3> *pDCJgc_vg, 227 flag fOut); 228 229 virtual ~StaticVariableBody(void); 230 WorkSpaceDim(integer * piNumRows,integer * piNumCols)231 void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const { 232 *piNumRows = 6; 233 *piNumCols = 6; 234 }; 235 236 virtual VariableSubMatrixHandler& 237 AssJac(VariableSubMatrixHandler& WorkMat, 238 doublereal dCoef, 239 const VectorHandler& XCurr, 240 const VectorHandler& XPrimeCurr); 241 242 void AssMats(VariableSubMatrixHandler& WorkMatA, 243 VariableSubMatrixHandler& WorkMatB, 244 const VectorHandler& XCurr, 245 const VectorHandler& XPrimeCurr); 246 247 virtual SubVectorHandler& 248 AssRes(SubVectorHandler& WorkVec, 249 doublereal dCoef, 250 const VectorHandler& XCurr, 251 const VectorHandler& XPrimeCurr); 252 253 /* inverse dynamics capable element */ 254 virtual bool bInverseDynamics(void) const; 255 256 /* Inverse Dynamics: */ 257 virtual SubVectorHandler& 258 AssRes(SubVectorHandler& WorkVec, 259 const VectorHandler& /* XCurr */ , 260 const VectorHandler& /* XPrimeCurr */ , 261 const VectorHandler& /* XPrimePrimeCurr */ , 262 InverseDynamics::Order iOrder = InverseDynamics::INVERSE_DYNAMICS); 263 264 /* Dimensione del workspace durante l'assemblaggio iniziale. 265 * Occorre tener conto del numero di dof che l'elemento definisce 266 * in questa fase e dei dof dei nodi che vengono utilizzati. 267 * Sono considerati dof indipendenti la posizione e la velocita' 268 * dei nodi */ 269 virtual void InitialWorkSpaceDim(integer * piNumRows,integer * piNumCols)270 InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const { 271 *piNumRows = 6; 272 *piNumCols = 6; 273 }; 274 275 /* Contributo allo jacobiano durante l'assemblaggio iniziale */ 276 virtual VariableSubMatrixHandler& 277 InitialAssJac(VariableSubMatrixHandler& WorkMat, 278 const VectorHandler& XCurr); 279 280 /* Contributo al residuo durante l'assemblaggio iniziale */ 281 virtual SubVectorHandler& 282 InitialAssRes(SubVectorHandler& WorkVec, const VectorHandler& XCurr); 283 284 /* Usata per inizializzare la quantita' di moto */ 285 virtual void SetValue(DataManager *pDM, 286 VectorHandler& X, VectorHandler& XP, 287 SimulationEntity::Hints *ph = 0); 288 289 /******** PER IL SOLUTORE PARALLELO *********/ 290 /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento 291 * utile per l'assemblaggio della matrice di connessione fra i dofs */ 292 virtual void GetConnectedNodes(std::vector<const Node * > & connectedNodes)293 GetConnectedNodes(std::vector<const Node *>& connectedNodes) const { 294 connectedNodes.resize(1); 295 connectedNodes[0] = pNode; 296 }; 297 /**************************************************/ 298 }; 299 300 extern Elem* 301 ReadVariableBody(DataManager* pDM, MBDynParser& HP, unsigned int uLabel, 302 const StructNode* pStrNode); 303 304 /* StaticVariableBody - end */ 305 306 class DataManager; 307 class MBDynParser; 308 309 #endif /* BODY_VM_H */ 310 311