File: CheckPointController.h

package info (click to toggle)
esys-particle 2.3.4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,036 kB
  • ctags: 10,805
  • sloc: cpp: 80,009; python: 5,872; makefile: 1,243; sh: 313; perl: 225
file content (220 lines) | stat: -rw-r--r-- 4,884 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.apache.org/licenses/LICENSE-2.0          //
//                                                         //
/////////////////////////////////////////////////////////////


#ifndef CHECKPOINTCONTROLLER_H
#define CHECKPOINTCONTROLLER_H

// --- MPI includes ---
#include <mpi.h>

// --- Project includes ---
#include "Geometry/GeometryInfo.h"
#include "Foundation/StringUtil.h"
#include "Foundation/BoundingBox.h"

// --- STL includes ---
#include <string>

/**
 * Controls the issue of check-pointing commands to slave processes.
 */
class CheckPointController
{
public:
  /**
   * Default constructor.
   *
   * Default parameters cause isCheckPoint to return false.
   */
  CheckPointController();

  /**
   * Instantiates and sets the parameters which determine when
   * a check-point should occur.
   *
   * @see setCheckpointParams
   */
  CheckPointController(
    const std::string &fileNamePrefix,
    int beginTime,
    int endTime,
    int timeInterval,
    bool writeThroughMaster
  );

  /**
   *
   */
  virtual ~CheckPointController();

  /**
   * Determines whether specified argument is a check-point
   * time (see isCheckPoint). If currentTime is a check-point,
   * issues commands to slave processes to perform check-point.
   *
   * @param currentTime Parameter used to determine whether
   *                    a check point should occur.
   */
  virtual void performCheckPoint(int currentTime);
  virtual void performSnapShot(int currentTime);

  /**
   * Issues the check-point command to slave processes.
   *
   * @param currentTime The check-point time.
   */
  virtual void issueCheckPointCmd(int currentTime);
  virtual void issueCheckPointCmdWTM(int currentTime);
  virtual void issueSnapShotCmd(int currentTime);
  virtual void issueCheckPointLoadingCmd(const std::string&);

  /**
   * Returns whether specified time is a check-point time.
   *
   * @param time This value is checked against the checkpoint
   *             parameters.
   */
  bool isCheckPoint(int time);

  /**
   * Sets the parameters which determine when a check-point should occur.
   */
  void setCheckPointParams(
    const std::string &fileNamePrefix,
    int beginTime,
    int endTime,
    int timeInterval,
    bool writeThroughMaster,
    int precision=12
  );

  std::string getLatticeDataFileName(const std::string &fileNamePrefix, int timeStep, int rank, bool bin=false);

  esys::lsm::StringVector getLatticeDataFiles(int timeStep, int size);

  esys::lsm::StringVector getLatticeDataFiles(int timeStep);

  /**
   * Set 2-D information to true if the particle data are two-dimensional; 
   * otherwise set to false.
   */
  void set_is2d(bool do2d);

  /**
   * Set the LSMGeometry version for use in geometry files. 
   */
  void setLsmGeoVersion(float version);

  /**
   * Set the periodicity of the x, y and z dimensions. 
   */
  void setPeriodicDimensions(esys::lsm::BoolVector periodicDimensions);

  /**
   * Sets the spatial extent in which particles are tracked.
   */
  void setGeometryInfo(const esys::lsm::GeometryInfo &geoInfo);

  /**
   * Sets geometry info.
   */
  void setSpatialDomain(const esys::lsm::BoundingBox &bBox);

  /**
   * Returns geometry info.
   */
  esys::lsm::GeometryInfo getGeometryInfo() const;

  /**
   *
   */
  int getNumTimeSteps() const;
  
  /**
   * Sets the number of time steps.
   */
  void setNumTimeSteps(int numTimeSteps);

  /*!
    get time step size
  */
  double getTimeStepSize() const;
  
  /**
   * Sets the time step size.
   */
  void setTimeStepSize(double timeStepSize);

  void setPrecision(int precision){m_precision=precision;};

  bool spatialDomainHasBeenSet() const;
 

  MPI_Comm getMpiComm() const;

  void setMpiComm(MPI_Comm mpiComm);
  

protected:
  /**
   *
   */
  MPI_Comm m_mpiComm;


  /**
   * Prefix of check-point files.
   */
  std::string m_fileNamePrefix;

  /**
   *
   */
  int m_beginTime;

  /**
   *
   */
  int m_endTime;

  /**
   *
   */
  int m_timeInterval;

  /**
   *
   */
  esys::lsm::GeometryInfo m_geoInfo;

  /**
   *
   */
  int m_numTimeSteps;

  /**
   *
   */
  double m_timeStepSize;

  bool m_spatialDomainHasBeenSet;
  
  /*!
    If set, pipe all write operations through master process. Useful on installations
    where only proc. 0 can write to files
  */
  bool m_writeThroughMaster;  
  int m_precision; //! output precision (digits)
};

#endif