include "test.idp" real t; cout << functionDEFINITION << "poisson" << endl; // parameter func Pk = P2; func f = -2.*x*(y-1.)*(y-2.*x+x*y+2.)*exp(x-y); func uD = 0; func ue = exp(x-y)*x*(1.-x)*y*(1.-y); real eps = 1e-4; int nn = 10; macro grad(A) [dx(A), dy(A)] // border b1(t=0, 1){x=t; y=0; label=1;} border b2(t=0, 1){x=1; y=t; label=2;} border b3(t=0, 1){x=1-t; y=1; label=3;} border b4(t=0, 1){x=0; y=1-t; label=4;} mesh Th = buildmesh(b1(nn) + b2(nn) + b3(nn) + b4(nn)); int[int] Wall = [1, 2, 3, 4]; fespace Uh(Th, Pk); Uh u, uh; Uh uerror; cout << functionDEFINITION << "solve" << endl; { t = clock(); solve Poisson (u, uh) = int2d(Th)( grad(u)' * grad(uh) ) - int2d(Th)( f * uh ) + on(Wall, u=uD) ; t = clock() - t; cout << timeELAPSED << t << endl; uerror = u - ue; test(uerror[].max < eps); } cout << functionDEFINITION << "problem" << endl; { t = clock(); problem Poisson (u, uh) = int2d(Th)( grad(u)' * grad(uh) ) - int2d(Th)( f * uh ) + on(Wall, u=uD) ; Poisson; t = clock() - t; cout << timeELAPSED << t << endl; uerror = u - ue; test(uerror[].max < eps); } cout << typeDEFINITION << "varf" << endl; { t = clock(); varf vPoisson (u, uh) = int2d(Th)( grad(u)' * grad(uh) ) + int2d(Th)( f * uh ) + on(Wall, u=uD) ; t = clock() - t; cout << timeELAPSED << t << endl; matrix Poisson = vPoisson(Uh, Uh, solver=sparsesolver); real[int] PoissonBoundary = vPoisson(0, Uh); cout << functionDEFINITION << "^-1" << endl; t = clock(); u[] = Poisson^-1 * PoissonBoundary; t = clock() - t; cout << timeELAPSED << t << endl; uerror = u - ue; test(uerror[].max < eps); }