MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
simentity.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/simentity.h,v 1.38 2017/01/12 14:46:10 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 #ifndef SIMENTITY_H
33 #define SIMENTITY_H
34 
35 #include <vector>
36 
37 #include "myassert.h"
38 
39 /* include del programma */
40 #include "output.h"
41 #include "withlab.h"
42 #include "dofown.h"
43 #include "drive.h"
44 #include "hint.h"
45 #include "invdyn.h"
46 
47 /* SimulationEntity - begin */
48 
49 /*
50  * Functional class that introduces methods to handle the simulation.
51  *
52  * Ancestor of nodes and elements.
53  *
54  * Usage pattern:
55  *
56  * pre-operation:
57  * iGetNumDof()
58  * bIsValidIndex()
59  * GetDofType()
60  * GetEqType()
61  * SetValue()
62  * iGetNumPrivData()
63  * iGetPrivDataIdx()
64  *
65  * runtime:
66  * BeforePredict() : prepare for prediction
67  * AfterPredict() : account for predicted state
68  * Update() : use converged solution
69  * AfterConvergence() : account for conveged state
70  * dGetPrivData() : get an internal state
71  */
72 
73 class MBDynParser;
74 class DataManager;
75 
77 protected:
78 #if 0
79  /* punta a un vettore di due elementi che sono il valore
80  * iniziale dello stato e la sua derivata prima */
81  const VectorHandler const** ppX0_Xp0;
82 #endif
83 
84 public:
85  SimulationEntity(void);
86  virtual ~SimulationEntity(void);
87 
88  /* used to pass hints to SetValue */
89  typedef std::vector<Hint *> Hints;
90 
91  /*
92  * Ritorna il numero di DoFs.
93  * Non usa il DofOwner in quanto viene usata per generale il DofOwner
94  * stesso (per compatibilita' con gli elementi che generano gradi di
95  * liberta' ed in previsione di nodi con un numero variabile di DoF)
96  */
97  virtual unsigned int iGetNumDof(void) const = 0;
98 
99  /*
100  * Describe the degrees of freedom
101  */
102  virtual std::ostream& DescribeDof(std::ostream& out,
103  const char *prefix = "",
104  bool bInitial = false) const = 0;
105  virtual void DescribeDof(std::vector<std::string>& desc,
106  bool bInitial = false, int i = -1) const = 0;
107 
108  /*
109  * Describe the degrees of freedom
110  */
111  virtual std::ostream& DescribeEq(std::ostream& out,
112  const char *prefix = "",
113  bool bInitial = false) const = 0;
114  virtual void DescribeEq(std::vector<std::string>& desc,
115  bool bInitial = false, int i = -1) const = 0;
116 
117  /*
118  * Test di validita' di un indice.
119  * Nota: gli indici vanno da 1 a iGetNumDofs()
120  */
121  virtual bool bIsValidIndex(unsigned int i) const;
122 
123  /*
124  * Esegue operazioni sui DoF di proprieta' dell'elemento.
125  * In particolare ritorna il tipo di DoF in base all'indice i.
126  * Di default i DoF dei nodi sono assunti differenziali.
127  * Il tipo e' preso dall'enum DofOrder.
128  * Nota: gli indici sono in base 0, ovvero deve essere
129  * 0 < i < iGetNumDof()
130  * @see DofOrder
131  */
132  virtual DofOrder::Order GetDofType(unsigned int i) const = 0;
133 
134  /*
135  * Complementare di GetDofType(); dice che tipo di equazione
136  * corrisponde al dof i (ALGEBRAIC o DIFFERENTIAL).
137  */
138  virtual DofOrder::Order GetEqType(unsigned int i) const
139 #if 0
140  = 0
141 #else
142  { return DofOrder::DIFFERENTIAL; }
143 #endif
144  ;
145 
146  /* Metodi legati all'integrazione */
147 
148  /*
149  * Setta i valori iniziali dei DoF.
150  * Puo' essere usata per altre inizializzazioni prima di
151  * iniziare l'integrazione
152  */
153  virtual void SetValue(DataManager *pDM,
155  SimulationEntity::Hints* h = 0);
156 
157  virtual Hint *
158  ParseHint(DataManager *pDM, const char *s) const;
159 
160  /*
161  * Elaborazione vettori e dati prima della predizione.
162  * Per MultiStepIntegrator
163  */
164  virtual void BeforePredict(VectorHandler& /* X */ ,
165  VectorHandler& /* XP */ ,
166  VectorHandler& /* XPrev */ ,
167  VectorHandler& /* XPPrev */ ) const;
168 
169  /*
170  * Elaborazione vettori e dati dopo la predizione.
171  * Per MultiStepIntegrator
172  */
173  virtual void AfterPredict(VectorHandler& X, VectorHandler& XP);
174 
175  /*
176  * Aggiorna dati in base alla soluzione.
177  * Usata per operazioni aggiuntive al semplice aggiornamento additivo,
178  * effettuato gia' dall'integratore.
179  */
180  virtual void Update(const VectorHandler& XCurr,
181  const VectorHandler& XPrimeCurr);
182 
183  virtual void DerivativesUpdate(const VectorHandler& XCurr,
184  const VectorHandler& XPrimeCurr);
185 
186  /* Inverse Dynamics:*/
187  virtual void Update(const VectorHandler& XCurr,
188  InverseDynamics::Order iOrder);
189  /*
190  * Elaborazione stato interno dopo la convergenza
191  */
192  virtual void AfterConvergence(const VectorHandler& X,
193  const VectorHandler& XP);
194 
195  /* Inverse Dynamics:*/
196  virtual void AfterConvergence(const VectorHandler& X,
197  const VectorHandler& XP,
198  const VectorHandler& XPP);
199 
200  /*
201  * Metodi per l'estrazione di dati "privati".
202  * Si suppone che l'estrattore li sappia interpretare.
203  * Come default non ci sono dati privati estraibili
204  */
205  virtual unsigned int iGetNumPrivData(void) const;
206 
207  /*
208  * Maps a string (possibly with substrings) to a private data;
209  * returns a valid index ( > 0 && <= iGetNumPrivData()) or 0
210  * in case of unrecognized data; error must be handled by caller
211  */
212  virtual unsigned int iGetPrivDataIdx(const char *s) const;
213 
214  /*
215  * Returns the current value of a private data
216  * with 0 < i <= iGetNumPrivData()
217  */
218  virtual doublereal dGetPrivData(unsigned int i) const;
219 
220  /*
221  * Contributes to output on a stream
222  */
223  virtual std::ostream& OutputAppend(std::ostream& out) const;
224  virtual void ReadInitialState(MBDynParser& HP);
225 
226 };
227 
228 /* SimulationEntity - end */
229 
230 #endif /* SIMENTITY_H */
231 
Definition: hint.h:38
virtual DofOrder::Order GetEqType(unsigned int i) const
Definition: simentity.h:138
virtual Hint * ParseHint(DataManager *pDM, const char *s) const
Definition: simentity.cc:76
virtual unsigned int iGetPrivDataIdx(const char *s) const
Definition: simentity.cc:142
virtual void ReadInitialState(MBDynParser &HP)
Definition: simentity.cc:161
std::vector< Hint * > Hints
Definition: simentity.h:89
virtual std::ostream & DescribeDof(std::ostream &out, const char *prefix="", bool bInitial=false) const =0
virtual std::ostream & DescribeEq(std::ostream &out, const char *prefix="", bool bInitial=false) const =0
SimulationEntity(void)
Definition: simentity.cc:43
virtual DofOrder::Order GetDofType(unsigned int i) const =0
virtual std::ostream & OutputAppend(std::ostream &out) const
Definition: simentity.cc:156
virtual void BeforePredict(VectorHandler &, VectorHandler &, VectorHandler &, VectorHandler &) const
Definition: simentity.cc:82
virtual doublereal dGetPrivData(unsigned int i) const
Definition: simentity.cc:149
virtual unsigned int iGetNumPrivData(void) const
Definition: simentity.cc:136
virtual bool bIsValidIndex(unsigned int i) const
Definition: simentity.cc:54
virtual unsigned int iGetNumDof(void) const =0
virtual void AfterConvergence(const VectorHandler &X, const VectorHandler &XP)
Definition: simentity.cc:120
virtual void DerivativesUpdate(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: simentity.cc:105
virtual void AfterPredict(VectorHandler &X, VectorHandler &XP)
Definition: simentity.cc:91
virtual void SetValue(DataManager *pDM, VectorHandler &X, VectorHandler &XP, SimulationEntity::Hints *h=0)
Definition: simentity.cc:63
double doublereal
Definition: colamd.c:52
virtual ~SimulationEntity(void)
Definition: simentity.cc:48
virtual void Update(const VectorHandler &XCurr, const VectorHandler &XPrimeCurr)
Definition: simentity.cc:98