Skip to content

Commit 0329227

Browse files
committed
Merge pull request #150 from memmett/feature/implicit-lu
Create implicit sweeper that supports LU decomposition of Q. This fixes #31.
2 parents a1b9cf2 + 4dfed11 commit 0329227

File tree

4 files changed

+379
-165
lines changed

4 files changed

+379
-165
lines changed

examples/vanderpol/vdp_sweeper.hpp

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using namespace std;
1515

1616
#include <pfasst/logging.hpp>
17-
#include <pfasst/encap/imex_sweeper.hpp>
17+
#include <pfasst/encap/implicit_sweeper.hpp>
1818
#include <pfasst/encap/vector.hpp>
1919

2020

@@ -44,18 +44,14 @@ namespace pfasst
4444
* y' = \\nu*(1 - x^2)*y - x
4545
* \\]
4646
*
47-
* Although derived from the IMEX sweeper, the explicit part does not do anything
48-
* and a fully implicit Euler is used as a base method.
49-
*
50-
* Note that an analytical solution is available only for \\( \\nu=0 \\), where the vdP
51-
* simplifies to the standard linear oscillator.
52-
* Hence, actual errors are computed only for \\( \\nu=0 \\).
47+
* Note that an analytical solution is available only for \\( \\nu=0 \\), where the vdP simplifies
48+
* to the standard linear oscillator. Hence, actual errors are computed only for \\( \\nu=0 \\).
5349
*
5450
* @ingroup VanDerPol
5551
*/
5652
template<typename time = pfasst::time_precision>
5753
class VdpSweeper
58-
: public encap::IMEXSweeper<time>
54+
: public encap::ImplicitSweeper<time>
5955
{
6056
private:
6157
typedef encap::Encapsulation<time> encap_type;
@@ -75,8 +71,8 @@ namespace pfasst
7571
//! Tolerance for the nonlinear Newton iteration
7672
double newton_tol;
7773

78-
//! Counters for how often `f_expl_eval`, `f_impl_eval` and `impl_solve` are called.
79-
size_t n_f_expl_eval, n_f_impl_eval, n_impl_solve, n_newton_iter;
74+
//! Counters for how often `f_impl_eval` and `impl_solve` are called.
75+
size_t n_f_impl_eval, n_impl_solve, n_newton_iter;
8076

8177
//! Output file
8278
fstream output_file;
@@ -98,7 +94,6 @@ namespace pfasst
9894
, y0(y0)
9995
, newton_maxit(50)
10096
, newton_tol(1e-12)
101-
, n_f_expl_eval(0)
10297
, n_f_impl_eval(0)
10398
, n_impl_solve(0)
10499
, n_newton_iter(0)
@@ -114,7 +109,6 @@ namespace pfasst
114109
*/
115110
virtual ~VdpSweeper()
116111
{
117-
LOG(INFO) << "Number of explicit evaluations:" << this->n_f_expl_eval;
118112
LOG(INFO) << "Number of implicit evaluations:" << this->n_f_impl_eval;
119113
LOG(INFO) << "Number of implicit solves: " << this->n_impl_solve;
120114
this->output_file.close();
@@ -186,7 +180,7 @@ namespace pfasst
186180
if (this->nu==0)
187181
{
188182
/**
189-
* For \\( \\nu=0 \\) and given initial value \\( x0 \\), \\( y0 \\), the analytic
183+
* For \\( \\nu=0 \\) and given initial value \\( x0 \\), \\( y0 \\), the analytic
190184
* solution reads
191185
*
192186
* \\[
@@ -215,29 +209,7 @@ namespace pfasst
215209
}
216210

217211
/**
218-
* evaluate the explicit part of the right hand side.
219-
*
220-
* Because we use a fully implicit Euler for the vdP oscillator, this returns zeros.
221-
*/
222-
void f_expl_eval(shared_ptr<encap_type> f_encap,
223-
shared_ptr<encap_type> q_encap, time t) override
224-
{
225-
UNUSED(t);
226-
UNUSED(q_encap);
227-
auto& f = encap::as_vector<double, time>(f_encap);
228-
//auto& q = pfasst::encap::as_vector<double, time>(q_encap);
229-
230-
// We use a fully implicit sweeper, so f_expl_eval returns zero
231-
f[0] = 0.0;
232-
f[1] = 0.0;
233-
this->n_f_expl_eval++;
234-
}
235-
236-
/**
237-
* evaluate the implicit part of the right hand side.
238-
*
239-
* Because we use a fully implicit Euler for the vdP oscillator, here the full rhs of vdP
240-
* is computed.
212+
* Evaluate the implicit part of the right hand side.
241213
*/
242214
void f_impl_eval(shared_ptr<encap_type> f_encap,
243215
shared_ptr<encap_type> q_encap, time t) override

0 commit comments

Comments
 (0)