MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
mbcxx.h
Go to the documentation of this file.
1 /*
2  * MBDyn (C) is a multibody analysis code.
3  * http://www.mbdyn.org
4  *
5  * Copyright (C) 1996-2017
6  *
7  * Pierangelo Masarati <masarati@aero.polimi.it>
8  * Paolo Mantegazza <mantegazza@aero.polimi.it>
9  *
10  * Dipartimento di Ingegneria Aerospaziale - Politecnico di Milano
11  * via La Masa, 34 - 20156 Milano, Italy
12  * http://www.aero.polimi.it
13  *
14  * Changing this copyright notice is forbidden.
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation (version 2 of the License).
19  *
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29  */
30 
31 #ifndef MBCXX_H
32 #define MBCXX_H
33 
34 #include <mbc.h>
35 
36 // hack...
37 extern "C" {
41 };
42 }
43 
44 class MBCBase {
45 protected:
46  virtual mbc_t *GetBasePtr(void) const = 0;
47  virtual mbc_refnode_stub_t *GetRefNodePtr(void) const = 0;
48 
49 public:
50  enum Type {
53  };
54 
55  enum Rot {
60  };
61 
62  virtual MBCBase::Type GetType(void) const = 0;
63 
64  MBCBase::Rot GetRot(void) const;
65  bool bRefNode(void) const;
66  MBCBase::Rot GetRefNodeRot(void) const;
67  bool bAccelerations(void) const;
68  bool bLabels(void) const;
69 
70  void SetTimeout(int t);
71  void SetVerbose(bool bv);
72  void SetDataAndNext(bool bd);
73 
74  bool bVerbose(void) const;
75  bool bDataAndNext(void) const;
76 
77 protected:
78  enum Status {
84  } m_status;
85 
86  Status GetStatus(void) const;
87  void SetStatus(Status s);
88 
89 public:
90  MBCBase(void);
91  virtual ~MBCBase(void);
92 
93  int Init(const char *const path);
94  int Init(const char *const host, short unsigned port);
95 
96  virtual int Negotiate(void) const = 0;
97  virtual int PutForces(bool bConverged) const = 0;
98  virtual int GetMotion(void) const = 0;
99  virtual int Close(void) const = 0;
100 
101  int GetCmd(void) const;
102 
103  uint32_t GetRefNodeKinematicsLabel(void) const;
104 
105  uint32_t KinematicsLabel(void) const;
106 
107  const double *const GetRefNodeX(void) const;
108  const double *const GetRefNodeR(void) const;
109  const double *const GetRefNodeTheta(void) const;
110  const double *const GetRefNodeEuler123(void) const;
111  const double *const GetRefNodeXP(void) const;
112  const double *const GetRefNodeOmega(void) const;
113  const double *const GetRefNodeXPP(void) const;
114  const double *const GetRefNodeOmegaP(void) const;
115 
116  const double& X(uint8_t idx) const;
117  const double& R(uint8_t ir, uint8_t ic) const;
118  const double& Theta(uint8_t idx) const;
119  const double& Euler123(uint8_t idx) const;
120  const double& XP(uint8_t idx) const;
121  const double& Omega(uint8_t idx) const;
122  const double& XPP(uint8_t idx) const;
123  const double& OmegaP(uint8_t idx) const;
124 
125  uint32_t GetRefNodeDynamicsLabel(void) const;
126  const uint32_t& DynamicsLabel(void) const;
127  uint32_t& DynamicsLabel(void);
128 
129  const double *GetRefNodeF(void) const;
130  const double *GetRefNodeM(void) const;
131 
132  const double& F(uint8_t idx) const;
133  double& F(uint8_t idx);
134  const double& M(uint8_t idx) const;
135  double& M(uint8_t idx);
136 };
137 
138 class MBCNodal : public MBCBase {
139 private:
140  mutable mbc_nodal_t mbc;
141 
142  virtual mbc_t *GetBasePtr(void) const;
143  virtual mbc_refnode_stub_t *GetRefNodePtr(void) const;
144 
145 public:
146  MBCNodal(void);
147  MBCNodal(MBCBase::Rot refnode_rot, unsigned nodes,
148  bool labels, MBCBase::Rot rot, bool accels);
149  virtual ~MBCNodal(void);
150 
151  MBCBase::Type GetType(void) const;
152 
153  int Initialize(MBCBase::Rot refnode_rot, unsigned nodes,
154  bool labels, MBCBase::Rot rot, bool accels);
155 
156  virtual int Negotiate(void) const;
157  virtual int PutForces(bool bConverged) const;
158  virtual int GetMotion(void) const;
159  int Close(void) const;
160 
161  uint32_t KinematicsLabel(void) const;
162  const double& X(uint8_t idx) const;
163  const double& R(uint8_t ir, uint8_t ic) const;
164  const double& Theta(uint8_t idx) const;
165  const double& Euler123(uint8_t idx) const;
166  const double& XP(uint8_t idx) const;
167  const double& Omega(uint8_t idx) const;
168  const double& XPP(uint8_t idx) const;
169  const double& OmegaP(uint8_t idx) const;
170  const uint32_t& DynamicsLabel(void) const;
171  uint32_t& DynamicsLabel(void);
172  const double& F(uint8_t idx) const;
173  double& F(uint8_t idx);
174  const double& M(uint8_t idx) const;
175  double& M(uint8_t idx);
176 
177  uint32_t GetNodes(void) const;
178 
179  uint32_t *GetKinematicsLabel(void) const;
180 
181  const double *const GetX(void) const;
182  const double *const GetR(void) const;
183  const double *const GetTheta(void) const;
184  const double *const GetEuler123(void) const;
185  const double *const GetXP(void) const;
186  const double *const GetOmega(void) const;
187  const double *const GetXPP(void) const;
188  const double *const GetOmegaP(void) const;
189 
190  const double& X(uint32_t n, uint8_t idx) const;
191  const double& R(uint32_t n, uint8_t ir, uint8_t ic) const;
192  const double& Theta(uint32_t n, uint8_t idx) const;
193  const double& Euler123(uint32_t n, uint8_t idx) const;
194  const double& XP(uint32_t n, uint8_t idx) const;
195  const double& Omega(uint32_t n, uint8_t idx) const;
196  const double& XPP(uint32_t n, uint8_t idx) const;
197  const double& OmegaP(uint32_t n, uint8_t idx) const;
198 
199  uint32_t GetKinematicsLabel(uint32_t n) const;
200  uint32_t KinematicsLabel(uint32_t n) const;
201 
202  const double *const GetX(uint32_t n) const;
203  const double *const GetR(uint32_t n) const;
204  const double *const GetTheta(uint32_t n) const;
205  const double *const GetEuler123(uint32_t n) const;
206  const double *const GetXP(uint32_t n) const;
207  const double *const GetOmega(uint32_t n) const;
208  const double *const GetXPP(uint32_t n) const;
209  const double *const GetOmegaP(uint32_t n) const;
210 
211  uint32_t *GetDynamicsLabel(void) const;
212 
213  const double *GetF(void) const;
214  const double *GetM(void) const;
215 
216  const uint32_t& DynamicsLabel(uint32_t n) const;
217  uint32_t& DynamicsLabel(uint32_t n);
218 
219  const double *GetF(uint32_t n) const;
220  const double *GetM(uint32_t n) const;
221 
222  const double& F(uint32_t n, uint8_t idx) const;
223  double& F(uint32_t n, uint8_t idx);
224  const double& M(uint32_t n, uint8_t idx) const;
225  double& M(uint32_t n, uint8_t idx);
226 };
227 
228 class MBCModal : public MBCBase {
229 private:
230  mutable mbc_modal_t mbc;
231 
232  virtual mbc_t *GetBasePtr(void) const;
233  virtual mbc_refnode_stub_t *GetRefNodePtr(void) const;
234 
235 public:
236  MBCModal(void);
237  MBCModal(MBCBase::Rot refnode_rot, unsigned modes);
238  virtual ~MBCModal(void);
239 
240  MBCBase::Type GetType(void) const;
241 
242  int Initialize(MBCBase::Rot refnode_rot, unsigned modes);
243 
244  virtual int Negotiate(void) const;
245  virtual int PutForces(bool bConverged) const;
246  virtual int GetMotion(void) const;
247  int Close(void) const;
248 
249  uint32_t KinematicsLabel(void) const;
250  const double& X(uint8_t idx) const;
251  const double& R(uint8_t ir, uint8_t ic) const;
252  const double& Theta(uint8_t idx) const;
253  const double& Euler123(uint8_t idx) const;
254  const double& XP(uint8_t idx) const;
255  const double& Omega(uint8_t idx) const;
256  const double& XPP(uint8_t idx) const;
257  const double& OmegaP(uint8_t idx) const;
258  const uint32_t& DynamicsLabel(void) const;
259  uint32_t& DynamicsLabel(void);
260  const double& F(uint8_t idx) const;
261  double& F(uint8_t idx);
262  const double& M(uint8_t idx) const;
263  double& M(uint8_t idx);
264 
265  uint32_t GetModes(void) const;
266 
267  const double *const GetQ(void) const;
268  const double *const GetQP(void) const;
269 
270  const double& Q(uint32_t m) const;
271  const double& QP(uint32_t m) const;
272 
273  const double *GetP(void) const;
274 
275  const double& P(uint32_t m) const;
276  double& P(uint32_t m);
277 };
278 
279 #endif // MBCXX_H
280 
const double *const GetRefNodeOmegaP(void) const
virtual int PutForces(bool bConverged) const =0
virtual int GetMotion(void) const
virtual int Close(void) const =0
void SetDataAndNext(bool bd)
Status
Definition: mbcxx.h:78
virtual int PutForces(bool bConverged) const
const double & Theta(uint8_t idx) const
bool bAccelerations(void) const
const double & R(uint8_t ir, uint8_t ic) const
nodal stuff (partially opaque).
Definition: mbc.h:509
virtual mbc_refnode_stub_t * GetRefNodePtr(void) const =0
const double & XPP(uint8_t idx) const
const double *const GetRefNodeXP(void) const
const double *const GetOmegaP(void) const
uint32_t KinematicsLabel(void) const
const double *const GetRefNodeEuler123(void) const
Status GetStatus(void) const
virtual MBCBase::Type GetType(void) const =0
virtual ~MBCBase(void)
mbc_modal_t mbc
Definition: mbcxx.h:230
const double & M(uint8_t idx) const
const double & OmegaP(uint8_t idx) const
const double & X(uint8_t idx) const
int Close(void) const
bool bVerbose(void) const
Definition: mbc.h:65
uint32_t KinematicsLabel(void) const
const double *const GetRefNodeOmega(void) const
int Close(void) const
virtual mbc_refnode_stub_t * GetRefNodePtr(void) const
virtual ~MBCNodal(void)
const double & Theta(uint8_t idx) const
const double & Omega(uint8_t idx) const
const uint32_t & DynamicsLabel(void) const
const double *const GetX(void) const
virtual int GetMotion(void) const =0
MBCBase::Type GetType(void) const
static unsigned rot
void SetStatus(Status s)
const double & X(uint8_t idx) const
const double *const GetXPP(void) const
mbc_nodal_t mbc
Definition: mbcxx.h:140
uint32_t GetRefNodeKinematicsLabel(void) const
const double & R(uint8_t ir, uint8_t ic) const
const double & QP(uint32_t m) const
void SetVerbose(bool bv)
MBCNodal(void)
const double & R(uint8_t ir, uint8_t ic) const
const double & Euler123(uint8_t idx) const
const double & XPP(uint8_t idx) const
const double *const GetEuler123(void) const
const double & XP(uint8_t idx) const
int Initialize(MBCBase::Rot refnode_rot, unsigned nodes, bool labels, MBCBase::Rot rot, bool accels)
const double * GetP(void) const
const double & OmegaP(uint8_t idx) const
virtual mbc_t * GetBasePtr(void) const
uint32_t * GetDynamicsLabel(void) const
const double & Q(uint32_t m) const
const double *const GetQP(void) const
MBCBase(void)
uint32_t GetModes(void) const
static int labels
const double *const GetRefNodeR(void) const
virtual mbc_t * GetBasePtr(void) const
virtual mbc_refnode_stub_t * GetRefNodePtr(void) const
Definition: mbc.h:66
Type
Definition: mbcxx.h:50
bool bRefNode(void) const
const double *const GetR(void) const
bool bLabels(void) const
uint32_t GetNodes(void) const
const double & F(uint8_t idx) const
const double *const GetTheta(void) const
MBCBase::Rot GetRot(void) const
const uint32_t & DynamicsLabel(void) const
const double & F(uint8_t idx) const
const char * host
Definition: autopilot.c:142
virtual int Negotiate(void) const =0
MBCModal(void)
const double & M(uint8_t idx) const
Rot
Definition: mbcxx.h:55
const double & XPP(uint8_t idx) const
const double & X(uint8_t idx) const
MBCBase::Rot GetRefNodeRot(void) const
virtual mbc_t * GetBasePtr(void) const =0
uint32_t * GetKinematicsLabel(void) const
mbc_rigid_t mbcr
Definition: mbcxx.h:40
Connection data structure (partially opaque)
Definition: mbc.h:103
int Init(const char *const path)
const double *const GetOmega(void) const
const double & Omega(uint8_t idx) const
const double * GetF(void) const
const double *const GetQ(void) const
const double & Omega(uint8_t idx) const
virtual int Negotiate(void) const
enum MBCBase::Status m_status
bool bDataAndNext(void) const
const double *const GetRefNodeX(void) const
static int nodes
const double *const GetRefNodeTheta(void) const
virtual int Negotiate(void) const
const double *const GetXP(void) const
MBCBase::Type GetType(void) const
uint32_t GetRefNodeDynamicsLabel(void) const
const double * GetM(void) const
const uint32_t & DynamicsLabel(void) const
const double * GetRefNodeF(void) const
const double & Euler123(uint8_t idx) const
const double & M(uint8_t idx) const
Nodal stuff (partially opaque).
Definition: mbc.h:334
const double & OmegaP(uint8_t idx) const
const double & P(uint32_t m) const
Definition: mbcxx.h:44
const double & F(uint8_t idx) const
const double * GetRefNodeM(void) const
Reference node (AKA "rigid") stuff (partially opaque).
Definition: mbc.h:233
const double *const GetRefNodeXPP(void) const
virtual int GetMotion(void) const
unsigned short int port
Definition: autopilot.c:143
virtual ~MBCModal(void)
virtual int PutForces(bool bConverged) const
const double & XP(uint8_t idx) const
uint32_t KinematicsLabel(void) const
void SetTimeout(int t)
const double & Theta(uint8_t idx) const
const double & Euler123(uint8_t idx) const
int Initialize(MBCBase::Rot refnode_rot, unsigned modes)
int GetCmd(void) const
const char * path
Definition: autopilot.c:141
const double & XP(uint8_t idx) const