Let $\mathcal{L}$ be a second-order, linear, elliptic differential operator acting on $\mathcal{C}^2([0,\infty)^2)$.
I'm numerically solving the inhomogeneous PDE \begin{align*} \mathcal{L}u(x,y)+(x-1)^+=0, \end{align*} where $(\cdot)^+$ denotes the positive part.
Approximating all partial derivatives by central differences, I get the FD scheme \begin{align*} c_1 u_{i-1,j-1} + c_2 u_{i,j-1} + c_3 u_{i+1,j-1} + c_4 u_{i-1,j} + c_5 u_{i,j} &\\ + c_6 u_{i+1,j}+ c_7 u_{i-1,j+1} + c_8 u_{i,j+1} + c_9 u_{i+1,j+1} + (x_i-1)^+ &=0. \end{align*}
Problem
Plotting the solution $u$, it all looks fine and perfect. However, a plot of $\frac{\partial u}{\partial x}$ as a function of $x$ shows that there's a small kink at $x=1$. The above FD scheme seems to work fine with value-matching (the solution $u$ looks appears perfectly continuous) but struggles with smooth-pasting at $x=1$ (the derivative is not smooth).
Question
How do I ensure smooth-pasting with a finite difference scheme at $x=1$?
Some of my failed attempts include
- Impose that forward and backward differences at $x=1$ equal each other (= 2nd order central difference is zero).
- Use higher order approximations around $x=1$ such as $u_{xx}\approx \frac{-u(-2h)+16u(-h)-30u(0)+16u(h)-u(2h)}{12h^2}$ and $u_{x}\approx \frac{u(-2h)-8u(-h)+8u(h)-u(2h)}{12h}$ and central differences everywhere else.
- Approximating partial derivatives using points only from one side of $x=1$ (i.e. only using either $u(0), u(h), u(2h)$ or instead $u(0),u(-h),u(-2h)$).
Note: This problem arises as part of a larger system of free boundary problems. Thus, it's necessary to solve the PDE numerically.