COPASI API  4.16.103
CCrossSectionTask.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 /**
7  * CCrossSectionTask class.
8  *
9  * This class implements a trajectory task which is comprised of a
10  * of a problem and a method. Additionally calls to the reporting
11  * methods are done when initialized.
12  *
13  * Created for COPASI by Sven Sahle 2012
14  */
15 
16 #ifndef COPASI_CCrossSectionTask
17 #define COPASI_CCrossSectionTask
18 
19 //#include "crosssection/CCrosssectionMethod.h"
20 #include "copasi/model/CEvent.h"
25 
27 //class CCrossSectionMethod;
28 class CState;
29 class CEvent;
30 
32 {
33  //Attributes
34 public:
35  /**
36  * The methods which can be selected for performing this task.
37  */
38  static const unsigned int ValidMethods[];
39 
40 private:
41 
42  /**
43  * whether the time series should be stored in mTimeSeries
44  */
46 
47  /**
48  * the time series (if requested)
49  */
51 
52  /**
53  * A pointer to the trajectory Problem
54  */
56 
57  /**
58  * A pointer to the trajectory method
59  */
61 
62  /**
63  * Indicates whether we need to update moieties.
64  */
66 
67  /**
68  * A pointer to the current state of the integration.
69  */
71 
72  /**
73  * A pointer to the current time of the integration.
74  */
76 
77  /**
78  * time at which the output starts.
79  */
81 
82  /**
83  * time at which the simulation starts.
84  */
86 
87  size_t mNumCrossings;
88 
90 
92 
93  /**
94  * handle for progress reporting
95  */
96  size_t mhProgress;
97 
98  /**
99  * this holds the max value for the progress reporting
100  */
102 
103  /**
104  * this holds the current value for the progress reporting
105  */
107 
108  /**
109  * this holds the current value for the progress reporting
110  */
112 
113  /**
114  * temporary event
115  */
117 
118  /**
119  * describes the internal state of the calculation
120  */
121  enum STATE
122  {
123  TRANSIENT = 0, //before the condition for starting output is met
124  MAIN, //the main part of the run, while output is generated
125  FINISH //when the conditions for finishing are met
126  };
127 
129 
130  std::vector< CState > mStatesRing;
131  //std::vector<C_FLOAT64> mvTimesRing;
132 
133  //the number of states already pushed to the ring buffer
135 
144 
145 public:
146  /**
147  * Default constructor
148  * @param const CCopasiContainer * pParent (default: NULL)
149  */
150  CCrossSectionTask(const CCopasiContainer * pParent = NULL);
151 
152  /**
153  * Copy constructor
154  * @param const CCrossSectionTask & src
155  * @param const CCopasiContainer * pParent (default: NULL)
156  */
158  const CCopasiContainer * pParent = NULL);
159 
160  /**
161  * Destructor
162  */
164 
165  /**
166  * Initialize the task. If an ostream is given this ostream is used
167  * instead of the target specified in the report. This allows nested
168  * tasks to share the same output device.
169  * @param const OutputFlag & of
170  * @param COutputHandler * pOutputHandler
171  * @param std::ostream * pOstream (default: NULL)
172  * @return bool success
173  */
174  virtual bool initialize(const OutputFlag & of,
175  COutputHandler * pOutputHandler,
176  std::ostream * pOstream);
177 
178  /**
179  * Process the task with or without initializing to the initial state.
180  * @param const bool & useInitialValues
181  * @return bool success
182  */
183  virtual bool process(const bool & useInitialValues);
184 
185  void createEvent();
186  void removeEvent();
187 
188  /**
189  * Starts the process of integration by calling CTrajectoryMethod::start
190  * @param const bool & useInitialValues
191  */
192  void processStart(const bool & useInitialValues);
193 
194  /**
195  * Integrates one step
196  * @param const C_FLOAT64 & nextTime
197  * @return bool success;
198  */
199  bool processStep(const C_FLOAT64 & nextTime);
200 
201  /**
202  * Perform necessary cleanup procedures
203  */
204  virtual bool restore();
205 
206  /**
207  * Set the method type applied to solve the task
208  * @param const CCopasiMethod::SubType & type
209  * @return bool success
210  */
211  virtual bool setMethodType(const int & type);
212 
213  /**
214  * Create a method of the specified type to solve the task.
215  * It is the duty of the caller to release the CCopasiMethod.
216  * @param const CCopasiMethod::SubType & type
217  * @return CCopasiMethod *
218  */
219  virtual CCopasiMethod * createMethod(const int & type) const;
220 
221  /**
222  * Retrieves a pointer to current state of the integration.
223  * @return CState * pState
224  */
225  CState * getState();
226 
227  /**
228  * gets a reference to the time series
229  * @return time series
230  */
231  const CTimeSeries & getTimeSeries() const;
232 
233 private:
234  /**
235  * cleanup()
236  */
237  void cleanup();
238 
239  /**
240  * initialize the object references
241  */
242  void initObjects();
243 
244  /**
245  * this is the static call back function that is called by the
246  * process queue when an event is executed-
247  */
248  static void EventCallBack(void* pCSTask, CEvent::Type type);
249 
250  /**
251  * This is the member function that is called by the static call back function
252  * It checks if an event describes the cut plane and does all
253  * the necessary analysis and output in this case
254  */
255  void eventCallBack(CEvent::Type type);
256 
257  /**
258  * should be called by all code paths that finish the task.
259  * -finishes progress reporting
260  * -finishes output
261  * -resets call back function
262  */
263  void finish();
264 
266 };
267 #endif // COPASI_CCrossSectionTask
Definition: CEvent.h:152
#define C_INT
Definition: copasi.h:115
virtual bool restore()
C_FLOAT64 mPreviousCrossingTime
void processStart(const bool &useInitialValues)
virtual bool setMethodType(const int &type)
Definition: CState.h:305
Type
Definition: CEvent.h:155
virtual bool process(const bool &useInitialValues)
void eventCallBack(CEvent::Type type)
const C_FLOAT64 * mpCurrentTime
CCrossSectionTask(const CCopasiContainer *pParent=NULL)
std::vector< CState > mStatesRing
CTimeSeries mTimeSeries
virtual CCopasiMethod * createMethod(const int &type) const
CTrajectoryMethod * mpTrajectoryMethod
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 mOutputStartTime
static void EventCallBack(void *pCSTask, CEvent::Type type)
bool processStep(const C_FLOAT64 &nextTime)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
Header file of class CEvent.
const CTimeSeries & getTimeSeries() const
CCrossSectionProblem * mpCrossSectionProblem
static C_FLOAT64 relativeDifferenceOfStates(CState *s1, CState *s2)
static const unsigned int ValidMethods[]