MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
rtsolver.h
Go to the documentation of this file.
1 /* $Header: /var/cvs/mbdyn/mbdyn/mbdyn-1.0/mbdyn/base/rtsolver.h,v 1.13 2017/01/12 14:46:10 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 RTSOLVER_H
33 #define RTSOLVER_H
34 
35 /* RTSolverBase - begin */
36 
37 class Solver;
38 
39 class RTSolverBase {
40 public:
41  enum RTMode {
43 
47 
49  };
50 
51 protected:
53 
55 
56  /* if eRTMode == MBRT_WAITPERIOD */
57  unsigned long lRTPeriod;
58 
59  unsigned long RTStackSize;
61  int RTCpuMap;
62 
63  bool bNoOutput;
64 
65  bool RTWaitPeriod(void) const {
66  return (eRTMode == MBRT_WAITPERIOD);
67  };
68 
69  bool RTSemWait(void) const {
70  return (eRTMode == MBRT_SEMAPHORE);
71  };
72 
73  bool RTBlockingIO(void) const {
74  return (eRTMode == MBRT_IO);
75  };
76 
77  volatile int RTSteps;
78 
79 public:
82  unsigned long lRTPeriod,
83  unsigned long RTStackSize,
84  bool bRTAllowNonRoot,
85  int RTCpuMap,
86  bool bNoOutput = true);
87  virtual ~RTSolverBase(void);
88 
89  // write contribution to restart file
90  virtual std::ostream& Restart(std::ostream& out) const = 0;
91  // very first setup, to be always performed
92  virtual void Setup(void) = 0;
93  // initialization to be performed only if real-time is requested
94  virtual void Init(void);
95  // check whether stop is commanded by real-time
96  virtual bool IsStopCommanded(void);
97  // to be performed when stop is commanded by someone else
98  virtual void StopCommanded(void) = 0;
99  // write real-time related message when stop commanded by someone else
100  virtual void Log(void) = 0;
101  // wait for period to expire
102  virtual void Wait(void) = 0;
103 };
104 
105 /* RTSolverBase - end */
106 
107 extern void
109  RTSolverBase::RTMode& eRTMode,
110  unsigned long& lRTPeriod,
111  unsigned long& RTStackSize,
112  bool& bRTAllowNonRoot,
113  int& RTCpuMap);
114 
115 extern RTSolverBase *
117 
118 #endif // RTSOLVER_H
119 
virtual void Init(void)
Definition: rtsolver.cc:69
unsigned long RTStackSize
Definition: rtsolver.h:59
virtual void Wait(void)=0
unsigned long lRTPeriod
Definition: rtsolver.h:57
bool bNoOutput
Definition: rtsolver.h:63
virtual void StopCommanded(void)=0
RTSolverBase * ReadRTSolver(Solver *pS, MBDynParser &HP)
Definition: rtsolver.cc:206
void ReadRTParams(Solver *pS, MBDynParser &HP, RTSolverBase::RTMode &eRTMode, unsigned long &lRTPeriod, unsigned long &RTStackSize, bool &bRTAllowNonRoot, int &RTCpuMap)
Definition: rtsolver.cc:89
virtual ~RTSolverBase(void)
Definition: rtsolver.cc:63
volatile int RTSteps
Definition: rtsolver.h:75
bool RTSemWait(void) const
Definition: rtsolver.h:69
bool RTWaitPeriod(void) const
Definition: rtsolver.h:65
virtual bool IsStopCommanded(void)
Definition: rtsolver.cc:81
virtual void Log(void)=0
RTMode eRTMode
Definition: rtsolver.h:54
Definition: solver.h:78
RTSolverBase(Solver *pS, RTMode eRTMode, unsigned long lRTPeriod, unsigned long RTStackSize, bool bRTAllowNonRoot, int RTCpuMap, bool bNoOutput=true)
Definition: rtsolver.cc:44
virtual std::ostream & Restart(std::ostream &out) const =0
bool RTBlockingIO(void) const
Definition: rtsolver.h:73
int RTCpuMap
Definition: rtsolver.h:61
Solver * pS
Definition: rtsolver.h:52
virtual void Setup(void)=0
bool bRTAllowNonRoot
Definition: rtsolver.h:60