GEIM
Prerequisite: EIM
The Generalized Empirical Interpolation Method (GEIM) extends the EIM by replacing the selection of magic points $(x_n)_{n=1,\dots,M}$ with the choice of linear functionals $(\sigma_n)_{n=1,\dots,M}.$
This makes it possible to use locally weighted averages over the magic points like sensor functions.
Of course, one can see the EIM as a particular case of GEIM where the functionnals $\sigma_n$ are Dirac measures. The interpolation matrix $Q$ is defined by $Q_{ij}=\sigma_i(q_j)=q_j(x_i)$ and the right hand side $G$ is given by $G_i(\mu)=\sigma_i(g(\cdot;\mu))=g(x_i;\mu)$.
In GEIM, the approximation stays the same $g_M(x;mu)= \sum_{j=1}^M \ \alpha_j(\mu) q_j(x),$ but the interpolation conditions that are imposed become
$$ \begin{equation} \boxed{x_1,\dots,x_M\in\Omega:\quad \sigma_n(g(\cdot;\mu)) = \sigma_n(\mathcal{I}_M[g](\cdot;\mu)),\quad n=1,\dots,M.} \end{equation} $$The functionals $(\sigma_n)_{n=1,\dots,M}$ can be any linear functionals, for instance gaussian sensors
$$\sigma_n(v)=\int_{\Omega} l_n(x) \ v(x) \ dx,$$with $l_n(x)=C_n \mathrm{exp} \left( -\frac{\|x-x_n\|^2}{2r_w^2}\right).$
The interpolation matrix $Q$ is defined by $Q_{ij}=\sigma_i(q_j)$ and the right hand side $G$ is given by $G_i(\mu)=\sigma_i(g(\cdot;\mu))$. Then we solve $Q \alpha(\mu) = G(\mu)$.
In the notebook we use P0 elements, and in that case $g_h$ is constant on each element. Thus, $\sigma_n(g_h)=\sum_K g_K \int_K l_n(x) \ dx$ and we can approximate $\int_K l_n(x) \ dx$ by $|K| l_n(x_K)$. The continuous sensor becomes a discretized vector of weights, with $w_K^{(n)}=|K| l_n(x_K)$ and $\sigma_n(g_h)\simeq \sum_K w_K^{(n)} g_K$.