danfortunato / ultraSEM

The ultraspherical spectral element method
MIT License
29 stars 3 forks source link

Bug in ultraSEMSol.feval for quads #21

Closed nickhale closed 5 years ago

nickhale commented 5 years ago

Although the computed coefficients of the solution in the following match to machine precision, the evaluated solutions are very different (presumably with error in the evaluation of the quad version):

p = 60;
rhs = -1;

N = chebop2(@(u) lap(u)); N.bc = 0;
sol = N\rhs;

% Solve using rectangles
R = ultraSEMDomain.rectangle; 
S = ultraSEM(R, {1,0,0}, rhs, p);
sol1 = S\0;
figure
[xx, yy] = getGrid(sol1);
err = abs(feval(sol, xx, yy) - feval(sol1, xx, yy));
surf(xx, yy, log10(err));

% Solve using quads
R2 = ultraSEMDomain.quad([-1 -1; 1 -1 ; 1 1 ; -1 1]);
S = ultraSEM(R2, {1,0,0}, rhs, p);
sol2 = S\0;
figure
[xx, yy] = getGrid(sol1);
err = abs(feval(sol, xx, yy) - feval(sol2, xx, yy));
surf(xx, yy, log10(err));
alignfigs

err_coeffs = norm(sol2.u{1} - sol1.u{1}, inf)

s4

danfortunato commented 5 years ago

Fixed in 00bf7652d114e6820281fda397913b79d0c4dc2c.