PFASST++
vector.hpp
Go to the documentation of this file.
1 #ifndef _PFASST_VECTOR_HPP_
2 #define _PFASST_VECTOR_HPP_
3 
4 #include <memory>
5 #include <vector>
6 using namespace std;
7 
8 #ifdef WITH_MPI
10 using namespace pfasst::mpi;
11 #endif
12 
14 
15 
16 namespace pfasst
17 {
18  namespace encap
19  {
26  template<typename scalar, typename time = time_precision>
28  : public vector<scalar>,
29  public Encapsulation<time>
30  {
31  public:
32 
34  VectorEncapsulation(const size_t size);
35 
42 
49 
56 
63 
64  virtual ~VectorEncapsulation();
66 
68  virtual void zero() override;
69  virtual void copy(shared_ptr<const Encapsulation<time>> x) override;
70  virtual void copy(shared_ptr<const VectorEncapsulation<scalar, time>> x);
72 
74  virtual void saxpy(time a, shared_ptr<const Encapsulation<time>> x) override;
75  virtual void saxpy(time a, shared_ptr<const VectorEncapsulation<scalar, time>> x);
76 
81  virtual void mat_apply(vector<shared_ptr<Encapsulation<time>>> dst,
82  time a, Matrix<time> mat,
83  vector<shared_ptr<Encapsulation<time>>> src,
84  bool zero = true) override;
85  virtual void mat_apply(vector<shared_ptr<VectorEncapsulation<scalar, time>>> dst,
86  time a, Matrix<time> mat,
87  vector<shared_ptr<VectorEncapsulation<scalar, time>>> src,
88  bool zero = true);
89 
95  virtual time norm0() const override;
97 
98 #ifdef WITH_MPI
99  MPI_Request recv_request = MPI_REQUEST_NULL;
101  MPI_Request send_request = MPI_REQUEST_NULL;
103 
105  inline MPICommunicator& as_mpi(ICommunicator* comm)
106  {
107  auto mpi = dynamic_cast<MPICommunicator*>(comm);
108  assert(mpi);
109  return *mpi;
110  }
112 
114  virtual void post(ICommunicator* comm, int tag) override;
115  virtual void recv(ICommunicator* comm, int tag, bool blocking) override;
116  virtual void send(ICommunicator* comm, int tag, bool blocking) override;
117  virtual void broadcast(ICommunicator* comm) override;
119 #endif
120 
121  };
122 
129  template<typename scalar, typename time = time_precision>
131  : public EncapFactory<time>
132  {
133  protected:
134  size_t size;
135 
136  public:
137  VectorFactory(const size_t size);
138  virtual shared_ptr<Encapsulation<time>> create(const EncapType) override;
139  size_t dofs() const;
140  };
141 
142  template<typename scalar, typename time = time_precision>
144 
145  template<typename scalar, typename time = time_precision>
147  } // ::pfasst::encap
148 } // ::pfasst
149 
151 
152 #endif
static void zero(vector< precision > &data)
STL namespace.
const VectorEncapsulation< scalar, time > & as_vector(shared_ptr< const Encapsulation< time >> x)
Abstract interface of factory for creating Encapsulation objects.
Data/solution encapsulation.
Abstract interface for communicators.
Definition: interfaces.hpp:70
Eigen::Matrix< scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
static precision norm0(const vector< precision > &data)