MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
inertia.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/inertia.h,v 1.12 2017/06/18 23:06:24 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 /* inertia element */
33 
34 #ifndef INERTIA_H
35 #define INERTIA_H
36 
37 #include "elem.h"
38 #include "strnode.h"
39 #include "gravity.h"
40 
41 /* CenterOfMass - begin */
42 
43 class CenterOfMass {
44 protected:
45  std::set<const ElemGravityOwner *> elements;
46 
47  mutable doublereal dMass;
48  mutable Vec3 S;
49  mutable Mat3x3 J;
50 
51  /* Center of mass kinematics and inertia */
56 
57  virtual void Collect_int(void);
58 
59  virtual std::ostream& Output_int(std::ostream& out) const;
60 
61 public:
62  /* Costruttore definitivo (da mettere a punto) */
63  CenterOfMass(std::set<const ElemGravityOwner *>& elements);
64  virtual ~CenterOfMass(void);
65 };
66 
67 /* CenterOfMass - end */
68 
69 /* Inertia - begin */
70 
71 class Inertia :
72 virtual public Elem, public ElemGravityOwner, public InitialAssemblyElem, public CenterOfMass {
73 public:
74  enum {
78  };
79 
80 protected:
81  /* reference point */
82  unsigned flags;
86 
89 
90  /* momento statico */
91  Vec3 GetS_int(void) const;
92 
93  /* momento d'inerzia */
94  Mat3x3 GetJ_int(void) const;
95 
96  virtual void Collect_int(void);
97 
98  virtual std::ostream& Output_int(std::ostream& out) const;
99  void OutputPrepare_int(OutputHandler &OH, std::string& name);
100  void OutputPrepare(OutputHandler &OH);
101 
102 #ifdef USE_NETCDF
103 private:
104  NcVar *Var_dMass;
105  NcVar *Var_X_cm;
106  NcVar *Var_V_cm;
107  NcVar *Var_Omega_cm;
108 
109  NcVar *Var_DX;
110  NcVar *Var_dx;
111  NcVar *Var_Jp;
112  NcVar *Var_Phip;
113 #endif // USE_NETCDF
114 
115 public:
116  /* Costruttore definitivo (da mettere a punto) */
117  Inertia(unsigned int uL, const std::string& sN, std::set<const ElemGravityOwner *>& elements,
118  const Vec3& x0, const Mat3x3& r0, std::ostream& log, flag fOut);
119 
120  virtual ~Inertia(void);
121 
122  /* massa totale */
123  doublereal dGetM(void) const;
124 
125  /* Tipo dell'elemento (usato solo per debug ecc.) */
126  virtual Elem::Type GetElemType(void) const;
127 
128  /* Numero gdl durante l'assemblaggio iniziale */
129  virtual unsigned int iGetInitialNumDof(void) const;
130 
131  /* Scrive il contributo dell'elemento al file di restart */
132  virtual std::ostream& Restart(std::ostream& out) const;
133 
134  virtual void Output(OutputHandler& OH) const;
135 
136  void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
137 
138  virtual VariableSubMatrixHandler&
140  doublereal dCoef,
141  const VectorHandler& XCurr,
142  const VectorHandler& XPrimeCurr);
143 
144  virtual SubVectorHandler&
145  AssRes(SubVectorHandler& WorkVec,
146  doublereal dCoef,
147  const VectorHandler& XCurr,
148  const VectorHandler& XPrimeCurr);
149 
150  /* inverse dynamics capable element */
151  virtual bool bInverseDynamics(void) const;
152 
153  /* Inverse Dynamics Jacobian matrix assembly */
154  virtual VariableSubMatrixHandler&
156  const VectorHandler& XCurr);
157 
158  /* Inverse Dynamics residual assembly */
159  virtual SubVectorHandler&
160  AssRes(SubVectorHandler& WorkVec,
161  const VectorHandler& XCurr,
162  const VectorHandler& XPrimeCurr,
163  const VectorHandler& XPrimePrimeCurr,
165 
166  /* Dimensione del workspace durante l'assemblaggio iniziale.
167  * Occorre tener conto del numero di dof che l'elemento definisce
168  * in questa fase e dei dof dei nodi che vengono utilizzati.
169  * Sono considerati dof indipendenti la posizione e la velocita'
170  * dei nodi */
171  virtual void
172  InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
173 
174  /* Contributo allo jacobiano durante l'assemblaggio iniziale */
175  virtual VariableSubMatrixHandler&
177  const VectorHandler& XCurr);
178 
179  /* Contributo al residuo durante l'assemblaggio iniziale */
180  virtual SubVectorHandler&
181  InitialAssRes(SubVectorHandler& WorkVec, const VectorHandler& XCurr);
182 
183  /* Usata per inizializzare la quantita' di moto */
184  virtual void SetValue(DataManager *pDM,
186  SimulationEntity::Hints *ph = 0);
187 
188  virtual unsigned int iGetNumPrivData(void) const;
189  virtual unsigned int iGetPrivDataIdx(const char *s) const;
190  virtual doublereal dGetPrivData(unsigned int i) const;
191 };
192 
193 /* Inertia - end */
194 
195 #endif // INERTIA_H
196 
virtual SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
Definition: inertia.cc:438
virtual void Output(OutputHandler &OH) const
Definition: inertia.cc:277
long int flag
Definition: mbdyn.h:43
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: inertia.cc:373
Definition: matvec3.h:98
Mat3x3 R_princ
Definition: inertia.h:87
void OutputPrepare(OutputHandler &OH)
Definition: inertia.cc:323
Vec3 V_cm
Definition: inertia.h:53
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: inertia.cc:421
virtual bool bInverseDynamics(void) const
Definition: inertia.cc:386
std::set< const ElemGravityOwner * > elements
Definition: inertia.h:45
virtual std::ostream & Output_int(std::ostream &out) const
Definition: inertia.cc:132
std::vector< Hint * > Hints
Definition: simentity.h:89
Mat3x3 J_cm
Definition: inertia.h:55
virtual unsigned int iGetInitialNumDof(void) const
Definition: inertia.cc:227
Mat3x3 J0
Definition: inertia.h:85
virtual VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
Definition: inertia.cc:429
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: inertia.cc:471
doublereal dMass
Definition: inertia.h:47
virtual unsigned int iGetNumPrivData(void) const
Definition: inertia.cc:457
Vec3 Omega_cm
Definition: inertia.h:54
void OutputPrepare_int(OutputHandler &OH, std::string &name)
Definition: inertia.cc:307
GradientExpression< UnaryExpr< FuncLog, Expr > > log(const GradientExpression< Expr > &u)
Definition: gradient.h:2976
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: inertia.cc:363
doublereal dGetM(void) const
Definition: inertia.cc:213
CenterOfMass(std::set< const ElemGravityOwner * > &elements)
Definition: inertia.cc:102
virtual doublereal dGetPrivData(unsigned int i) const
Definition: inertia.cc:561
unsigned flags
Definition: inertia.h:82
void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: inertia.cc:356
Vec3 X_cm
Definition: inertia.h:52
virtual ~CenterOfMass(void)
Definition: inertia.cc:108
virtual void Collect_int(void)
Definition: inertia.cc:233
Vec3 J_princ
Definition: inertia.h:88
Vec3 X0
Definition: inertia.h:83
virtual Elem::Type GetElemType(void) const
Definition: inertia.cc:220
Mat3x3 R0
Definition: inertia.h:84
Definition: elem.h:75
virtual std::ostream & Restart(std::ostream &out) const
Definition: inertia.cc:271
Type
Definition: elem.h:91
Mat3x3 J
Definition: inertia.h:49
virtual ~Inertia(void)
Definition: inertia.cc:206
Mat3x3 GetJ_int(void) const
Definition: inertia.cc:126
Inertia(unsigned int uL, const std::string &sN, std::set< const ElemGravityOwner * > &elements, const Vec3 &x0, const Mat3x3 &r0, std::ostream &log, flag fOut)
Definition: inertia.cc:160
Vec3 S
Definition: inertia.h:48
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *ph=0)
Definition: inertia.cc:449
virtual void Collect_int(void)
Definition: inertia.cc:59
Vec3 GetS_int(void) const
Definition: inertia.cc:119
virtual std::ostream & Output_int(std::ostream &out) const
Definition: inertia.cc:47