55#ifndef _PFASST_INTERFACES_HPP_
66#define _PFASST_INTERFACES_HPP_
77
8- #include < cassert>
9- #include < deque>
108#include < exception>
11- #include < iterator>
129#include < memory>
1310#include < string>
14-
15- #include " globals.hpp"
16-
1711using namespace std ;
1812
13+
1914namespace pfasst
2015{
21-
2216 using time_precision = double ;
2317
24- // forward declare for ISweeper
25- template <typename time>
26- class Controller ;
2718
2819 /* *
2920 * not implemented yet exception.
@@ -34,16 +25,11 @@ namespace pfasst
3425 class NotImplementedYet
3526 : public exception
3627 {
28+ protected:
3729 string msg;
3830 public:
39- NotImplementedYet (string msg)
40- : msg(msg)
41- {}
42-
43- const char * what () const throw()
44- {
45- return (string (" Not implemented/supported yet, required for: " ) + this ->msg ).c_str ();
46- }
31+ NotImplementedYet (const string& msg);
32+ virtual const char * what () const throw();
4733 };
4834
4935
@@ -55,67 +41,51 @@ namespace pfasst
5541 class ValueError
5642 : public exception
5743 {
44+ protected:
5845 string msg;
5946 public:
60- ValueError (string msg)
61- : msg(msg)
62- {}
63-
64- const char * what () const throw()
65- {
66- return (string (" ValueError: " ) + this ->msg ).c_str ();
67- }
47+ ValueError (const string& msg);
48+ virtual const char * what () const throw();
6849 };
6950
51+
52+ // forward declare for IStatus
7053 class IStatus ;
7154
7255 class ICommunicator
7356 {
7457 public:
75- virtual ~ICommunicator () { }
58+ virtual ~ICommunicator ();
7659 virtual int size () = 0;
7760 virtual int rank () = 0;
7861
7962 shared_ptr<IStatus> status;
8063 };
8164
65+
8266 class IStatus
8367 {
8468 protected:
8569 ICommunicator* comm;
8670
8771 public:
88- virtual ~IStatus () { }
72+ virtual ~IStatus ();
8973 virtual void clear () = 0;
9074 virtual void set_converged (bool converged) = 0;
9175 virtual bool get_converged (int rank) = 0;
9276 virtual void post () = 0;
9377 virtual void send () = 0;
9478 virtual void recv () = 0;
9579
96- virtual void set_comm (ICommunicator* comm)
97- {
98- this ->comm = comm;
99- }
100-
101- virtual bool previous_is_iterating ()
102- {
103- if (this ->comm ->rank () == 0 ) {
104- return false ;
105- }
106- return !this ->get_converged (this ->comm ->rank ()-1 );
107- }
108-
109- virtual bool keep_iterating ()
110- {
111- if (this ->comm ->rank () == 0 ) {
112- return !this ->get_converged (0 );
113- }
114- return !this ->get_converged (this ->comm ->rank ()) || !this ->get_converged (this ->comm ->rank ()-1 );
115- }
80+ virtual void set_comm (ICommunicator* comm);
81+ virtual bool previous_is_iterating ();
82+ virtual bool keep_iterating ();
11683 };
11784
11885
86+ // forward declare for ISweeper
87+ template <typename time>
88+ class Controller ;
11989
12090 /* *
12191 * abstract SDC sweeper.
@@ -130,48 +100,32 @@ namespace pfasst
130100
131101 public:
132102 // ! @{
133- ISweeper ()
134- : controller(nullptr )
135- {}
136-
137- virtual ~ISweeper ()
138- {}
103+ ISweeper ();
104+ virtual ~ISweeper ();
139105 // ! @}
140106
141107 // ! @{
142108 /* *
143109 * set the sweepers controller.
144110 */
145- void set_controller (Controller<time>* ctrl)
146- {
147- this ->controller = ctrl;
148- }
149-
150- Controller<time>* get_controller ()
151- {
152- assert (this ->controller );
153- return this ->controller ;
154- }
111+ void set_controller (Controller<time>* ctrl);
112+
113+ Controller<time>* get_controller ();
155114 // ! @}
156115
157116 // ! @{
158117 /* *
159118 * Set options from command line etc.
160119 */
161- virtual void set_options ()
162- {
163- }
120+ virtual void set_options ();
164121
165122 /* *
166123 * Setup (allocate etc) the sweeper.
167124 * @param[in] coarse
168125 * `true` if this sweeper exists on a coarsened MLSDC or PFASST level.
169126 * This implies that space for an FAS correction and "saved" solutions are necessary.
170127 */
171- virtual void setup (bool coarse = false )
172- {
173- UNUSED (coarse);
174- }
128+ virtual void setup (bool coarse = false );
175129
176130 /* *
177131 * perform a predictor sweep.
@@ -208,7 +162,7 @@ namespace pfasst
208162 *
209163 * This is used by controllers to shortcircuit iterations.
210164 */
211- virtual bool converged () { return false ; }
165+ virtual bool converged ();
212166
213167 /* *
214168 * Save states (and/or function values) at all nodes.
@@ -218,51 +172,27 @@ namespace pfasst
218172 *
219173 * @note This method must be implemented in derived sweepers.
220174 */
221- virtual void save (bool initial_only=false )
222- {
223- UNUSED (initial_only);
224- throw NotImplementedYet (" mlsdc/pfasst" );
225- }
226-
227- virtual void spread ()
228- {
229- throw NotImplementedYet (" pfasst" );
230- }
175+ virtual void save (bool initial_only=false );
176+
177+ virtual void spread ();
231178 // ! @}
232179
233180 // ! @{
234- virtual void post_sweep () { }
235- virtual void post_predict () { }
236- virtual void post_step () { }
181+ virtual void post_sweep ();
182+ virtual void post_predict ();
183+ virtual void post_step ();
237184 // ! @}
238185
239186 // ! @{
240- virtual void post (ICommunicator* comm, int tag)
241- {
242- UNUSED (comm); UNUSED (tag);
243- };
244-
245- virtual void send (ICommunicator* comm, int tag, bool blocking)
246- {
247- UNUSED (comm); UNUSED (tag); UNUSED (blocking);
248- throw NotImplementedYet (" pfasst" );
249- }
250-
251- virtual void recv (ICommunicator* comm, int tag, bool blocking)
252- {
253- UNUSED (comm); UNUSED (tag); UNUSED (blocking);
254- throw NotImplementedYet (" pfasst" );
255- }
256-
257- virtual void broadcast (ICommunicator* comm)
258- {
259- UNUSED (comm);
260- throw NotImplementedYet (" pfasst" );
261- }
187+ virtual void post (ICommunicator* comm, int tag);
188+ virtual void send (ICommunicator* comm, int tag, bool blocking);
189+ virtual void recv (ICommunicator* comm, int tag, bool blocking);
190+ virtual void broadcast (ICommunicator* comm);
262191 // ! @}
263192
264193 };
265194
195+
266196 /* *
267197 * abstract time/space transfer (restrict/interpolate) class.
268198 * @tparam time time precision
@@ -273,20 +203,15 @@ namespace pfasst
273203 {
274204 public:
275205 // ! @{
276- virtual ~ITransfer ()
277- {}
206+ virtual ~ITransfer ();
278207 // ! @}
279208
280209 // ! @{
281210 /* *
282211 * Interpolate initial condition from the coarse sweeper to the fine sweeper.
283212 */
284213 virtual void interpolate_initial (shared_ptr<ISweeper<time>> dst,
285- shared_ptr<const ISweeper<time>> src)
286- {
287- UNUSED (dst); UNUSED (src);
288- throw NotImplementedYet (" pfasst" );
289- }
214+ shared_ptr<const ISweeper<time>> src);
290215
291216 /* *
292217 * Interpolate, in time and space, from the coarse sweeper to the fine sweeper.
@@ -303,11 +228,7 @@ namespace pfasst
303228 * `true` if the initial condition should also be restricted.
304229 */
305230 virtual void restrict_initial (shared_ptr<ISweeper<time>> dst,
306- shared_ptr<const ISweeper<time>> src)
307- {
308- UNUSED (dst); UNUSED (src);
309- throw NotImplementedYet (" pfasst" );
310- }
231+ shared_ptr<const ISweeper<time>> src);
311232
312233
313234 /* *
@@ -327,7 +248,8 @@ namespace pfasst
327248 shared_ptr<const ISweeper<time>> src) = 0;
328249 // ! @}
329250 };
330-
331251} // ::pfasst
332252
253+ #include " interfaces_impl.hpp"
254+
333255#endif
0 commit comments