77
88#include < vector>
99
10- #include " pfasst.hpp"
10+ #include " pfasst-interfaces.hpp"
11+ #include " pfasst-quadrature.hpp"
1112
1213using namespace std ;
1314
1415namespace pfasst {
1516
16- template <typename T>
17- vector<T> compute_nodes (unsigned int nnodes, string qtype) {
18- vector<T> nodes (nnodes);
19-
20- // ...
21-
22- return nodes;
23- }
24-
25- typedef enum encaptype { solution, function } encaptype;
26-
27- template <typename T>
28- class matrix : public vector <T> {
29-
30- public:
31- unsigned int n, m;
32- matrix () { }
33- matrix (unsigned int n, unsigned int m) {
34- zeros (n, m);
35- }
36- void zeros (unsigned int n, unsigned int m) {
37- this ->n = n; this ->m = m;
38- this ->resize (n*m);
39- // ...
40- }
41- T& operator ()(unsigned int i, unsigned int j) {
42- return (*this )[i*m+j];
43- }
44- };
17+ typedef enum EncapType { solution, function } EncapType;
4518
4619 //
4720 // encapsulation
4821 //
4922
50- struct encapsulation {
51- virtual ~encapsulation () { }
23+ class Encapsulation {
24+ public:
25+ virtual ~Encapsulation () { }
26+
27+ // required for interp/restrict helpers
28+ virtual void interpolate (const Encapsulation *) { }
29+ virtual void restrict (const Encapsulation *) { }
5230
5331 // required for time-parallel communications
54- virtual unsigned int nbytes () { }
32+ virtual unsigned int nbytes () { return - 1 ; }
5533 virtual void pack (char *buf) { }
5634 virtual void unpack (char *buf) { }
5735
58- // required for interp/restrict helpers
59- virtual void interpolate (const encapsulation *) { }
60- virtual void restrict (const encapsulation *) { }
61-
6236 // required for host based encap helpers
6337 virtual void setval (double ) { }
64- virtual void copy (const encapsulation *) { }
65- virtual void mat_apply (encapsulation dst[], double a, matrix m, const encapsulation src[]) { }
38+ virtual void copy (const Encapsulation *) { }
39+ virtual void saxpy (double a, const Encapsulation *) { }
40+ // virtual void mat_apply(encapsulation dst[], double a, matrix m, const encapsulation src[]) { }
6641 };
6742
68- struct encapsulation_factory {
69- virtual encapsulation* create (const encaptype) = 0;
43+ class EncapsulationFactory {
44+ public:
45+ virtual Encapsulation* create (const EncapType) = 0;
7046 };
7147
72-
7348 template <typename T>
74- class encapsulated_sweeper_mixin : public isweeper {
75- shared_ptr< vector<T>> nodes;
76- shared_ptr<encapsulation_factory> encap ;
49+ class EncapsulatedSweeperMixin : public ISweeper {
50+ vector<T> nodes;
51+ shared_ptr<EncapsulationFactory> factory ;
7752
7853 public:
79- vector<encapsulation*> q;
80- vector<T>* get_nodes () { return nodes.get (); }
54+ void set_nodes (vector<T> nodes) { this ->nodes = nodes; }
55+ const vector<T> get_nodes () const { return nodes; }
56+
57+ void set_factory (EncapsulationFactory* factory) { this ->factory = shared_ptr<EncapsulationFactory>(factory); }
58+ EncapsulationFactory* get_factory () const { return factory.get (); }
8159
82- virtual void set_q0 (const encapsulation * q0) { }
83- virtual encapsulation * get_qend () { }
60+ virtual void set_q0 (const Encapsulation * q0) { throw NotImplementedYet ( " sweeper " ); }
61+ virtual Encapsulation * get_qend () { throw NotImplementedYet ( " sweeper " ); return NULL ; }
8462 };
8563
8664 template <class T >
87- class poly_interp_mixin : public T {
88- virtual void interpolate (const isweeper *) { }
89- virtual void restrict (const isweeper *) { }
65+ class PolyInterpMixin : public T {
66+ virtual void interpolate (const ISweeper *) { }
67+ virtual void restrict (const ISweeper *) { }
9068 };
9169
9270 template <typename T>
93- struct vector_encapsulation : public vector <T>, public encapsulation {
94- vector_encapsulation (int size) : vector<T>(size) { }
71+ struct VectorEncapsulation : public vector <T>, public Encapsulation {
72+ VectorEncapsulation (int size) : vector<T>(size) { }
9573 virtual unsigned int nbytes () const {
9674 return sizeof (T) * this ->size ();
9775 }
@@ -103,12 +81,13 @@ namespace pfasst {
10381 };
10482
10583 template <typename T>
106- class vector_factory : public pfasst ::encapsulation_factory {
84+ class VectorFactory : public EncapsulationFactory {
10785 int size;
10886 public:
109- vector_factory (const int size) : size(size) { }
110- encapsulation* create (const pfasst::encap_type) {
111- return new vector_encapsulation<T>(size);
87+ int dofs () { return size; }
88+ VectorFactory (const int size) : size(size) { }
89+ Encapsulation* create (const EncapType) {
90+ return new VectorEncapsulation<T>(size);
11291 }
11392 };
11493
0 commit comments