Neumann BCs in Chebychev and ultraspherical bases #587
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Boundary conditions in these bases are implemented by evaluating the Chebychev T polynomials in the boundary condition. For instance, the boundary condition$u(x=x_b)=v$ with $N$ degrees of freedom is implemented by evaluating all $T_n, 0\leq n<N$ at $x=x_b$ , putting the values in one line of the system matrix and putting $v$ in the corresponding spot in the right hand side vector. For special values, this is simple. For instance, $T_n(x=1)=1$ , i.e. we would need to add a line of all ones to the system matrix.$v$ .
Perhaps a better way of understanding this is that you can compute the value on the boundary in physical space by extrapolating from the coefficients in frequency space by a weighted sum of these coefficients. Putting this in the system matrix reverses this process from What is the value at the boundary? to The value at the boundary is
Neumann BCs are like$\partial_x u(x=x_b)=v$ . Here, we need the derivative of the $T_n$ . Looking on Wikipedia, we find that $\partial_x T_n(x) = n U_{n-1}(x)$ and $U_n(x=1) = n+1$ , therefore $\partial_x T_n(x=1) = n^2$ . A similarly easy version exists for the left boundary $x=-1$ .
This is exactly what is implemented in this PR. The algorithmic structure of Neumann BCs is exactly the same as for Dirichlet BCs in these spectral methods. All we need to change is the lines we put in the system matrix. This PR allows to populate these lines such that Neumann BCs at either end of the boundary result.