MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
filedrv.cc
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/filedrv.cc,v 1.52 2017/01/12 14:46:09 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 /* file driver */
33 
34 #include "mbconfig.h" /* This goes first in every *.c,*.cc file */
35 
36 #include <fstream>
37 
38 #include "dataman.h"
39 #include "mbdyn.h"
40 #include "filedrv.h"
41 #include "fixedstep.h"
42 #include "varstep.h"
43 #include "sockdrv.h"
44 #include "streamdrive.h"
45 #ifdef USE_SOCKET
46 #include "socketstreamdrive.h"
47 #endif // USE_SOCKET
48 #include "rtai_in_drive.h"
49 
50 /* FileDrive - begin */
51 
52 FileDrive::FileDrive(unsigned int uL, const DriveHandler* pDH,
53  const std::string& s,
54  integer nd, const std::vector<doublereal>& v0)
55 : Drive(uL, pDH), sFileName(s), iNumDrives(nd), pdVal(0)
56 {
57  SAFENEWARR(pdVal, doublereal, nd + 1);
59  if (v0.empty()) {
60  for (int iCntm1 = 1; iCntm1 <= nd; iCntm1++) {
61  pdVal[iCntm1] = 0.;
62  }
63 
64  } else {
65  ASSERT(v0.size() == unsigned(nd));
66  for (int iCnt = 0; iCnt < nd; iCnt++) {
67  pdVal[iCnt + 1] = v0[iCnt];
68  }
69  }
70 }
71 
72 
74 {
75  if (pdVal != NULL) {
77  }
78 }
79 
80 
83 {
84  return Drive::FILEDRIVE;
85 }
86 
88 FileDrive::dGet(const doublereal& /* t */ , int i) const
89 {
90  ASSERT(i > 0 && i <= iNumDrives);
91  return pdVal[i];
92 }
93 
94 /* FileDrive - end */
95 
96 
97 /* FileDriveCaller - begin */
98 
100  const FileDrive* p, integer i,
101  const doublereal& da)
102 : DriveCaller(pDH), pFileDrive(p), iNumDrive(i), dAmplitude(da)
103 {
104  ASSERT(pFileDrive != NULL);
105  ASSERT(iNumDrive > 0 && iNumDrive <= pFileDrive->iGetNumDrives());
106 }
107 
108 
110 {
111  NO_OP;
112 }
113 
114 /* Copia */
116 {
117  DriveCaller* pDC = NULL;
122 
123  return pDC;
124 }
125 
126 
127 /* Scrive il contributo del DriveCaller al file di restart */
128 std::ostream&
129 FileDriveCaller::Restart(std::ostream& out) const
130 {
131  out << " file, " << pFileDrive->GetLabel()
132  << ", " << iNumDrive;
133  if (dAmplitude != 1.) {
134  out << ", amplitude, " << dAmplitude;
135  }
136  return out;
137 }
138 
139 /* FileDriveCaller - end */
140 
virtual Drive::Type GetDriveType(void) const
Definition: filedrv.cc:82
Definition: drive.h:89
#define SAFEDELETEARR(pnt)
Definition: mynewmem.h:713
Type
Definition: drive.h:92
virtual std::ostream & Restart(std::ostream &out) const
Definition: filedrv.cc:129
#define MBDYN_FILE_DRIVE_CHECK
Definition: filedrv.h:40
#define NO_OP
Definition: myassert.h:74
FileDrive(unsigned int uL, const DriveHandler *pDH, const std::string &s, integer nd, const std::vector< doublereal > &v0)
Definition: filedrv.cc:52
integer iNumDrives
Definition: filedrv.h:47
doublereal * pdVal
Definition: filedrv.h:48
doublereal dAmplitude
Definition: filedrv.h:86
virtual DriveCaller * pCopy(void) const
Definition: filedrv.cc:115
virtual doublereal dGet(const doublereal &t, int i=1) const
Definition: filedrv.cc:88
virtual ~FileDriveCaller(void)
Definition: filedrv.cc:109
FileDriveCaller(const DriveHandler *pDH, const FileDrive *p, integer i, const doublereal &da)
Definition: filedrv.cc:99
DriveHandler * pDrvHdl
Definition: drive.h:444
#define ASSERT(expression)
Definition: colamd.c:977
#define SAFENEWWITHCONSTRUCTOR(pnt, item, constructor)
Definition: mynewmem.h:698
const FileDrive * pFileDrive
Definition: filedrv.h:84
integer iNumDrive
Definition: filedrv.h:85
#define SAFENEWARR(pnt, item, sz)
Definition: mynewmem.h:701
virtual ~FileDrive(void)
Definition: filedrv.cc:73
static const std::vector< doublereal > v0
Definition: fixedstep.cc:45
double doublereal
Definition: colamd.c:52
long int integer
Definition: colamd.c:51
unsigned int GetLabel(void) const
Definition: withlab.cc:62