MoL: How to enforce Chebyshev–Gauss–Lobatto points in SpatialDiscretization?
I'm afraid you've misunderstood the document. The document actually means, when DifferenceOrder->"Pseudospectral"
is chosen for non-periodic b.c., Chebyshev–Gauss–Lobatto (CGL) grid will be automatically used so that Runge's phenomena won't be extreme. This can be verified by
points = 35;
usol = NDSolveValue[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, u[t, 0] == Sin[t],
u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> points,
"MinPoints" -> points, "DifferenceOrder" -> "Pseudospectral"}}];
xcoord = usol["Coordinates"][[2]];
CGLGrid[x0_, L_, n_Integer /; n > 1] := x0 + 1/2 L (1 - Cos[Pi Range[0, n - 1]/(n - 1)])
cgrid = CGLGrid[0, 5., points];
xcoord == cgrid
(* True *)
Still, you can use CGL grid for other difference order as shown in user21's answer, but I doubt if CGL grid helps in those cases. (If CGL grid is really a catholicon, why isn't it the default setting of NDSolve
? )
If you read the linked tutorial to the end you will find the following code:
mygrid = Join[-5. + 10 Range[0, 48]/80, 1. + Range[1, 4 70]/70];
ν = 0.01;
bsolg = First[
NDSolve[{D[u[x, t], t] == ν D[u[x, t], x, x] -
u[x, t] D[u[x, t], x], u[x, 0] == E^-x^2, u[-5, t] == u[5, t]},
u, {x, -5, 5}, {t, 0, 4},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"Coordinates" -> {mygrid}}}]]