def create_DMPlex_from_box(minX, maxX, minY, maxY, resX, resY, refinement=None
    ):
    """
    Create a box and fill with triangles up to a specified refinement
    - This only works if PETSc was configured with triangle
    """
    from petsc4py import PETSc
    nx = int((maxX - minX) / resX)
    ny = int((maxY - minY) / resY)
    dm = PETSc.DMPlex().create()
    dm.setDimension(1)
    boundary = dm.createSquareBoundary([minX, minY], [maxX, maxY], [nx, ny])
    dm.generate(boundary, name='triangle')
    if refinement:
        dm.setRefinementLimit(refinement)
        dm = dm.refine()
    dm.markBoundaryFaces('boundary')
    pStart, pEnd = dm.getChart()
    origSect = dm.createSection(1, [1, 0, 0])
    origSect.setFieldName(0, 'points')
    origSect.setUp()
    dm.setDefaultSection(origSect)
    origVec = dm.createGlobalVec()
    if PETSc.COMM_WORLD.size > 1:
        sf = dm.distribute(overlap=1)
        newSect, newVec = dm.distributeField(sf, origSect, origVec)
        dm.setDefaultSection(newSect)
    dm.stratify()
    return dm
