MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
elem.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/elem.h,v 1.77 2017/05/12 17:28:14 morandini 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 /*****************************************************************************
33  * *
34  * MBDyn - Elements *
35  * *
36  *****************************************************************************/
37 
38 
39 #ifndef ELEM_H
40 #define ELEM_H
41 
42 #include <vector>
43 
44 #include "myassert.h"
45 #include "except.h"
46 
47 #include "solman.h"
48 #include "submat.h"
49 #include "output.h"
50 
51 #include "withlab.h"
52 #include "dofown.h"
53 
54 #include "invdyn.h"
55 #include "simentity.h"
56 #include "node.h"
57 
58 #ifdef USE_MULTITHREAD
59 #include "veciter.h"
60 #endif /* USE_MULTITHREAD */
61 
62 extern const char* psElemNames[];
63 extern const char* psReadControlElems[];
64 extern const char* psReadElemsElems[];
65 
66 /* classi dichiarate */
67 class ElemWithDofs;
68 class ElemGravityOwner;
69 class AerodynamicElem;
71 class InducedVelocity;
72 
73 /* Elem - begin */
74 
75 class Elem : public WithLabel, public SimulationEntity, public ToBeOutput
76 #ifdef USE_MULTITHREAD
77 , public InUse
78 #endif /* USE_MULTITHREAD */
79 {
80 private:
82 
83  /*
84  * Tipi di Elem. Lasciare sempre UNKNOWN = -1, cosi' il primo elemento
85  * ha tipo zero, e l'ultima entry dell'enum, LAST...TYPE, e' uguale
86  * al numero di tipi definiti, quindi puo' essere usata come costante nel
87  * dimensionamento degli arrays e come flag di fine tipi.
88  */
89 
90 public:
91  enum Type {
92  UNKNOWN = -1,
93 
94  // induced velocity must be as early as possible,
95  // but after air properties
98 
100 
107 
109 
111 
114 
116 
118 
123 
124  /* other aerodynamic elements must be as late as possible */
127 
129 
132 
134  };
135 
137  public:
139  };
140 
141 public:
142  Elem(unsigned int uL, flag fOut);
143  virtual ~Elem(void);
144 
145  /* Scrive il contributo dell'elemento al file di restart */
146  virtual std::ostream& Restart(std::ostream& out) const = 0;
147 
148  /* Tipo dell'elemento (usato solo per debug ecc.) */
149  virtual Elem::Type GetElemType(void) const = 0;
150 
151  /* inherited from SimulationEntity */
152  virtual unsigned int iGetNumDof(void) const;
153  virtual std::ostream& DescribeDof(std::ostream& out,
154  const char *prefix = "", bool bInitial = false) const;
155  virtual void DescribeDof(std::vector<std::string>& desc,
156  bool bInitial = false, int i = -1) const;
157  virtual std::ostream& DescribeEq(std::ostream& out,
158  const char *prefix = "", bool bInitial = false) const;
159  virtual void DescribeEq(std::vector<std::string>& desc,
160  bool bInitial = false, int i = -1) const;
161  virtual DofOrder::Order GetDofType(unsigned int) const;
162 
163  /* funzioni di servizio */
164 
165  /* Il metodo iGetNumDof() serve a ritornare il numero di gradi di liberta'
166  * propri che l'elemento definisce. Non e' virtuale in quanto serve a
167  * ritornare 0 per gli elementi che non possiedono gradi di liberta'.
168  * Viene usato nella costruzione dei DofOwner e quindi deve essere
169  * indipendente da essi. In genere non comporta overhead in quanto il
170  * numero di dof aggiunti da un tipo e' una costante e non richede dati
171  * propri.
172  * Il metodo pGetDofOwner() ritorna il puntatore al DofOwner dell'oggetto.
173  * E' usato da tutti quelli che agiscono direttamente sui DofOwner.
174  * Non e' virtuale in quanto ritorn a NULL per tutti i tipi che non hanno
175  * dof propri.
176  * Il metodo GetDofType() ritorna, per ogni dof dell'elemento, l'ordine.
177  * E' usato per completare i singoli Dof relativi all'elemento.
178  */
179 
180  /* funzioni proprie */
181 
182  /* Dimensioni del workspace */
183  virtual void WorkSpaceDim(integer* piNumRows, integer* piNumCols) const = 0;
184 
185  /* assemblaggio matrici per autovalori */
186  virtual void
188  VariableSubMatrixHandler& WorkMatB,
189  const VectorHandler& XCurr,
190  const VectorHandler& XPrimeCurr);
191 
192  /* assemblaggio residuo */
193  virtual SubVectorHandler&
194  AssRes(SubVectorHandler& WorkVec,
195  doublereal dCoef,
196  const VectorHandler& XCurr,
197  const VectorHandler& XPrimeCurr) = 0;
198 
199  /* assemblaggio jacobiano */
200  virtual VariableSubMatrixHandler&
202  doublereal dCoef,
203  const VectorHandler& XCurr,
204  const VectorHandler& XPrimeCurr) = 0;
205 
206  /* inverse dynamics capable element */
207  virtual bool bInverseDynamics(void) const;
208 
209  void SetInverseDynamicsFlags(unsigned uIDF);
210  unsigned GetInverseDynamicsFlags(void) const;
211  bool bIsErgonomy(void) const;
212  bool bIsRightHandSide(void) const;
213 
214  /* inverse dynamics Jacobian matrix assembly */
215  virtual VariableSubMatrixHandler&
217  const VectorHandler& XCurr);
218 
219  /* inverse dynamics residual assembly */
220  virtual SubVectorHandler&
221  AssRes(SubVectorHandler& WorkVec,
222  const VectorHandler& XCurr,
223  const VectorHandler& XPrimeCurr,
224  const VectorHandler& XPrimePrimeCurr,
226 
227  /* returns the number of connected nodes */
228  virtual inline int GetNumConnectedNodes(void) const;
229  virtual inline void GetConnectedNodes(std::vector<const Node *>& connectedNodes) const;
230 
231 };
232 
233 inline int
235 {
236  std::vector<const Node *> connectedNodes;
237  GetConnectedNodes(connectedNodes);
238 
239  return connectedNodes.size();
240 }
241 
242 inline void
243 Elem::GetConnectedNodes(std::vector<const Node *>& connectedNodes) const
244 {
245  connectedNodes.resize(0);
246 }
247 
248 
249 Elem::Type str2elemtype(const char *const s);
250 
251 /* Elem - end */
252 
253 
254 /* Functional object that reads elements */
255 
256 /* ElemRead - begin */
257 
258 struct ElemRead {
259  virtual ~ElemRead( void ) { NO_OP; };
260  virtual Elem *Read(const DataManager* pDM, MBDynParser& HP) = 0;
261 };
262 
263 /* ElemRead - end */
264 
265 /* register an ElemRead object */
266 extern bool
267 SetElem(const char *name, ElemRead *rf);
268 
269 /* create/destroy */
270 extern void InitElem(void);
271 extern void DestroyElem(void);
272 
273 /* Classe derivata da elem, relativa ad elementi che possiedono gradi di
274  * liberta' propri */
275 
276 /* ElemWithDofs - begin */
277 
278 class ElemWithDofs : virtual public Elem, public DofOwnerOwner {
279 public:
280  ElemWithDofs(unsigned int uL,
281  const DofOwner* pDO, flag fOut);
282 
283  virtual ~ElemWithDofs(void);
284 };
285 
286 /* ElemWithDofs - end */
287 
288 
289 /* SubjectToInitialAssembly - begin */
290 
292 public:
294  virtual ~SubjectToInitialAssembly(void);
295 
296  /* Numero di gradi di liberta' definiti durante l'assemblaggio iniziale
297  * e' dato dai gradi di liberta' soliti piu' le loro derivate necessarie;
298  * tipicamente per un vincolo di posizione il numero di dof raddoppia, in
299  * quanto vengono derivate tutte le equazioni, mentre per un vincolo di
300  * velocita' rimane inalterato. Sono possibili casi intermedi per vincoli
301  * misti di posizione e velocita' */
302  virtual unsigned int iGetInitialNumDof(void) const = 0;
303 
304  /* Dimensione del workspace durante l'assemblaggio iniziale. Occorre tener
305  * conto del numero di dof che l'elemento definisce in questa fase e dei
306  * dof dei nodi che vengono utilizzati. Sono considerati dof indipendenti
307  * la posizione e la velocita' dei nodi */
308  virtual void InitialWorkSpaceDim(integer* piNumRows,
309  integer* piNumCols) const = 0;
310 
311  /* Contributo allo jacobiano durante l'assemblaggio iniziale */
312  virtual VariableSubMatrixHandler&
314  const VectorHandler& XCurr) = 0;
315 
316  /* Contributo al residuo durante l'assemblaggio iniziale */
317  virtual SubVectorHandler&
319  const VectorHandler& XCurr) = 0;
320 };
321 
322 /* SubjectToInitialAssembly - end */
323 
324 
325 /* InitialAssemblyElem - begin */
326 
328 : virtual public Elem, public SubjectToInitialAssembly {
329 public:
330  InitialAssemblyElem(unsigned int uL, flag fOut);
331  virtual ~InitialAssemblyElem(void);
332 };
333 
334 /* InitialAssemblyElem - end */
335 
336 #endif // ELEM_H
virtual bool bInverseDynamics(void) const
Definition: elem.cc:65
ElemWithDofs(unsigned int uL, const DofOwner *pDO, flag fOut)
Definition: elem.cc:200
long int flag
Definition: mbdyn.h:43
Elem::Type str2elemtype(const char *const s)
Definition: elem.cc:159
virtual unsigned int iGetInitialNumDof(void) const =0
#define MBDYN_EXCEPT_ARGS_PASSTHRU
Definition: except.h:55
bool bIsErgonomy(void) const
Definition: elem.cc:83
virtual ~InitialAssemblyElem(void)
Definition: elem.cc:239
SubjectToInitialAssembly(void)
Definition: elem.cc:217
bool bIsRightHandSide(void) const
Definition: elem.cc:89
void InitElem(void)
#define MBDYN_EXCEPT_ARGS_DECL
Definition: except.h:43
#define NO_OP
Definition: myassert.h:74
virtual void InitialWorkSpaceDim(integer *piNumRows, integer *piNumCols) const =0
virtual Elem::Type GetElemType(void) const =0
virtual Elem * Read(const DataManager *pDM, MBDynParser &HP)=0
void SetInverseDynamicsFlags(unsigned uIDF)
Definition: elem.cc:71
virtual std::ostream & Restart(std::ostream &out) const =0
bool SetElem(const char *name, ElemRead *rf)
Definition: elem.cc:191
unsigned m_uInverseDynamicsFlags
Definition: elem.h:81
virtual ~Elem(void)
Definition: elem.cc:48
virtual ~SubjectToInitialAssembly(void)
Definition: elem.cc:223
virtual ~ElemWithDofs(void)
Definition: elem.cc:207
virtual VariableSubMatrixHandler & InitialAssJac(VariableSubMatrixHandler &WorkMat, const VectorHandler &XCurr)=0
Definition: elem.h:258
virtual ~ElemRead(void)
Definition: elem.h:259
virtual SubVectorHandler & InitialAssRes(SubVectorHandler &WorkVec, const VectorHandler &XCurr)=0
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: elem.cc:137
unsigned GetInverseDynamicsFlags(void) const
Definition: elem.cc:77
virtual unsigned int iGetNumDof(void) const
Definition: elem.cc:118
virtual void GetConnectedNodes(std::vector< const Node * > &connectedNodes) const
Definition: elem.h:243
void DestroyElem(void)
ChangedEquationStructure(MBDYN_EXCEPT_ARGS_DECL)
Definition: elem.h:138
Definition: elem.h:75
Type
Definition: elem.h:91
const char * psElemNames[]
Definition: enums.cc:39
virtual DofOrder::Order GetDofType(unsigned int) const
Definition: elem.cc:150
const char * psReadControlElems[]
Definition: enums.cc:122
virtual void WorkSpaceDim(integer *piNumRows, integer *piNumCols) const =0
virtual int GetNumConnectedNodes(void) const
Definition: elem.h:234
virtual void AssMats(VariableSubMatrixHandler &WorkMatA, VariableSubMatrixHandler &WorkMatB, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: elem.cc:55
virtual SubVectorHandler & AssRes(SubVectorHandler &WorkVec, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0
const char * psReadElemsElems[]
Definition: enums.cc:79
InitialAssemblyElem(unsigned int uL, flag fOut)
Definition: elem.cc:233
Elem(unsigned int uL, flag fOut)
Definition: elem.cc:41
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const
Definition: elem.cc:124
virtual VariableSubMatrixHandler & AssJac(VariableSubMatrixHandler &WorkMat, doublereal dCoef, const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)=0