1
// Copyright (C) 2002 Anders Logg.
2
// Licensed under the GNU LGPL Version 2.1.
5
// Last changed: 2006-08-22
7
// This demo solves the harmonic oscillator on
8
// the time interval (0, 4*pi) and computes the
9
// error for a set of methods and orders.
13
using namespace dolfin;
15
class Harmonic : public ODE
19
Harmonic() : ODE(2, 4.0 * DOLFIN_PI), e(0.0) {}
21
void u0(uBlasVector& u)
27
void f(const uBlasVector& u, real t, uBlasVector& y)
33
bool update(const uBlasVector& u, real t, bool end)
40
e = std::max(std::abs(e0), std::abs(e1));
58
dolfin_set("ODE fixed time step", true);
59
dolfin_set("ODE discrete tolerance", 1e-14);
61
for (int q = 1; q <= 5; q++)
63
dolfin_set("output destination", "silent");
64
dolfin_set("ODE method", "cg");
65
dolfin_set("ODE order", q);
69
dolfin_set("output destination", "terminal");
71
message("cG(%d): e = %.3e", q, ode.error());
76
for (int q = 0; q <= 5; q++)
78
dolfin_set("output destination", "silent");
79
dolfin_set("ODE method", "dg");
80
dolfin_set("ODE order", q);
84
dolfin_set("output destination", "terminal");
86
message("dG(%d): e = %.3e", q, ode.error());