I have encountered an interesting PDE, where $f\in C^1_0(\mathbb{R})$: $$ \partial_x u(x, t) + \partial_t u(x, t) = -f+u(x, t)\int_{\mathbb{R}}f(s)\chi_{\lbrace y: u(y, t) \geq f(y) \rbrace}(s)~\mathrm{d}s, \quad x, t \in \mathbb{R} $$ Solving this analytically is rather hard, so I just tried to discretize it.
I calculated $\frac{\mathrm{d}}{\mathrm{d}t} u(y+t, t)$ for fixed $y$ which gives me an ugly ODE with some delay...
Does anyone have a better idea on how to solve this on a computer? Any domain $[a, b] \times [c, d]$ would be fine for me.
The left hand side is an advection operator, so I guess a simple explicit upwind scheme would work. It also needs some boundary condition at $x = a$ and initial conditions at $t = t_0$.
$$ \frac{u^n_j - u^n_{j-1}}{\Delta x} + \frac{u^{n+1}_j - u^n_j}{\Delta t} = -f_j + u^n_j I^n, \quad j = 1, \dots, M, \quad n = 0, \dots, N-1\\ u^0_j = u_0(x_j)\\ u^{n+1}_0 = b(t_{n+1}) $$
Let's approximate the integral with a trapezoidal rule: $$ I^n = \Delta x\sum_{j=1}^M \frac{f^n_{j-1} [u^n_{j-1} > f_{j-1}] + f^n_j [u^n_j > f_j]}{2} $$
For stability you need $C = \frac{\Delta t}{\Delta x} < 1$ (CFL condition) and $\Delta t < -\frac{2}{I^n}$ (if $I_n$ becomes negative)
Here's a quick and dirty implementation of the scheme in Python https://gist.github.com/uranix/82e88262135088d8a66e9f6a8c684ea5