MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
tpldrive.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/tpldrive.h,v 1.38 2017/01/12 14:46:11 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 TPLDRIVE_H
33 #define TPLDRIVE_H
34 
35 #include "drive.h"
36 #include "matvec3.h"
37 #include "matvec6.h"
38 
39 // forward declaration, since "reffrm.h" needs "tpldrive.h"
40 class ReferenceFrame;
41 
42 /* TplDriveCaller - begin */
43 
44 template <class T>
46 public:
47  virtual ~TplDriveCaller(void) {
48  NO_OP;
49  };
50 
51  /* copia */
52  virtual TplDriveCaller<T>* pCopy(void) const = 0;
53 
54  /* Scrive il contributo del DriveCaller al file di restart */
55  virtual std::ostream& Restart(std::ostream& out) const = 0;
56  virtual std::ostream& Restart_int(std::ostream& out) const = 0;
57 
58  /* Restituisce il valore del driver */
59  virtual T Get(const doublereal& dVar) const = 0;
60  virtual T Get(void) const {
61  return Get(0.);
62  };
63 
64  /* this is about drives that are differentiable */
65  virtual bool bIsDifferentiable(void) const {
66  return false;
67  };
68  virtual T GetP(void) const {
70  };
71 
72  virtual int getNDrives(void) const = 0;
73 };
74 
75 /* TplDriveCaller - end */
76 
77 
78 /* TplDriveOwner - begin */
79 
80 template <class T>
82 protected:
84 
85 public:
87  : pTplDriveCaller(const_cast<TplDriveCaller<T> *>(pDC)) {
88  NO_OP;
89  };
90 
91  virtual ~TplDriveOwner(void) {
92  if (pTplDriveCaller != 0) {
94  }
95  };
96 
97  void Set(const TplDriveCaller<T>* pDC) {
98  ASSERT(pDC != 0);
99  if (pTplDriveCaller != 0) {
101  }
102  pTplDriveCaller = const_cast<TplDriveCaller<T>*>(pDC);
103  };
104 
106  return pTplDriveCaller;
107  };
108 
109  T Get(const doublereal& dVar) const {
110  return pTplDriveCaller->Get(dVar);
111  };
112 
113  T Get(void) const {
114  return pTplDriveCaller->Get();
115  };
116 
117  /* this is about drives that are differentiable */
118  virtual bool bIsDifferentiable(void) const {
119  return pTplDriveCaller->bIsDifferentiable();
120  };
121  virtual T GetP(void) const {
122  return pTplDriveCaller->GetP();
123  };
124 };
125 
126 /* TplDriveOwner - end */
127 
128 /* functions that read a template drive caller */
130 ReadDC1D(const DataManager* pDM, MBDynParser& HP);
131 extern TplDriveCaller<Vec3> *
132 ReadDC3D(const DataManager* pDM, MBDynParser& HP);
133 extern TplDriveCaller<Vec6> *
134 ReadDC6D(const DataManager* pDM, MBDynParser& HP);
135 extern TplDriveCaller<Mat3x3> *
136 ReadDC3x3D(const DataManager* pDM, MBDynParser& HP);
137 extern TplDriveCaller<Mat6x6> *
138 ReadDC6x6D(const DataManager* pDM, MBDynParser& HP);
139 
140 extern TplDriveCaller<Vec3> *
141 ReadDCVecRel(const DataManager* pDM, MBDynParser& HP, const ReferenceFrame& rf);
142 extern TplDriveCaller<Vec3> *
143 ReadDCVecAbs(const DataManager* pDM, MBDynParser& HP, const ReferenceFrame& rf);
144 
145 /* prototype of the template functional object: reads a template drive caller */
146 template <class T>
148  virtual ~TplDriveCallerRead<T>( void ) { NO_OP; };
149  virtual TplDriveCaller<T> *
150  Read(const DataManager* pDM, MBDynParser& HP) = 0;
151 };
152 
153 /* template drive caller registration functions: call to register one */
154 extern bool
155 SetDC1D(const char *name, TplDriveCallerRead<doublereal> *rf);
156 extern bool
157 SetDC3D(const char *name, TplDriveCallerRead<Vec3> *rf);
158 extern bool
159 SetDC6D(const char *name, TplDriveCallerRead<Vec6> *rf);
160 extern bool
161 SetDC3x3D(const char *name, TplDriveCallerRead<Mat3x3> *rf);
162 extern bool
163 SetDC6x6D(const char *name, TplDriveCallerRead<Mat6x6> *rf);
164 
165 /* create/destroy */
166 extern void InitTplDC(void);
167 extern void DestroyTplDC(void);
168 
169 #endif /* TPLDRIVE_H */
170 
TplDriveCaller< doublereal > * ReadDC1D(const DataManager *pDM, MBDynParser &HP)
virtual T Get(void) const
Definition: tpldrive.h:60
virtual ~TplDriveOwner(void)
Definition: tpldrive.h:91
virtual bool bIsDifferentiable(void) const
Definition: tpldrive.h:118
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
TplDriveCaller< T > * pTplDriveCaller
Definition: tpldrive.h:83
bool SetDC3x3D(const char *name, TplDriveCallerRead< Mat3x3 > *rf)
TplDriveOwner(const TplDriveCaller< T > *pDC=0)
Definition: tpldrive.h:86
bool SetDC6D(const char *name, TplDriveCallerRead< Vec6 > *rf)
virtual std::ostream & Restart_int(std::ostream &out) const =0
TplDriveCaller< Mat6x6 > * ReadDC6x6D(const DataManager *pDM, MBDynParser &HP)
#define NO_OP
Definition: myassert.h:74
void Set(const TplDriveCaller< T > *pDC)
Definition: tpldrive.h:97
virtual T GetP(void) const
Definition: tpldrive.h:121
TplDriveCaller< Vec3 > * ReadDCVecAbs(const DataManager *pDM, MBDynParser &HP, const ReferenceFrame &rf)
virtual ~TplDriveCaller(void)
Definition: tpldrive.h:47
virtual int getNDrives(void) const =0
TplDriveCaller< Vec3 > * ReadDC3D(const DataManager *pDM, MBDynParser &HP)
TplDriveCaller< T > * pGetDriveCaller(void) const
Definition: tpldrive.h:105
virtual bool bIsDifferentiable(void) const
Definition: tpldrive.h:65
bool SetDC3D(const char *name, TplDriveCallerRead< Vec3 > *rf)
void InitTplDC(void)
T Get(const doublereal &dVar) const
Definition: tpldrive.h:109
bool SetDC1D(const char *name, TplDriveCallerRead< doublereal > *rf)
TplDriveCaller< Vec6 > * ReadDC6D(const DataManager *pDM, MBDynParser &HP)
void DestroyTplDC(void)
virtual TplDriveCaller< T > * pCopy(void) const =0
virtual std::ostream & Restart(std::ostream &out) const =0
#define ASSERT(expression)
Definition: colamd.c:977
virtual T GetP(void) const
Definition: tpldrive.h:68
TplDriveCaller< Mat3x3 > * ReadDC3x3D(const DataManager *pDM, MBDynParser &HP)
virtual TplDriveCaller< T > * Read(const DataManager *pDM, MBDynParser &HP)=0
bool SetDC6x6D(const char *name, TplDriveCallerRead< Mat6x6 > *rf)
double doublereal
Definition: colamd.c:52
T Get(void) const
Definition: tpldrive.h:113
TplDriveCaller< Vec3 > * ReadDCVecRel(const DataManager *pDM, MBDynParser &HP, const ReferenceFrame &rf)
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710