MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
modal.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/struct/modal.h,v 1.78 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 /* Elemento modale */
33 
34 /*
35  * Copyright 1999-2017 Felice Felippone <ffelipp@tin.it>
36  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
37  */
38 
39 /*
40  * Copyright 1999-2017 Pierangelo Masarati <masarati@aero.polimi.it>
41  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
42  *
43  * Modified by Pierangelo Masarati
44  */
45 
46 #ifndef MODAL_H
47 #define MODAL_H
48 
49 #include <fstream>
50 #include <joint.h>
51 
52 #if !defined(MODAL_USE_AUTODIFF)
53 #define MODAL_USE_AUTODIFF USE_AUTODIFF
54 #endif
55 
56 #if USE_AUTODIFF && MODAL_USE_AUTODIFF
57 #include <gradient.h>
58 #include <matvec.h>
59 #include <matvecass.h>
60 #endif
61 
62 #if 0
63 #define MODAL_USE_INV9
64 #endif
65 
66 /* Modal - begin */
67 
68 /*
69  * ATTENZIONE!
70  * per ora e' derivato da Joint;
71  * puo' darsi che venga creata una classe apposta
72  */
73 
74 class Modal : virtual public Elem, public Joint {
75 public:
76  struct StrNodeData;
77 
78 private:
79 #if USE_AUTODIFF && MODAL_USE_AUTODIFF
80  inline void
81  UpdateStrNodeData(StrNodeData& oNode,
82  const grad::Vector<doublereal, 3>& d1tot,
83  const grad::Matrix<doublereal, 3, 3>& R1tot,
87  inline void
88  UpdateStrNodeData(StrNodeData& oNode,
89  const grad::Vector<grad::Gradient<0>, 3>& d1tot,
90  const grad::Matrix<grad::Gradient<0>, 3, 3>& R1tot,
91  const grad::Vector<grad::Gradient<0>, 3>& F,
92  const grad::Vector<grad::Gradient<0>, 3>& M,
93  const grad::Matrix<grad::Gradient<0>, 3, 3>& R2) {}
94 
95  inline void
96  UpdateModalNode(const grad::Vector<doublereal, 3>& x,
98 
99  inline void
100  UpdateModalNode(const grad::Vector<grad::Gradient<0>, 3>& x,
101  const grad::Matrix<grad::Gradient<0>, 3, 3>& R) {}
102 
103  inline void
108 
109  inline void
114 
115  inline void
116  UpdateInvariants(const grad::Vector<doublereal, 3>& Inv3jaj,
119 
120  inline void
121  UpdateInvariants(const grad::Vector<grad::Gradient<0>, 3>& Inv3jaj,
122  const grad::Matrix<grad::Gradient<0>, 3, 3>& Inv8jaj,
123  const grad::Matrix<grad::Gradient<0>, 3, 3>& Inv9jkajak) {}
124 
125  grad::LocalDofMap dofMap;
126 #endif
127 
128 protected:
129  const ModalNode* const pModalNode;
130  const unsigned iRigidOffset; /* 0 iff pModalNode == 0; else 12 */
131 
132  /* configuration of reference point;
133  * from ModalNode iff pModalNode == 0 */
134  mutable Vec3 x;
135  mutable Mat3x3 R;
136  mutable Mat3x3 RT;
137 
138  const unsigned int NModes;
139  const unsigned int NStrNodes;
140 
141  const unsigned int NFEMNodes; // number of FEM nodes, common
142  const std::vector<std::string> IdFEMNodes; // ID of FEM nodes, common
143  const Mat3xN *pXYZFEMNodes; // local position of FEM nodes, common
144  const doublereal dMass; // mass, common
145  const Vec3 Inv2; // undeformed static moment, common
146  const Mat3x3 Inv7; // undeformed inertia moment, common
147 
148  const std::vector<unsigned int> uModeNumber;
152 
153  const Mat3xN *pPHIt;
154  const Mat3xN *pPHIr;
155 
158 
161 
162  const Mat3xN *pInv3;
163  const Mat3xN *pInv4;
164  const Mat3xN *pInv5;
165  const Mat3xN *pInv8;
166  const Mat3xN *pInv9;
167 
168  const Mat3xN *pInv10;
169  const Mat3xN *pInv11;
170 
172 
173 #if !(USE_AUTODIFF && MODAL_USE_AUTODIFF) || MODAL_DEBUG_AUTODIFF
175 #endif
176 
178 
179 #if !(USE_AUTODIFF && MODAL_USE_AUTODIFF) || MODAL_DEBUG_AUTODIFF
183 #endif
185 
186 #if !(USE_AUTODIFF && MODAL_USE_AUTODIFF) || MODAL_DEBUG_AUTODIFF
188 #endif
189 
194 
195 public:
196  struct StrNodeData {
197  // constant, defined once for all at input
199  std::string FEMNode;
203 
204  // variable, constructed during analysis
208 
209  // variable, constructed during analysis
212 
213  bool bOut;
214  };
215 
216 protected:
217  std::vector<StrNodeData> SND;
218 
219  /* from gravity.h */
220  /* momento statico */
221  Vec3 GetS_int(void) const;
222 
223  /* momento d'inerzia */
224  Mat3x3 GetJ_int(void) const;
225 
226  Vec3 GetB_int(void) const;
227  Vec3 GetG_int(void) const;
228 
229 public:
230  /* Costruttore non banale */
231  Modal(unsigned int uL,
232  const ModalNode* pModalNodeTmp,
233  const Vec3& x0,
234  const Mat3x3& R0,
235  const DofOwner* pDO,
236  unsigned int N,
237  unsigned int NS,
238  unsigned int NFN,
240  const Vec3& STmp,
241  const Mat3x3& JTmp,
242  const std::vector<unsigned int>& uModeNumber,
243  MatNxN *pGenMass,
244  MatNxN *pGenStiff,
245  MatNxN *pGenDamp,
246  const std::vector<std::string>& IdFEMNodes,
247  Mat3xN *pN,
248  const std::vector<Modal::StrNodeData>& snd,
249  Mat3xN *pPHIt,
250  Mat3xN *pPHIr,
253  Mat3xN *pInv3,
254  Mat3xN *pInv4,
255  Mat3xN *pInv5,
256  Mat3xN *pInv8,
257  Mat3xN *pInv9,
258  Mat3xN *pInv10,
259  Mat3xN *pInv11,
260  VecN *a,
261  VecN *aP,
262  flag fOut);
263 
264  /* Distruttore */
265  ~Modal(void);
266 
267  /* Tipo di Joint */
268  virtual Joint::Type GetJointType(void) const;
269 
270  /* Contributo al file di restart */
271  virtual std::ostream& Restart(std::ostream& out) const;
272 
273  virtual unsigned int iGetNumDof(void) const;
274  virtual std::ostream&
275  DescribeDof(std::ostream& out,
276  const char *prefix = "",
277  bool bInitial = false) const;
278  virtual void
279  DescribeDof(std::vector<std::string>& desc,
280  bool bInitial = false,
281  int i = -1) const;
282  virtual std::ostream&
283  DescribeEq(std::ostream& out,
284  const char *prefix = "",
285  bool bInitial = false) const;
286  virtual void
287  DescribeEq(std::vector<std::string>& desc,
288  bool bInitial = false,
289  int i = -1) const;
290  DofOrder::Order GetDofType(unsigned int i) const;
291  DofOrder::Order GetEqType(unsigned int i) const;
292 
293  void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
294 
297  const VectorHandler& XCurr,
298  const VectorHandler& XPrimeCurr);
300  AssRes(SubVectorHandler& WorkVec, doublereal dCoef,
301  const VectorHandler& XCurr,
302  const VectorHandler& XPrimeCurr);
303 
304 #if USE_AUTODIFF && MODAL_USE_AUTODIFF
305  template <typename T>
306  void
308  doublereal dCoef,
309  const grad::GradientVectorHandler<T>& XCurr,
310  const grad::GradientVectorHandler<T>& XPrimeCurr,
311  enum grad::FunctionCall func);
312 #endif
313  void Output(OutputHandler& OH) const;
314 
315  /* funzioni usate nell'assemblaggio iniziale */
316 
317  virtual unsigned int iGetInitialNumDof(void) const;
318  virtual void
319  InitialWorkSpaceDim(integer* piNumRows, integer* piNumCols) const;
320 
321  /* Contributo allo jacobiano durante l'assemblaggio iniziale */
324  const VectorHandler& XCurr);
325  /* Contributo al residuo durante l'assemblaggio iniziale */
327  InitialAssRes(SubVectorHandler& WorkVec, const VectorHandler& XCurr);
328 
329  /* Setta il valore iniziale delle proprie variabili */
330  void SetInitialValue(VectorHandler& /* X */ );
331 
332  void SetValue(DataManager *pDM,
333  VectorHandler& /* X */ , VectorHandler& /* XP */ ,
334  SimulationEntity::Hints *ph = 0);
335 
336 #if 0
337  /* Aggiorna dati durante l'iterazione fittizia iniziale */
338  virtual void DerivativesUpdate(const VectorHandler& X,
339  const VectorHandler& XP);
340 #endif
341 
342  /* Dati privati */
343  virtual unsigned int iGetNumPrivData(void) const;
344  virtual unsigned int iGetPrivDataIdx(const char *s) const;
345  virtual doublereal dGetPrivData(unsigned int i) const;
346 
347  /* Funzioni che restituiscono dati che possono servire ad
348  * altri elementi (ad es. agli elementi aerodinamici modali)
349  */
350 
351  const Mat3xN& pGetPHIt(void) const {
352  return *pModeShapest;
353  };
354 
355  const Mat3xN& pGetPHIr(void) const {
356  return *pModeShapesr;
357  };
358 
359  // NOTE: not 'const' because modify internal storage
360  const Mat3xN& GetCurrFEMNodesPosition(void);
361  const Mat3xN& GetCurrFEMNodesVelocity(void);
362 
363  integer uGetNModes(void) const {
364  return NModes;
365  };
366 
367  const std::vector<unsigned int>& GetModeList(void) const {
368  return uModeNumber;
369  };
370 
371  const VecN& GetA(void) const {
372  return a;
373  };
374 
375  const VecN& GetAP(void) const {
376  return aPrime;
377  };
378 
379  const VecN& GetB(void) const {
380  return b;
381  };
382 
383  const VecN& GetBP(void) const {
384  return bPrime;
385  };
386 
388  return NFEMNodes;
389  };
390 
391  integer iGetModalIndex(void) const {
392  return iGetFirstIndex();
393  };
394 
395  const ModalNode* pGetModalNode(void) const {
396  return pModalNode;
397  };
398 
399  /* from gravity.h */
400  /* massa totale */
401  doublereal dGetM(void) const;
402 
403  /* *******PER IL SOLUTORE PARALLELO******** */
404  /* Fornisce il tipo e la label dei nodi che sono connessi all'elemento
405  * utile per l'assemblaggio della matrice di connessione fra i dofs */
406  virtual void
407  GetConnectedNodes(std::vector<const Node *>& connectedNodes) const {
408  connectedNodes.resize(NStrNodes + (pModalNode ? 1 : 0));
409  for (unsigned int j = 0; j < NStrNodes; j++) {
410  connectedNodes[j] = SND[j].pNode;
411  }
412  if (pModalNode) {
413  connectedNodes[NStrNodes] = pModalNode;
414  }
415  };
416  /* ************************************************ */
417 };
418 
419 /* Modal - end */
420 
421 class DataManager;
422 class MBDynParser;
423 
424 extern Joint *
425 ReadModal(DataManager* pDM, MBDynParser& HP, const DofOwner* pD0,
426  unsigned int uLabel);
427 
428 #endif /* MODAL_H */
429 
const ModalNode * pGetModalNode(void) const
Definition: modal.h:395
SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)
Definition: modal.cc:2411
Vec3 Inv3jaPj
Definition: modal.h:174
Type
Definition: joint.h:66
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: modal.cc:283
Vec3 GetB_int(void) const
Definition: modal.cc:3171
const Mat3xN * pModeShapesr
Definition: modal.h:157
const Mat3xN * pModeShapest
Definition: modal.h:156
long int flag
Definition: mbdyn.h:43
Mat3x3 GetJ_int(void) const
Definition: modal.cc:3142
Mat3x3 RotMB
Definition: modal.h:202
const VecN & GetA(void) const
Definition: modal.h:371
Mat3x3 Inv8jaPj
Definition: modal.h:180
Definition: matvec3.h:98
static const index_type DYNAMIC_SIZE
Definition: gradient.h:141
const MatNxN * pModalMass
Definition: modal.h:149
void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: modal.cc:529
Mat3xN Inv5jaj
Definition: modal.h:181
VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: modal.cc:543
const doublereal dMass
Definition: modal.h:144
Vec3 x
Definition: modal.h:134
const Mat3xN * pPHIr
Definition: modal.h:154
integer uGetNModes(void) const
Definition: modal.h:363
void SetInitialValue(VectorHandler &)
Definition: modal.cc:2664
doublereal dGetM(void) const
Definition: modal.cc:3118
const std::vector< unsigned int > uModeNumber
Definition: modal.h:148
const Mat3xN * pInv4
Definition: modal.h:163
VecN bPrime
Definition: modal.h:193
VecN aPrime0
Definition: modal.h:191
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: modal.cc:2743
VecN aPrime
Definition: modal.h:191
std::string FEMNode
Definition: modal.h:199
const Vec3 Inv2
Definition: modal.h:145
std::vector< Hint * > Hints
Definition: simentity.h:89
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const
Definition: modal.cc:1948
Mat3x3 Inv8jaj
Definition: modal.h:177
DofOrder::Order GetEqType(unsigned int i) const
Definition: modal.cc:514
const Mat3xN & GetCurrFEMNodesPosition(void)
Definition: modal.cc:3046
const Mat3xN * pInv3
Definition: modal.h:162
void Output(OutputHandler &OH) const
Definition: modal.cc:1914
const StructNode * pNode
Definition: modal.h:198
~Modal(void)
Definition: modal.cc:210
DofOrder::Order GetDofType(unsigned int i) const
Definition: modal.cc:499
Definition: modal.h:74
void func(const T &u, const T &v, const T &w, doublereal e, T &f)
const Mat3xN & GetCurrFEMNodesVelocity(void)
Definition: modal.cc:3077
const VecN & GetB(void) const
Definition: modal.h:379
Mat3xN * pCurrXYZVel
Definition: modal.h:160
void SetValue(DataManager *pDM, VectorHandler &, VectorHandler &, SimulationEntity::Hints *ph=0)
Definition: modal.cc:2687
const ModalNode *const pModalNode
Definition: modal.h:76
virtual std::ostream & Restart(std::ostream &out) const
Definition: modal.cc:268
Mat3x3 RT
Definition: modal.h:136
Mat3x3 R1tot
Definition: modal.h:206
const Mat3xN & pGetPHIt(void) const
Definition: modal.h:351
DataManager * pDM
Definition: mbpar.h:252
FunctionCall
Definition: gradient.h:1018
const Mat3xN * pPHIt
Definition: modal.h:153
Mat3x3 Inv9jkajaPk
Definition: modal.h:187
VecN b
Definition: modal.h:192
std::vector< StrNodeData > SND
Definition: modal.h:217
const std::vector< std::string > IdFEMNodes
Definition: modal.h:142
const unsigned int NModes
Definition: modal.h:138
VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)
Definition: modal.cc:1955
const Mat3xN & pGetPHIr(void) const
Definition: modal.h:355
const Mat3xN * pInv5
Definition: modal.h:164
SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: modal.cc:924
VecN a0
Definition: modal.h:190
const unsigned iRigidOffset
Definition: modal.h:130
integer iGetModalIndex(void) const
Definition: modal.h:391
const MatNxN * pModalDamp
Definition: modal.h:151
Definition: elem.h:75
Mat3xN * pCurrXYZ
Definition: modal.h:159
Vec3 GetS_int(void) const
Definition: modal.cc:3125
Mat3x3 Inv9jkajak
Definition: modal.h:184
Vec3 GetG_int(void) const
Definition: modal.cc:3183
Vec3 Inv3jaj
Definition: modal.h:171
const Mat3xN * pXYZFEMNodes
Definition: modal.h:143
const Mat3xN * pInv9
Definition: modal.h:166
virtual void DerivativesUpdate(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: simentity.cc:105
virtual unsigned int iGetInitialNumDof(void) const
Definition: modal.cc:1942
Definition: matvec3n.h:76
const MatNxN * pModalStiff
Definition: modal.h:150
virtual doublereal dGetPrivData(unsigned int i) const
Definition: modal.cc:2903
virtual unsigned int iGetNumDof(void) const
Definition: modal.cc:274
Definition: joint.h:50
const VecN & GetAP(void) const
Definition: modal.h:375
virtual Joint::Type GetJointType(void) const
Definition: modal.cc:262
virtual integer iGetFirstIndex(void) const
Definition: dofown.h:127
double doublereal
Definition: colamd.c:52
const Mat3xN * pInv11
Definition: modal.h:169
Mat3xN Inv5jaPj
Definition: modal.h:182
long int integer
Definition: colamd.c:51
integer uGetNFEMNodes(void)
Definition: modal.h:387
const VecN & GetBP(void) const
Definition: modal.h:383
const std::vector< unsigned int > & GetModeList(void) const
Definition: modal.h:367
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: modal.cc:402
const Mat3xN * pInv8
Definition: modal.h:165
VecN a
Definition: modal.h:190
const unsigned int NFEMNodes
Definition: modal.h:141
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: modal.h:407
const unsigned int NStrNodes
Definition: modal.h:139
Modal(unsigned int uL, const ModalNode *pModalNodeTmp, const Vec3 &x0, const Mat3x3 &R0, const DofOwner *pDO, unsigned int N, unsigned int NS, unsigned int NFN, doublereal dMass, const Vec3 &STmp, const Mat3x3 &JTmp, const std::vector< unsigned int > &uModeNumber, MatNxN *pGenMass, MatNxN *pGenStiff, MatNxN *pGenDamp, const std::vector< std::string > &IdFEMNodes, Mat3xN *pN, const std::vector< Modal::StrNodeData > &snd, Mat3xN *pPHIt, Mat3xN *pPHIr, Mat3xN *pModeShapest, Mat3xN *pModeShapesr, Mat3xN *pInv3, Mat3xN *pInv4, Mat3xN *pInv5, Mat3xN *pInv8, Mat3xN *pInv9, Mat3xN *pInv10, Mat3xN *pInv11, VecN *a, VecN *aP, flag fOut)
Definition: modal.cc:123
Mat3x3 R
Definition: modal.h:135
virtual unsigned int iGetNumPrivData(void) const
Definition: modal.cc:2737
const Mat3xN * pInv10
Definition: modal.h:168
const Mat3x3 Inv7
Definition: modal.h:146