Arguments for Rectangle and RectangleMesh are inconsistent

Issue #299 resolved
Patrick Farrell created an issue

RectangleMesh takes in

RectangleMesh(double x0, double y0, double x1, double y1, ..)

Rectangle takes in

Rectangle(double x0, double x1, double y0, double y1)

Why?

Comments (17)

  1. Anders Logg (Chalmers)

    I don't know why, but think the first one is more natural (specifying two corners that span the triangle).

  2. Patrick Farrell reporter

    After reading it again, I think that is what the Rectangle constructor takes, just labelled very strangely:

        /// Create rectangle defined by two opposite corners
        /// x = (x0, x1) and y = (y0, y1).
        ///
        /// *Arguments*
        ///     x0 (double)
        ///         x0-coordinate of first corner.
        ///     x1 (double)
        ///         x1-coordinate of first corner.
        ///     y0 (double)
        ///         y0-coordinate of second corner.
        ///     y1 (double)
        ///         y1-coordinate of second corner.
        Rectangle(double x0, double x1, double y0, double y1);                                                                                                                                                          
    

    When I saw (x0, x1, y0, y1), I thought {x,y} referred to the coordinate axis and {0,1} referred to the vertex. But the Rectangle constructor means it the other way around -- {x,y} refers to the vertex, and {0,1} to the coordinate axis!

  3. Prof Garth Wells

    I suggested in the past that using tuples would be clearer:

    mesh = RectangleMesh((x0, y0), (x1, y1))
    
  4. Prof Garth Wells

    @logg Doing

    RectangleMesh mesh(Point(0.0, 0.0), Point(2.0, 1.0));
    

    looks pretty tidy to me.

  5. Prof Garth Wells

    It's not a scalable solution. The actual interface is RectangleMesh(x0, y0, x1, y1, n0, n1), and in 3D it's BoxMesh(x0, y0, z0, x1, y1, z1, n0, n1, n2). There is plenty of scope for user error.

  6. Anders Logg (Chalmers)

    Update: the new version of Rectangle in mshr now has this interface:

    Rectangle::Rectangle(dolfin::Point a, dolfin::Point b)
    

    We should do the same in DOLFIN for RectangleMesh.

  7. Anders Logg (Chalmers)

    Should be fixed now. Both RectangleMesh and BoxMesh now require Point, but IntervalMesh does not (would be consistent but a bit silly).

  8. Log in to comment