All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
object.h
1 /* Copyright (C) 2004-2014 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _OBJECT_H_
21 #define _OBJECT_H_
22 
23 #include "mbsim/element.h"
24 //#include "mbsim/object_interface.h"
25 
26 namespace MBSim {
27 
28  class DynamicSystem;
29  class Link;
30 
41  //class Object : public Element, public ObjectInterface {
42  class Object : public Element {
43  public:
47  Object(const std::string &name);
48 
52  virtual ~Object();
53 
54  /* INHERITED INTERFACE OF OBJECTINTERFACE */
55  virtual void updateT() { }
56  virtual void updateh(int j=0) { }
57  virtual void updateM() { }
58  virtual void updatedhdz();
59  virtual void updatedq();
60  virtual void updatedu();
61  virtual void updateud();
62  virtual void updateqd();
63  virtual void sethSize(int hSize_, int i=0);
64  virtual int gethSize(int i=0) const { return hSize[i]; }
65  virtual int getqSize() const { return qSize; }
66  virtual int getuSize(int i=0) const { return uSize[i]; }
67  virtual void calcqSize() {};
68  virtual void calcuSize(int j) {};
69  //virtual int getqInd(DynamicSystem* sys);
70  virtual int getuInd(int i=0) { return uInd[i]; }
71  //virtual int getuInd(DynamicSystem* sys, int i=0)
72  virtual void setqInd(int qInd_) { qInd = qInd_; }
73  virtual void setuInd(int uInd_, int i=0) { uInd[i] = uInd_; }
74  //virtual int gethInd(DynamicSystem* sys,int i=0);
75  virtual const fmatvec::Vec& getq() const { return q; }
76  virtual const fmatvec::Vec& getu() const { return u; }
77  virtual H5::GroupBase *getPlotGroup() { return plotGroup; }
78  virtual PlotFeatureStatus getPlotFeature(PlotFeature fp) { return Element::getPlotFeature(fp); }
79  virtual PlotFeatureStatus getPlotFeatureForChildren(PlotFeature fp) { return Element::getPlotFeatureForChildren(fp); }
80  /*******************************************************/
81 
82  /* INHERITED INTERFACE OF ELEMENT */
83  virtual void plot();
84  virtual void closePlot();
85  virtual std::string getType() const { return "Object"; }
86  //virtual void setDynamicSystemSolver(DynamicSystemSolver *sys);
87  /*******************************************************/
88 
93  virtual void updateqRef(const fmatvec::Vec& qRef);
94 
99  virtual void updateqdRef(const fmatvec::Vec& qdRef);
100 
105  virtual void updatedqRef(const fmatvec::Vec& dqRef);
106 
111  virtual void updateuRef(const fmatvec::Vec& uRef);
112 
117  virtual void updateuallRef(const fmatvec::Vec& uallRef);
118 
123  virtual void updateudRef(const fmatvec::Vec& udRef);
124 
129  virtual void updateduRef(const fmatvec::Vec& duRef);
130 
135  virtual void updateudallRef(const fmatvec::Vec& udallRef);
136 
142  virtual void updatehRef(const fmatvec::Vec& hRef, int i=0);
143 
149  virtual void updatedhdqRef(const fmatvec::Mat& dhdqRef, int i=0);
150 
156  virtual void updatedhduRef(const fmatvec::SqrMat& dhduRef, int i=0);
157 
163  virtual void updatedhdtRef(const fmatvec::Vec& dhdtRef, int i=0);
164 
169  virtual void updaterRef(const fmatvec::Vec& ref, int i=0);
170 
175  virtual void updaterdtRef(const fmatvec::Vec& ref);
176 
181  virtual void updateTRef(const fmatvec::Mat &ref);
182 
188  virtual void updateMRef(const fmatvec::SymMat &ref);
189 
195  virtual void updateLLMRef(const fmatvec::SymMat &ref);
196 
200  virtual void init(InitStage stage);
201 
205  virtual void initz();
206 
210  virtual void writez(H5::GroupBase *group);
211 
215  virtual void readz0(H5::GroupBase *group);
216 
220  virtual void updateLLM() { LLM = facLL(evalM()); }
221 
225  virtual double evalKineticEnergy() { return 0.5*u.T()*M*u; }
226 
230  virtual double evalPotentialEnergy() { return 0; }
231 
235  virtual void setUpInverseKinetics() {}
236  /*******************************************************/
237 
238  /* GETTER / SETTER */
239  void setqSize(int qSize_) { qSize = qSize_; }
240  void setuSize(int uSize_, int i=0) { uSize[i] = uSize_; }
241  int getzSize() const { return qSize + uSize[0]; }
242 
243  virtual void sethInd(int hInd_, int i=0);
244  int gethInd(int i=0) { return hInd[i]; }
245 
246  const fmatvec::Vec& geth(int i=0, bool check=true) const;
247  fmatvec::Vec& geth(int i=0, bool check=true);
248 
249  fmatvec::Vec& getq() { return q; };
250  fmatvec::Vec& getu() { return u; };
251 
252  const fmatvec::Vec& getq0() const { return q0; };
253  const fmatvec::Vec& getu0() const { return u0; };
254  fmatvec::Vec& getq0() { return q0; };
255  fmatvec::Vec& getu0() { return u0; };
256 
257  const fmatvec::Mat& evalT();
258  const fmatvec::Vec& evalh(int i=0);
259  const fmatvec::SymMat& evalM();
260  const fmatvec::SymMat& evalLLM();
261  const fmatvec::Vec& evalr(int i=0);
262  const fmatvec::Vec& evalrdt();
263  const fmatvec::Vec& evalqd();
264  const fmatvec::Vec& evalud();
265  const fmatvec::Vec& evaludall();
266 
267  void setq(const fmatvec::Vec &q_) { q = q_; }
268  void setu(const fmatvec::Vec &u_) { u = u_; }
269 
270  /*******************************************************/
271 
272  virtual void initializeUsingXML(xercesc::DOMElement *element);
273 
274  protected:
278  int qSize;
279 
283  int uSize[2];
284 
288  int hSize[2];
289 
293  int qInd, uInd[2], hInd[2];
294 
298  fmatvec::Vec q, u, uall;
299 
304 
308  fmatvec::Vec qd, ud, dq, du, udall;
309 
313  fmatvec::Vec h[2], r[2], rdt;
314 
315  fmatvec::Mat W[2], V[2];
316 
321  fmatvec::SqrMat dhdu;
322  fmatvec::Vec dhdt;
323 
328 
333 
338 
339  };
340 
341 }
342 
343 #endif /* _OBJECT_H_ */
int qInd
indices of positions, velocities, right hand side
Definition: object.h:293
Object(const std::string &name)
constructor
Definition: object.cc:34
virtual void updateudallRef(const fmatvec::Vec &udallRef)
references to differentiated velocities of dynamic system parent
Definition: object.cc:169
virtual void updatedqRef(const fmatvec::Vec &dqRef)
references to differentiated positions of dynamic system parent
Definition: object.cc:149
virtual void updateTRef(const fmatvec::Mat &ref)
references to linear transformation matrix between differentiated positions and velocities of dynamic...
Definition: object.cc:197
virtual void updateLLM()
perform Cholesky decomposition of mass martix
Definition: object.h:220
virtual void updatedhdqRef(const fmatvec::Mat &dhdqRef, int i=0)
references to object Jacobian for implicit integration of dynamic system parent regarding positions ...
Definition: object.cc:177
fmatvec::Mat T
linear relation matrix of differentiated position and velocity parameters
Definition: object.h:327
virtual void updateudRef(const fmatvec::Vec &udRef)
references to differentiated velocities of dynamic system parent
Definition: object.cc:161
int qSize
size of object positions
Definition: object.h:278
virtual void initz()
Definition: object.cc:247
fmatvec::Vec q
positions, velocities
Definition: object.h:298
basic class of MBSim mainly for plotting
Definition: element.h:58
virtual void writez(H5::GroupBase *group)
writes its z-Vector to a subgroup of the given group
Definition: object.cc:262
int hSize[2]
size of object h-vector (columns of J)
Definition: object.h:288
fmatvec::SymMat LLM
LU-decomposition of mass matrix.
Definition: object.h:337
virtual void plot()
plots time dependent data
Definition: object.cc:103
virtual void updatedhduRef(const fmatvec::SqrMat &dhduRef, int i=0)
references to object Jacobian for implicit integration of dynamic system parent regarding velocities ...
Definition: object.cc:181
InitStage
The stages of the initialization.
Definition: element.h:97
virtual void updatedhdtRef(const fmatvec::Vec &dhdtRef, int i=0)
references to object Jacobian for implicit integration of dynamic system parent regarding time ...
Definition: object.cc:185
PlotFeatureStatus getPlotFeature(PlotFeature pf)
Definition: element.h:214
std::string name
name of element
Definition: element.h:298
virtual void updateuRef(const fmatvec::Vec &uRef)
references to velocities of dynamic system parent
Definition: object.cc:153
fmatvec::Mat dhdq
Jacobians of h.
Definition: object.h:320
virtual double evalKineticEnergy()
Definition: object.h:225
virtual void init(InitStage stage)
initialize object at start of simulation with respect to contours and frames
Definition: object.cc:209
virtual void updateqRef(const fmatvec::Vec &qRef)
references to positions of dynamic system parent
Definition: object.cc:141
virtual void updateMRef(const fmatvec::SymMat &ref)
references to mass matrix of dynamic system parent
Definition: object.cc:201
virtual void closePlot()
closes plot file
Definition: object.cc:135
int uSize[2]
size of object velocities
Definition: object.h:283
virtual void updatehRef(const fmatvec::Vec &hRef, int i=0)
references to smooth force vector of dynamic system parent
Definition: object.cc:173
virtual void updateLLMRef(const fmatvec::SymMat &ref)
references to Cholesky decomposition of dynamic system parent
Definition: object.cc:205
virtual void readz0(H5::GroupBase *group)
reads the z-Vector of a subgroup of the given group
Definition: object.cc:268
fmatvec::Vec h[2]
complete and object smooth and nonsmooth right hand side
Definition: object.h:313
H5::GroupBase * plotGroup
associated plot group
Definition: element.h:332
virtual ~Object()
destructor
Definition: object.cc:47
virtual void updaterdtRef(const fmatvec::Vec &ref)
references to nonsmooth force vector of dynamic system parent
Definition: object.cc:193
virtual void updateduRef(const fmatvec::Vec &duRef)
references to differentiated velocities of dynamic system parent
Definition: object.cc:165
PlotFeatureStatus
Plot feature status.
Definition: element.h:61
virtual std::string getType() const
Definition: object.h:85
virtual void updateuallRef(const fmatvec::Vec &uallRef)
references to velocities of dynamic system parent
Definition: object.cc:157
PlotFeature
Plot Features.
Definition: element.h:74
virtual void updaterRef(const fmatvec::Vec &ref, int i=0)
references to nonsmooth force vector of dynamic system parent
Definition: object.cc:189
virtual void updateqdRef(const fmatvec::Vec &qdRef)
references to differentiated positions of dynamic system parent
Definition: object.cc:145
fmatvec::SymMat M
mass matrix
Definition: object.h:332
fmatvec::Vec qd
differentiated positions, velocities
Definition: object.h:308
PlotFeatureStatus getPlotFeatureForChildren(PlotFeature pf)
Definition: element.h:219
class for all objects having own dynamics and mass
Definition: object.h:42
fmatvec::Vec q0
initial position, velocity
Definition: object.h:303
virtual void setUpInverseKinetics()
TODO.
Definition: object.h:235
virtual double evalPotentialEnergy()
Definition: object.h:230

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML