PFASST++
interfaces_impl.hpp
Go to the documentation of this file.
1 #include "pfasst/interfaces.hpp"
2 
3 #include <cassert>
4 #include <memory>
5 #include <string>
6 using namespace std;
7 
8 #include "pfasst/globals.hpp"
9 #include "pfasst/logging.hpp"
10 
11 
12 namespace pfasst
13 {
14  NotImplementedYet::NotImplementedYet(const string& msg)
15  : runtime_error(msg)
16  {}
17 
23  const char* NotImplementedYet::what() const throw()
24  {
25  return (string("Not implemented/supported yet, required for: ") + string(runtime_error::what())).c_str();
26  }
27 
28 
29  ValueError::ValueError(const string& msg)
30  : invalid_argument(msg)
31  {}
32 
38  const char* ValueError::what() const throw()
39  {
40  return (string("ValueError: ") + string(invalid_argument::what())).c_str();
41  }
42 
43 
45  {}
46 
47 
49  {}
50 
53  {
54  this->comm = comm;
55  }
56 
59  {
60  if (this->comm->rank() == 0) {
61  return false;
62  }
63  return !this->get_converged(this->comm->rank() - 1);
64  }
65 
78  {
79  if (this->comm->rank() == 0) {
80  return !this->get_converged(0);
81  }
82  bool keep_iterating = !this->get_converged(this->comm->rank() - 1) || !this->get_converged(this->comm->rank());
83  ML_CLOG(DEBUG, "Controller", "previous converged: " << boolalpha << this->get_converged(this->comm->rank() - 1)
84  << "; this converged: " << boolalpha << this->get_converged(this->comm->rank())
85  << " --> keep iterating: " << boolalpha << keep_iterating);
86  return keep_iterating;
87  }
88 
89 
90  template<typename time>
92  : controller(nullptr)
93  {}
94 
95  template<typename time>
97  {}
98 
102  template<typename time>
104  {
105  this->controller = ctrl;
106  }
107 
113  template<typename time>
115  {
116  assert(this->controller);
117  return this->controller;
118  }
119 
125  template<typename time>
127  {}
128 
129  template<typename time>
130  void ISweeper<time>::setup(bool coarse)
131  {
132  UNUSED(coarse);
133  }
134 
138  template<typename time>
140  {
141  return false;
142  }
143 
147  template<typename time>
148  void ISweeper<time>::save(bool initial_only)
149  {
150  UNUSED(initial_only);
151  throw NotImplementedYet("mlsdc/pfasst");
152  }
153 
157  template<typename time>
159  {
160  throw NotImplementedYet("pfasst");
161  }
162 
163  template<typename time>
165  {}
166 
167  template<typename time>
169  {}
170 
171  template<typename time>
173  {}
174 
175  template<typename time>
176  void ISweeper<time>::post(ICommunicator* comm, int tag)
177  {
178  UNUSED(comm); UNUSED(tag);
179  }
180 
184  template<typename time>
185  void ISweeper<time>::send(ICommunicator* comm, int tag, bool blocking)
186  {
187  UNUSED(comm); UNUSED(tag); UNUSED(blocking);
188  throw NotImplementedYet("pfasst");
189  }
190 
194  template<typename time>
195  void ISweeper<time>::recv(ICommunicator* comm, int tag, bool blocking)
196  {
197  UNUSED(comm); UNUSED(tag); UNUSED(blocking);
198  throw NotImplementedYet("pfasst");
199  }
200 
204  template<typename time>
206  {
207  UNUSED(comm);
208  throw NotImplementedYet("pfasst");
209  }
210 
211 
212  template<typename time>
214  {}
215 
219  template<typename time>
221  shared_ptr<const ISweeper<time>> src)
222  {
223  UNUSED(dst); UNUSED(src);
224  throw NotImplementedYet("pfasst");
225  }
226 
230  template<typename time>
232  shared_ptr<const ISweeper<time>> src)
233  {
234  UNUSED(dst); UNUSED(src);
235  throw NotImplementedYet("pfasst");
236  }
237 } // ::pfasst
virtual void broadcast(ICommunicator *comm)
virtual bool previous_is_iterating()
Check whether previous processor is still iterating.
virtual void post_sweep()
Hook automatically run after each completed sweep.
virtual void spread()
Initialize solution values at all time nodes with meaningful values.
virtual bool get_converged(int rank)=0
Retreive converged state for specific processor.
ICommunicator * comm
Definition: interfaces.hpp:94
Not implemented yet exception.
Definition: interfaces.hpp:29
Base SDC/MLSDC/PFASST controller.
Definition: interface.hpp:31
virtual const char * what() const
STL namespace.
virtual void set_controller(Controller< time > *ctrl)
Set the sweepers controller.
virtual bool converged()
Return convergence status.
virtual void post_predict()
Hook automatically run after each completed predict.
virtual Controller< time > * get_controller()
Accessor to the controller managing this sweeper.
virtual void set_comm(ICommunicator *comm)
Set new communicator to use.
#define ML_CLOG(level, logger_id, x)
same as CLOG(level, logger, x) from easylogging++
Definition: logging.hpp:117
virtual void set_options()
Set options from command line etc.
virtual bool keep_iterating()
Check whether this processor should keep iterating.
virtual const char * what() const
virtual void post(ICommunicator *comm, int tag)
virtual void post_step()
Hook automatically run after each completed time step.
virtual void restrict_initial(shared_ptr< ISweeper< time >> dst, shared_ptr< const ISweeper< time >> src)
Restrict initial condition from the fine sweeper to the coarse sweeper.
virtual int rank()=0
interfaces for SDC/MLSDC/PFASST algorithms.
virtual void setup(bool coarse=false)
Setup (allocate etc) the sweeper.
#define UNUSED(expr)
Denoting unused function parameters for omitting compiler warnings.
Definition: globals.hpp:32
Abstract interface for communicators.
Definition: interfaces.hpp:70
virtual void interpolate_initial(shared_ptr< ISweeper< time >> dst, shared_ptr< const ISweeper< time >> src)
Interpolate initial condition from the coarse sweeper to the fine sweeper.
virtual void send(ICommunicator *comm, int tag, bool blocking)
virtual void save(bool initial_only=false)
Save states (and/or function values) at all nodes.
Abstract SDC sweeper.
Definition: interfaces.hpp:164
virtual void recv(ICommunicator *comm, int tag, bool blocking)
ValueError(const string &msg)