danfortunato / ultraSEM

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

ultraSEM with a single leaf domain #8

Closed ajt60gaibb closed 5 years ago

ajt60gaibb commented 5 years ago

When ultraSEM is given a single leaf domain, I was expecting it to just return the solution. Instead, I get warnings and it doesn't work:

D = ultraSEMDomain.rectangle([0 0 1 1]); 
op = ultraSEMPDO(1, 0, 0);
rhs = -1;                            
bc = 0;                              
L = ultraSEM(D, op, rhs);           
sol = L \ bc;                        
plot(sol)
> In ultraSEMLeaf.initialize>schurSolve (line 510)
  In ultraSEMLeaf.initialize>buildSolOp (line 288)
  In ultraSEMLeaf.initialize (line 103)
  In ultraSEM/initialize (line 151)
  In ultraSEM (line 100) 
Warning: Matrix is singular, close to
singular or badly scaled. Results may
be inaccurate. RCOND = NaN. 
> In ultraSEMLeaf.initialize>schurSolve (line 515)
  In ultraSEMLeaf.initialize>buildSolOp (line 288)
  In ultraSEMLeaf.initialize (line 103)
  In ultraSEM/initialize (line 151)
  In ultraSEM (line 100) 
Warning: Matrix is singular, close to
singular or badly scaled. Results may
be inaccurate. RCOND = NaN. 
danfortunato commented 5 years ago

That's because the rectangle you specified is degenerate. I think you meant ultraSEM.rectangle([0 1 0 1])?

ajt60gaibb commented 5 years ago

OK. I guess I need help text then. I assumed it worked like rectangle in MATLAB:

>> help rectangle
 rectangle Create rectangle, rounded-rectangle, or ellipse
    rectangle adds a default rectangle to the current axes.

    rectangle('Position',pos) creates a rectangle in 2-D coordinates.
    Specify pos as a four-element vector of the form [x y w h] in data
    units. The x and y elements determine the location and the w and h
    elements determine the size. The function plots into the current axes
    without clearing existing content from the axes.
danfortunato commented 5 years ago

It follows the chebfun2 convention:

>> help ultraSEM.rectangle
 rectangle   Construct a rectangular ultraSEMDomain.
    ultraSEM.rectangle([A B C D]) returns a rectangluar
    ultraSEMDomain with vertices (A,C), (A,D), (B,D), (B,C) with a
    single patch.

    ultraSEM.rectangle([A B C D], M, N) returns the same rectangle,
    but subdivided into an MxN grid of equally sized patches.
    Similarly, ultraSEM.rectangle([A B C D], M) assumes N = M.
danfortunato commented 5 years ago

I've added an error for degenerate rectangles in 70992a7af2b61a014fe9defab440f2b704972c40.