@@ -120,14 +120,16 @@ namespace pfasst {
120120 this ->set_state (this ->get_end_state (), 0 );
121121 }
122122
123- virtual void integrate (Encapsulation<scalar,time>* dst, time dt) {
123+ virtual void integrate (time dt, vector<Encapsulation<scalar,time>*> dst) const
124+ {
124125 throw NotImplementedYet (" sweeper" );
125126 }
126127 };
127128
128129 template <typename scalar, typename time>
129130 class PolyInterpMixin : public pfasst ::ITransfer {
130- matrix<time> tmat;
131+ matrix<time> tmat, fmat;
132+
131133 public:
132134
133135 virtual void interpolate (ISweeper *DST, const ISweeper *SRC, bool initial)
@@ -192,22 +194,55 @@ namespace pfasst {
192194 for (int m=0 ; m<ndst; m++) dst->evaluate (m);
193195 }
194196
195- virtual void fas (ISweeper *DST , const ISweeper *SRC )
197+ virtual void fas (time dt, ISweeper *dst , const ISweeper *src )
196198 {
197- auto * dst = dynamic_cast <EncapsulatedSweeperMixin<scalar,time>*>(DST );
198- auto * src = dynamic_cast <const EncapsulatedSweeperMixin<scalar,time>*>(SRC );
199+ auto * crse = dynamic_cast <EncapsulatedSweeperMixin<scalar,time>*>(dst );
200+ auto * fine = dynamic_cast <const EncapsulatedSweeperMixin<scalar,time>*>(src );
199201
200- int ndst = dst ->get_nodes ().size ();
201- int nsrc = src ->get_nodes ().size ();
202+ int ncrse = crse ->get_nodes ().size ();
203+ int nfine = fine ->get_nodes ().size ();
202204
203- auto * crse_factory = src ->get_factory ();
204- auto * fine_factory = dst ->get_factory ();
205+ auto * crse_factory = crse ->get_factory ();
206+ auto * fine_factory = fine ->get_factory ();
205207
206- vector<Encapsulation<scalar,time>*> fine_q (ndst), fine_tmp (nsrc);
208+ vector<Encapsulation<scalar,time>*> crse_z2n (ncrse-1 ), fine_z2n (nfine-1 ), rstr_z2n (ncrse-1 );
209+ for (int m=0 ; m<ncrse-1 ; m++) crse_z2n[m] = crse_factory->create (solution);
210+ for (int m=0 ; m<ncrse-1 ; m++) rstr_z2n[m] = crse_factory->create (solution);
211+ for (int m=0 ; m<nfine-1 ; m++) fine_z2n[m] = fine_factory->create (solution);
207212
208- for (int m=0 ; m<ndst; m++) fine_q[m] = dst->get_state (m);
209- for (int m=0 ; m<nsrc; m++) fine_tmp[m] = fine_factory->create (solution);
213+ // compute '0 to node' integral on the coarse level
214+ crse->integrate (dt, crse_z2n);
215+ for (int m=1 ; m<ncrse-1 ; m++)
216+ crse_z2n[m]->saxpy (1.0 , crse_z2n[m-1 ]);
217+
218+ // compute '0 to node' integral on the fine level
219+ fine->integrate (dt, fine_z2n);
220+ for (int m=1 ; m<nfine-1 ; m++)
221+ fine_z2n[m]->saxpy (1.0 , fine_z2n[m-1 ]);
222+
223+ // restrict '0 to node' fine integral
224+ int trat = (nfine - 1 ) / (ncrse - 1 );
225+ for (int m=1 ; m<ncrse; m++)
226+ this ->restrict (rstr_z2n[m-1 ], fine_z2n[m*trat-1 ]);
227+
228+ // compute 'node to node' tau correction
229+ vector<Encapsulation<scalar,time>*> tau (ncrse-1 );
230+ for (int m=0 ; m<ncrse-1 ; m++) tau[m] = crse->get_tau (m);
231+
232+ tau[0 ]->copy (rstr_z2n[0 ]);
233+ tau[0 ]->saxpy (-1.0 , crse_z2n[0 ]);
234+
235+ for (int m=1 ; m<ncrse-1 ; m++) {
236+ tau[m]->copy (rstr_z2n[m]);
237+ tau[m]->saxpy (-1.0 , rstr_z2n[m-1 ]);
238+
239+ tau[m]->saxpy (-1.0 , crse_z2n[m]);
240+ tau[m]->saxpy (1.0 , crse_z2n[m-1 ]);
241+ }
210242
243+ for (int m=0 ; m<ncrse-1 ; m++) delete crse_z2n[m];
244+ for (int m=0 ; m<ncrse-1 ; m++) delete rstr_z2n[m];
245+ for (int m=0 ; m<nfine-1 ; m++) delete fine_z2n[m];
211246 }
212247
213248 // required for interp/restrict helpers
0 commit comments