MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
extedge.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/extedge.h,v 1.20 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) 2007-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 /* Forza */
33 
34 #ifndef EXTEDGE_H
35 #define EXTEDGE_H
36 
37 #include "extforce.h"
38 
39 /* ExtFileHandlerEDGE - begin */
40 
42 protected:
43  std::string fflagname, fdataname;
45 
46  std::ifstream infile;
47  std::ofstream outfile;
48 
49  enum EDGEcmd {
50  // ?
52 
53  // EDGE is initializing; MBDyn waits
55 
56  // EDGE is busy; MBDyn waits
57  EDGE_BUSY = 1,
58 
59  // EDGE waits (is ready to read kinematics); MBDyn iterates
61 
62  // EDGE is computing; MBDyn waits before reading forces
64 
65  // EDGE converged; MBDyn advances one step
67 
68  // EDGE wants to end simulation
69  EDGE_QUIT = 5,
70 
71  // must be the last one
73  };
74 
75  const char *EDGEcmd2str(int cmd) const;
76 
77  EDGEcmd CheckFlag(int& cnt);
78  void SendFlag(EDGEcmd cmd);
79 
80 public:
81  ExtFileHandlerEDGE(std::string& fflagname, std::string& fdataname,
82  mbsleep_t SleepTime, std::streamsize Precision);
83  ~ExtFileHandlerEDGE(void);
84 
85  virtual bool Prepare_pre(void);
86  virtual void Prepare_post(bool ok);
87 
88  virtual void AfterPredict(void);
89 
90  virtual bool Send_pre(SendWhen when);
91  virtual void Send_post(SendWhen when);
92 
93  virtual bool Recv_pre(void);
94  virtual bool Recv_post(void);
95 
96  virtual std::ostream *GetOutStream(void);
97  virtual std::istream *GetInStream(void);
98 };
99 
100 /* ExtFileHandlerEDGE - end */
101 
102 extern int
103 mbedge_goto_eol(std::istream& fin, char *buf, size_t bufsiz);
104 char *
105 mbedge_eat_sep(char *buf, size_t& buflen);
106 char *
107 mbedge_eat_field(char *buf, size_t& buflen, const char *val);
108 #if 0
109 char *
110 mbedge_eat_field(char *buf, size_t& buflen);
111 #endif
112 
113 
114 class DataManager;
115 class MBDynParser;
116 
117 extern ExtFileHandlerBase *
119  MBDynParser& HP,
120  unsigned int uLabel);
121 
122 #endif // EXTEDGE_H
123 
virtual bool Prepare_pre(void)
Definition: extedge.cc:562
const char * EDGEcmd2str(int cmd) const
Definition: extedge.cc:169
std::string fdataname
Definition: extedge.h:43
unsigned long mbsleep_t
Definition: mbsleep.h:51
virtual void AfterPredict(void)
Definition: extedge.cc:574
virtual std::ostream * GetOutStream(void)
Definition: extedge.cc:743
char * mbedge_eat_field(char *buf, size_t &buflen, const char *val)
Definition: extedge.cc:94
char * mbedge_eat_sep(char *buf, size_t &buflen)
Definition: extedge.cc:74
ExtFileHandlerEDGE(std::string &fflagname, std::string &fdataname, mbsleep_t SleepTime, std::streamsize Precision)
Definition: extedge.cc:135
DataManager * pDM
Definition: mbpar.h:252
virtual void Prepare_post(bool ok)
Definition: extedge.cc:568
std::string fflagname
Definition: extedge.h:43
virtual bool Recv_post(void)
Definition: extedge.cc:733
virtual void Send_post(SendWhen when)
Definition: extedge.cc:638
std::ifstream infile
Definition: extedge.h:46
int mbedge_goto_eol(std::istream &fin, char *buf, size_t bufsiz)
Definition: extedge.cc:49
std::streamsize Precision
Definition: extforce.h:75
virtual std::istream * GetInStream(void)
Definition: extedge.cc:749
virtual bool Send_pre(SendWhen when)
Definition: extedge.cc:580
ExtFileHandlerBase * ReadExtFileHandlerEDGE(DataManager *pDM, MBDynParser &HP, unsigned int uLabel)
Definition: extedge.cc:757
virtual bool Recv_pre(void)
Definition: extedge.cc:668
~ExtFileHandlerEDGE(void)
Definition: extedge.cc:144
void SendFlag(EDGEcmd cmd)
Definition: extedge.cc:509
std::ofstream outfile
Definition: extedge.h:47
EDGEcmd CheckFlag(int &cnt)
Definition: extedge.cc:179
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
mbsleep_t SleepTime
Definition: extforce.h:76