Right now PeriodicBC assumes that the end-points of a discretization do not overlap under periodicity. To make this work, the user must be aware of this assumption and ensure that their discretization is at cell centers instead of cell boundaries.
This can get awkward. For example, if f has period 1, then you want f(0) = f(1). If you were to discretize on the unit interval, you would likely make a grid of the form x = 0:dx:1 with end-points included.
PeriodicBC assumes that the left-neighbor of x[1] is x[end]
|
Base.:*(Q::PeriodicBC, u::AbstractVector) = BoundaryPaddedVector(u[end], u[1], u) |
This is not consistent with our choice of discretization above, since x[1] and x[end] are actually the same points (under periodicity).
We could get around this by making the grid x = dx/2:dx:(1-dx/2) but this is a little awkward, and it is (I assume) not consistent with other types of boundary conditions that require the grid point to actually lie on the boundary.
We could overcome this by simply requiring PeriodicBC to use the 2nd and end-1 th points, but perhaps there are more elegant solutions.