Skip to content

Commit fc32def

Browse files
committed
incorporating @memmett's suggestions
1 parent 45f3d4f commit fc32def

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

include/pfasst/encap/imex_sweeper.hpp

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ namespace pfasst
2626
*
2727
* Given an ODE \\( \\frac{\\partial}{\\partial t}u(t) = F(t,u) \\) where the function of the
2828
* right hand side \\( F(t,u) \\) can be split into a non-stiff and a stiff part.
29-
* To reduce complexity and computational efford one would want to solve the non-stiff part
29+
* To reduce complexity and computational effort one would want to solve the non-stiff part
3030
* explicitly and the stiff part implicitly.
3131
* Therefore, we define the splitting \\( F(t,u) = F_{expl}(t,u) + F_{impl}(t,u) \\).
3232
*
33-
* This sweeper provides an interface for such ODEs were the implicit part can be computed by
34-
* an external implicit solver without actually evaluating \\( F_{impl}(t,u) \\), which is
35-
* possibly very expensive.
33+
* This sweeper requires three interfaces to be implement for such ODEs: two routines to
34+
* evaluate the explicit \\( F_{\\rm expl} \\) and implicit \\( F_{\\rm impl} \\) pieces for a
35+
* given state, and one that solves (perhaps with an external solver) the backward-Euler
36+
* equation \\( U^{n+1} - \\Delta t F_{\\rm impl}(U^{n+1}) = RHS \\) for \\( U^{n+1} \\).
3637
*
3738
* @tparam time precision type of the time dimension
3839
*/
@@ -46,13 +47,13 @@ namespace pfasst
4647
* solution values \\( u(\\tau) \\) at all time nodes \\( \\tau \\in [0, M-1] \\) of the
4748
* current iteration
4849
*/
49-
vector<shared_ptr<Encapsulation<time>>> us;
50+
vector<shared_ptr<Encapsulation<time>>> u_state;
5051

5152
/**
5253
* solution values \\( u(t) \\) at all time nodes \\( t \\in [0, M-1] \\) of the
5354
* previous iteration
5455
*/
55-
vector<shared_ptr<Encapsulation<time>>> previous_us;
56+
vector<shared_ptr<Encapsulation<time>>> previous_u_state;
5657

