2
2
// Licensed under the GNU LGPL Version 2.1.
4
4
// First added: 2006-12-05
5
// Last changed: 2008-12-18
5
// Last changed: 2009-10-05
7
7
// This demo program solves Poisson's equation,
22
22
#include <dolfin.h>
23
23
#include "Poisson.h"
24
#include "P1Projection.h"
26
25
using namespace dolfin;
31
class Source : public Function
30
class Source : public Expression
34
Source() : Expression(2) {}
33
36
void eval(double* values, const double* x) const
35
38
double dx = x[0] - 0.5;
36
39
double dy = x[1] - 0.5;
37
40
values[0] = 500.0*exp(-(dx*dx + dy*dy)/0.02);
42
46
UnitSquare mesh(24, 24);
44
dolfin_set("linear algebra backend", "uBLAS");
49
parameters["linear_algebra_backend"] = "uBLAS";
46
51
// Create functions
51
55
// Create funtion space
52
PoissonFunctionSpace V(mesh);
56
Poisson::FunctionSpace V(mesh);
54
58
// Define forms and attach functions
55
PoissonBilinearForm a(V, V);
56
PoissonLinearForm L(V);
57
a.n = n; a.h = h; L.f = f;
60
VariationalProblem pde(a, L);
61
pde.set("symmetric", true);
67
// Plot solution projected
59
Poisson::BilinearForm a(V, V);
60
Poisson::LinearForm L(V);
63
// Create variational problem
64
VariationalProblem problem(a, L);
65
//problem.parameters["symmetric"] = true;
67
// Solve variational problem
70
74
// Save solution in VTK format