4
using namespace dolfin;
8
// Create mesh and forms
9
UnitSquare mesh(128, 128);
10
DomainBoundary boundary;
11
Function g(mesh, 0.0);
12
DirichletBC bc(g, mesh, boundary);
14
Function f(mesh, 2.0);
15
PoissonBilinearForm a;
16
PoissonLinearForm L(f);
21
KrylovSolver solver(bicgstab, ilu);
24
// Assemble and solve using uBLAS
25
cout << "uBLAS ------------------------------------------------------" << endl;
26
Assembler ass_ublas(mesh);
27
uBLASMatrix<ublas_sparse_matrix> A_ublas;
28
uBLASVector b_ublas, x_ublas;
31
ass_ublas.assemble(A_ublas, a);
32
ass_ublas.assemble(b_ublas, L);
33
bc.apply(A_ublas, b_ublas, a);
34
solver.solve(A_ublas, x_ublas, b_ublas);
35
table("uBLAS", "solve") = toc();
40
// Assemble and solve using MTL4
41
printf("MTL4 with specified number of nonzeros----------------------\n");
42
Assembler ass_mtl4(mesh);
43
MTL4Matrix A_mtl4(A_ublas.size(0), A_ublas.size(1), 10);
44
MTL4Vector b_mtl4(A_ublas.size(0)), x_mtl4;
47
ass_mtl4.assemble(A_mtl4, a, false);
48
ass_mtl4.assemble(b_mtl4, L, false);
49
bc.apply(A_mtl4, b_mtl4, a);
50
solver.solve(A_mtl4, x_mtl4, b_mtl4);
51
table("MTL4", "solve") = toc();
55
//u.init(mesh, x_mtl4, a, 1);
56
//File file("test.pvd");