5758
/**
5859
* node-to-node integrated values of \\( F(t,u) \\) at all time nodes \\( t \\in
@@ -109,12 +110,12 @@ namespace pfasst
109110
//! @{
110111
virtual void set_state(shared_ptr<const Encapsulation<time>> u0, size_t m) override
111112
{
112-
this->us[m]->copy(u0);
113+
this->u_state[m]->copy(u0);
113114
}
114115

115116
virtual shared_ptr<Encapsulation<time>> get_state(size_t m) const override
116117
{
117-
return this->us[m];
118+
return this->u_state[m];
118119
}
119120

120121
virtual shared_ptr<Encapsulation<time>> get_tau(size_t m) const override
@@ -124,7 +125,7 @@ namespace pfasst
124125

125126
virtual shared_ptr<Encapsulation<time>> get_saved_state(size_t m) const override
126127
{
127-
return this->previous_us[m];
128+
return this->previous_u_state[m];
128129
}
129130
//! @}
130131

@@ -185,9 +186,9 @@ namespace pfasst
185186
}
186187

187188
for (size_t m = 0; m < nodes.size(); m++) {
188-
this->us.push_back(this->get_factory()->create(pfasst::encap::solution));
189+
this->u_state.push_back(this->get_factory()->create(pfasst::encap::solution));
189190
if (coarse) {
190-
this->previous_us.push_back(this->get_factory()->create(pfasst::encap::solution));
191+
this->previous_u_state.push_back(this->get_factory()->create(pfasst::encap::solution));
191192
}
192193
this->fs_expl.push_back(this->get_factory()->create(pfasst::encap::function));
193194
this->fs_impl.push_back(this->get_factory()->create(pfasst::encap::function));
@@ -211,18 +212,18 @@ namespace pfasst
211212
time t = this->get_controller()->get_time();
212213

213214
if (initial) {
214-
this->f_expl_eval(this->fs_expl[0], this->us[0], t);
215-
this->f_impl_eval(this->fs_impl[0], this->us[0], t);
215+
this->f_expl_eval(this->fs_expl[0], this->u_state[0], t);
216+
this->f_impl_eval(this->fs_impl[0], this->u_state[0], t);
216217
}
217218

218219
shared_ptr<Encapsulation<time>> rhs = this->get_factory()->create(pfasst::encap::solution);
219220

220221
for (size_t m = 0; m < nnodes - 1; m++) {
221222
time ds = dt * (nodes[m + 1] - nodes[m]);
222-
rhs->copy(this->us[m]);
223+
rhs->copy(this->u_state[m]);
223224
rhs->saxpy(ds, this->fs_expl[m]);
224-
this->impl_solve(this->fs_impl[m + 1], this->us[m + 1], t, ds, rhs);
225-
this->f_expl_eval(this->fs_expl[m + 1], this->us[m + 1], t + ds);
225+
this->impl_solve(this->fs_impl[m + 1], this->u_state[m + 1], t, ds, rhs);
226+
this->f_expl_eval(this->fs_expl[m + 1], this->u_state[m + 1], t + ds);
226227

227228
t += ds;
228229
}
@@ -252,39 +253,39 @@ namespace pfasst
252253
for (size_t m = 0; m < nnodes - 1; m++) {
253254
time ds = dt * (nodes[m + 1] - nodes[m]);
254255

255-
rhs->copy(this->us[m]);
256+
rhs->copy(this->u_state[m]);
256257
rhs->saxpy(ds, this->fs_expl[m]);
257258
rhs->saxpy(1.0, this->s_integrals[m]);
258-
this->impl_solve(this->fs_impl[m + 1], this->us[m + 1], t, ds, rhs);
259-
this->f_expl_eval(this->fs_expl[m + 1], this->us[m + 1], t + ds);
259+
this->impl_solve(this->fs_impl[m + 1], this->u_state[m + 1], t, ds, rhs);
260+
this->f_expl_eval(this->fs_expl[m + 1], this->u_state[m + 1], t + ds);
260261

261262
t += ds;
262263
}
263264
}
264265

265266
virtual void advance() override
266267
{
267-
this->us[0]->copy(this->us.back());
268+
this->u_state[0]->copy(this->u_state.back());
268269
this->fs_expl[0]->copy(this->fs_expl.back());
269270
this->fs_impl[0]->copy(this->fs_impl.back());
270271
}
271272

272273
virtual void save(bool initial_only) override
273274
{
274275
if (initial_only) {
275-
this->previous_us[0]->copy(us[0]);
276+
this->previous_u_state[0]->copy(u_state[0]);
276277
} else {
277-
for (size_t m = 0; m < this->previous_us.size(); m++) {
278-
this->previous_us[m]->copy(us[m]);
278+
for (size_t m = 0; m < this->previous_u_state.size(); m++) {
279+
this->previous_u_state[m]->copy(u_state[m]);
279280
}
280281
}
281282
}
282283

283284
virtual void evaluate(size_t m) override
284285
{
285286
time t = this->get_nodes()[m]; // XXX
286-
this->f_expl_eval(this->fs_expl[m], this->us[m], t);
287-
this->f_impl_eval(this->fs_impl[m], this->us[m], t);
287+
this->f_expl_eval(this->fs_expl[m], this->u_state[m], t);
288+
this->f_impl_eval(this->fs_impl[m], this->u_state[m], t);
288289
}
289290

290291
/**
@@ -302,11 +303,11 @@ namespace pfasst
302303

303304
//! @{
304305
/**
305-
* Evaluates the explicit part of the right hand side at the given time.
306+
* Evaluates the explicit part of the right hand side of the ODE at the given time.
306307
*
307308
* @param[in,out] f_expl_encap Encapsulation to store the evaluated right hand side
308309
* @param[in] u_encap Encapsulation storing the solution values to use for computing the
309-
* explicit part of the right hand side
310+
* explicit part of the right hand side of the ODE
310311
* @param[in] t time point of the evaluation
311312
*
312313
* @note This method must be implemented in derived sweepers.
@@ -320,14 +321,14 @@ namespace pfasst
320321
}
321322

322323
/**
323-
* Evaluates the implicit part of the right hand side at the given time.
324+
* Evaluates the implicit part of the right hand side of the ODE at the given time.
324325
*
325326
* This is typically called to compute the implicit part of the right hand side at the first
326327
* collocation node, and on all nodes after restriction or interpolation.
327328
*
328329
* @param[in,out] f_impl_encap Encapsulation to store the evaluated right hand side
329330
* @param[in] u_encap Encapsulation storing the solution values to use for computing the
330-
* implicit part of the right hand side
331+
* implicit part of the right hand side of the ODE
331332
* @param[in] t time point of the evaluation
332333
*
333334
* @note This method must be implemented in derived sweepers.
@@ -341,18 +342,18 @@ namespace pfasst
341342
}
342343

343344
/**
344-
* Solves \\( U - \\Delta t f_{\\rm impl}(U) = RHS \\) for \\(U\\).
345+
* Solves \\( U - \\Delta t f_{\\rm impl}(U) = RHS \\) for \\( U \\).
345346
*
346347
* During an IMEX SDC sweep, the correction equation is evolved using a forward-Euler
347348
* stepper for the explicit piece, and a backward-Euler stepper for the implicit piece.
348349
* This routine (implemented by the user) performs the solve required to perform one
349-
* backward-Euler sub-step, and also returns \\(f_{\\rm impl}(U)\\).
350+
* backward-Euler sub-step, and also returns \\( f_{\\rm impl}(U) \\).
350351
*
351352
* @param[in,out] f_encap Encapsulation to store the evaluated right hand side
352353
* @param[in,out] u_encap Encapsulation to store the solution of the backward-Euler sub-step
353-
* @param[in] t time point (of \\(RHS\\))
354-
* @param[in] dt sub-step size to the previous time point (\\(\\Delta t \\))
355-
* @param[in] rhs_encap Encapsulation storing \\(RHS\\)
354+
* @param[in] t time point (of \\( RHS \\))
355+
* @param[in] dt sub-step size to the previous time point (\\( \\Delta t \\))
356+
* @param[in] rhs_encap Encapsulation storing \\( RHS \\)
356357
*
357358
* @note This method must be implemented in derived sweepers.
358359
*/

0 commit comments

Comments
 (0)