PFASST++
interfaces.hpp
Go to the documentation of this file.
1 
7 #ifndef _PFASST_INTERFACES_HPP_
8 #define _PFASST_INTERFACES_HPP_
9 
10 #include <memory>
11 #include <stdexcept>
12 #include <string>
13 using namespace std;
14 
15 
16 namespace pfasst
17 {
18  using time_precision = double;
19 
20 
30  : public runtime_error
31  {
32  public:
36  explicit NotImplementedYet(const string& msg);
37  virtual const char* what() const throw();
38  };
39 
40 
50  class ValueError
51  : public invalid_argument
52  {
53  public:
54  explicit ValueError(const string& msg);
55  virtual const char* what() const throw();
56  };
57 
58 
59  // forward declare for IStatus
60  class IStatus;
61 
62 
71  {
72  public:
73  virtual ~ICommunicator();
74  virtual int size() = 0;
75  virtual int rank() = 0;
76 
77  shared_ptr<IStatus> status;
78  };
79 
80 
87  class IStatus
88  {
89  public:
90  static const int NOT_CONVERGED = 0;
91  static const int CONVERGED = 1;
92 
93  protected:
95 
96  public:
97  virtual ~IStatus();
98 
100 
105  virtual void clear() = 0;
106 
110  virtual void set_converged(bool converged) = 0;
111 
120  virtual bool get_converged(int rank) = 0;
122 
124 
127  virtual void set_comm(ICommunicator* comm);
128 
134  virtual bool previous_is_iterating();
135 
142  virtual bool keep_iterating();
144 
146  virtual void post(int tag) = 0;
147  virtual void send(int tag) = 0;
148  virtual void recv(int tag) = 0;
150  };
151 
152 
153  // forward declare for ISweeper
154  template<typename time>
155  class Controller;
156 
157 
163  template<typename time = time_precision>
164  class ISweeper
165  {
166  protected:
171 
172  public:
174  ISweeper();
175  virtual ~ISweeper();
177 
179 
184  virtual void set_controller(Controller<time>* ctrl);
185 
191  virtual Controller<time>* get_controller();
193 
195 
198  virtual void set_options();
199 
206  virtual void setup(bool coarse = false);
207 
219  virtual void predict(bool initial) = 0;
220 
228  virtual void sweep() = 0;
229 
236  virtual void advance() = 0;
237 
243  virtual bool converged();
244 
255  virtual void save(bool initial_only=false);
256 
260  virtual void spread();
262 
264 
267  virtual void post_sweep();
268 
272  virtual void post_predict();
273 
277  virtual void post_step();
279 
281  virtual void post(ICommunicator* comm, int tag);
282  virtual void send(ICommunicator* comm, int tag, bool blocking);
283  virtual void recv(ICommunicator* comm, int tag, bool blocking);
284  virtual void broadcast(ICommunicator* comm);
286  };
287 
288 
294  template<typename time = time_precision>
295  class ITransfer
296  {
297  public:
299  virtual ~ITransfer();
301 
303 
309  virtual void interpolate_initial(shared_ptr<ISweeper<time>> dst,
310  shared_ptr<const ISweeper<time>> src);
311 
320  virtual void interpolate(shared_ptr<ISweeper<time>> dst,
321  shared_ptr<const ISweeper<time>> src,
322  bool interp_initial = false) = 0;
324 
326 
332  virtual void restrict_initial(shared_ptr<ISweeper<time>> dst,
333  shared_ptr<const ISweeper<time>> src);
334 
335 
343  virtual void restrict(shared_ptr<ISweeper<time>> dst,
344  shared_ptr<const ISweeper<time>> src,
345  bool restrict_initial = false) = 0;
347 
349 
356  virtual void fas(time dt, shared_ptr<ISweeper<time>> dst,
357  shared_ptr<const ISweeper<time>> src) = 0;
359  };
360 } // ::pfasst
361 
363 
364 #endif
double time_precision
Definition: interfaces.hpp:18
ICommunicator * comm
Definition: interfaces.hpp:94
void setup(shared_ptr< WrapperInterface< scalar, time >> wrapper)
Not implemented yet exception.
Definition: interfaces.hpp:29
Base SDC/MLSDC/PFASST controller.
Definition: interface.hpp:31
STL namespace.
Controller< time > * controller
Backreference to the controller managing the sweeper instance.
Definition: interfaces.hpp:170
Value exception.
Definition: interfaces.hpp:50
Abstract interface for the current status of the algorithm.
Definition: interfaces.hpp:87
Abstract time/space transfer (restrict/interpolate) class.
Definition: interfaces.hpp:295
Abstract interface for communicators.
Definition: interfaces.hpp:70
Abstract SDC sweeper.
Definition: interfaces.hpp:164
float dt
Definition: plot.py:10
shared_ptr< IStatus > status
Definition: interfaces.hpp:77