MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
module-eu2phi.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/modules/module-eu2phi/module-eu2phi.cc,v 1.6 2017/01/12 14:51:03 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 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
33 
34 #include <cmath>
35 #include <cfloat>
36 
37 #include "dataman.h"
38 #include "tpldrive.h"
39 #include "Rot.hh"
40 
41 class Eu2PhiWrap : public TplDriveCaller<Vec3> {
42 private:
45 
46 public:
48  NO_OP;
49  };
50 
51  virtual ~Eu2PhiWrap(void) {
52  delete m_pDC;
53  };
54 
55  /* copia */
56  virtual TplDriveCaller<Vec3>* pCopy(void) const {
57  return new Eu2PhiWrap(m_pDC->pCopy(), m_od);
58  };
59 
60  /* Scrive il contributo del DriveCaller al file di restart */
61  virtual std::ostream& Restart(std::ostream& out) const {
62  return out;
63  };
64 
65  virtual std::ostream& Restart_int(std::ostream& out) const {
66  return out;
67  };
68 
69  /* Restituisce il valore del driver */
70  virtual Vec3 Get(const doublereal& dVar) const {
71  Vec3 E(m_pDC->Get(dVar));
72 
73  Mat3x3 R;
74  switch (m_od) {
75  case EULER_123:
76  R = EulerAngles123_2MatR(E);
77  break;
78 
79  case EULER_313:
80  R = EulerAngles313_2MatR(E);
81  break;
82 
83  case EULER_321:
84  R = EulerAngles321_2MatR(E);
85  break;
86 
87  default:
88  ASSERT(0);
89  }
90 
91  return RotManip::VecRot(R);
92  };
93 
94  virtual Vec3 Get(void) const {
95  return Get(0.);
96  };
97 
98  /* this is about drives that are differentiable */
99  virtual bool bIsDifferentiable(void) const {
100  return false;
101  };
102  virtual Vec3 GetP(void) const {
104  };
105 
106  virtual int getNDrives(void) const {
107  return 1;
108  };
109 };
110 
111 /* prototype of the functional object: reads a drive caller */
112 struct Eu2PhiDCR : public TplDriveCallerRead<Vec3> {
113  virtual TplDriveCaller<Vec3> *
114  Read(const DataManager* pDM, MBDynParser& HP) {
115  if (HP.IsKeyWord("help")) {
116  silent_cout(
117 "Eu2PhiWrap: converts a TplDriveCaller<Vec3> containing three Euler angles\n"
118 "into the corresponding Euler vector\n"
119 "\n"
120 "Syntax:\n"
121 " eu2phi ,\n"
122 " [ help , ]\n"
123 " [ format , { euler123 | euler313 | euler321 } , ]\n"
124 " (TplDriveCaller<Vec3>) <drive>\n");
125  }
126 
128 
129  if (HP.IsKeyWord("format")) {
131  switch (od) {
132  case EULER_123:
133  case EULER_313:
134  case EULER_321:
135  break;
136 
137  default:
138  silent_cerr("Eu2PhiWrap: unhandled format at line " << HP.GetLineData() << std::endl);
140  }
141  }
142 
143  return new Eu2PhiWrap(HP.GetTplDriveCaller<Vec3>(), od);
144  };
145 };
146 
147 extern "C" int
148 module_init(const char *module_name, void *pdm, void *php)
149 {
150 #if 0
151  DataManager *pDM = (DataManager *)pdm;
152  MBDynParser *pHP = (MBDynParser *)php;
153 #endif
154 
156 
157  if (!SetDC3D("eu2phi", rf)) {
158  delete rf;
159 
160  silent_cerr("Eu2PhiDCR: "
161  "module_init(" << module_name << ") "
162  "failed" << std::endl);
163 
164  return -1;
165  }
166 
167  return 0;
168 }
169 
TplDriveCaller< T > * GetTplDriveCaller(void)
Definition: mbpar.cc:2112
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
Definition: matvec3.h:98
TplDriveCaller< Vec3 > * m_pDC
virtual T Get(const doublereal &dVar) const =0
OrientationDescription m_od
virtual ~Eu2PhiWrap(void)
virtual Vec3 Get(void) const
OrientationDescription
Definition: matvec3.h:1597
virtual Vec3 GetP(void) const
#define NO_OP
Definition: myassert.h:74
Mat3x3 EulerAngles313_2MatR(const Vec3 &v)
Definition: matvec3.cc:1039
virtual bool bIsDifferentiable(void) const
OrientationDescription ReadOrientationDescription(MBDynParser &HP)
Definition: dataman3.cc:2502
Vec3 VecRot(const Mat3x3 &Phi)
Definition: Rot.cc:136
int module_init(const char *module_name, void *pdm, void *php)
This function registers our user defined element for the math parser.
Mat3x3 EulerAngles123_2MatR(const Vec3 &v)
Definition: matvec3.cc:1014
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
bool SetDC3D(const char *name, TplDriveCallerRead< Vec3 > *rf)
virtual TplDriveCaller< Vec3 > * pCopy(void) const
virtual TplDriveCaller< Vec3 > * Read(const DataManager *pDM, MBDynParser &HP)
virtual TplDriveCaller< T > * pCopy(void) const =0
virtual std::ostream & Restart(std::ostream &out) const
#define ASSERT(expression)
Definition: colamd.c:977
Mat3x3 EulerAngles321_2MatR(const Vec3 &v)
Definition: matvec3.cc:1064
virtual std::ostream & Restart_int(std::ostream &out) const
virtual Vec3 Get(const doublereal &dVar) const
Eu2PhiWrap(TplDriveCaller< Vec3 > *pDC, OrientationDescription od)
double doublereal
Definition: colamd.c:52
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697
static std::stack< const HighParser * > pHP
Definition: parser.cc:598
virtual int getNDrives(void) const
Mat3x3 R