Poisson's equation with Robin boundary conditions:
−Δu=f in $\Omega=]0,a[\times]0;b[ $
$\alpha u$+$\frac{∂u}{∂n}$=g $in \; \Gamma$.
for a given f$\in L^2(\Omega)$,g$\in L^2(\Gamma)$,$\alpha \in L^\infty(\Gamma), \alpha(x,y)\ge 0$
the existence and uniqueness are guaranteed by Lax Milgram lemma.
my purpose is to approximate this problem with finite element method $\mathbb{P}_1$.
the variational approximation of elliptic problems
\begin{equation*} \left\{\begin{array}{cc} find \ u=(u_1,....,u_N)^{t} \in {R}^N & such \;that \\ \displaystyle \sum_{i=1}^{i=N} u_i \displaystyle[ \int_{\Omega} \nabla\varphi_{i} \nabla\varphi_{j} dx+ \displaystyle \int_{\Gamma} \alpha \varphi_{i}\varphi_{j} d\sigma] =\displaystyle \int_{\Omega} f \varphi_{j} dx + \int_{\Gamma}g \varphi_{j} d\sigma &for \; j=1,...,N \end{array} \right. \end{equation*} we pose
$$\mathbb M_{ij}= \displaystyle \int_{\Omega} \nabla\varphi_{i} \nabla\varphi_{j} dx =\displaystyle \sum_{K \in\mathcal T_h} \int_{K} \nabla\varphi_{i} \nabla\varphi_{j} dx $$ $$\mathbb R_{ij}= \displaystyle \int_{\Gamma} \alpha \varphi_{i}\varphi_{j} d\sigma= \displaystyle \sum_{K \in\mathcal T_h} \int_{K\cap \Gamma} \alpha \varphi_{i}\varphi_{j} d\sigma$$ $$\mathbb B_{j}= \displaystyle \int_{\Omega} f \varphi_{j} dx=\displaystyle \sum_{K \in\mathcal T_h} \int_{K} f \varphi_{j} dx $$ $$\mathbb G_{j}=\displaystyle \int_{\Gamma}g \varphi_{j} d\sigma =\displaystyle \sum_{K \in\mathcal T_h} \int_{K\cap \Gamma} g \varphi_{j} d\sigma $$ So, we should solve $$\mathbb A \mathbb U=\mathbb F$$ with $$\mathbb U=(u_1,....,u_N)^{t} \in{R}^N $$ $$ \mathbb A =\mathbb M + \mathbb R$$ $$ \mathbb F =\mathbb B + \mathbb G$$
I have problem to calculate $\displaystyle \int_{K\cap \Gamma} \alpha \varphi_{i}\varphi_{j} d\sigma$
where $\varphi_{i} $ basis functions or barycentric coordinates
$\mathcal T_h $general triangulations and K is a triangle
Map the integral to a reference face and integrate there.
More precisely, let $F_E:\mathbb{R} \rightarrow \mathbb{R}^2$ be a mapping from the reference face $\hat{E}$ to the global face $E$. One possible reference face $\hat{E}$ is the interval $[0,1]$. Mapping would be $$F_E(\hat{x})=b_E\hat{x}+c_E,$$ where $$b_E=x_E^2-x_E^1\in \mathbb{R}^{2}, \quad b = x_E^1 \in \mathbb{R}^2,$$ and $x_E^j \in \mathbb{R}^2, j \in \{1,2\},$ are the vertices of the edge $E$. Basis functions on the reference face are $$\hat{\phi}_1(\hat{x})=1-\hat{x}, \quad \hat{\phi}_2(\hat{x})=\hat{x}.$$ Then by the definition of a path integral $$\begin{align*}\int_E \alpha \phi_i \phi_j \,\mathrm{d}s &= \int_0^1 \alpha(F_E(\hat{x})) \phi_i(F_E(\hat{x})) \phi_j(F_E(\hat{x})) |F_E'(\hat{x})|\,\mathrm{d}\hat{x}\\ &=\int_0^1\alpha(F_E(\hat{x})) \hat{\phi}_{I(E,i)}(\hat{x}) \hat{\phi}_{J(E,j)}(\hat{x})|b_E|\,\mathrm{d}\hat{x},\end{align*}$$ where $I(E,i)$ (or $J(E,j)$) is the local index corresponding to global index $i$ (or $j$) on edge $E$. Pick any numerical integration rule to integrate this integral. If $\alpha$ is constant you can even do it analytically.
Remark. In a proper implementation, instead of $I(E,i)$ you have its inverse. Thus, for each edge you would evaluate once $$\int_0^1\alpha(F_E(\hat{x})) \hat{\phi}_{1}(\hat{x}) \hat{\phi}_{1}(\hat{x})|b_E|\,\mathrm{d}\hat{x},$$ $$\int_0^1\alpha(F_E(\hat{x})) \hat{\phi}_{1}(\hat{x}) \hat{\phi}_{2}(\hat{x})|b_E|\,\mathrm{d}\hat{x},$$ and $$\int_0^1\alpha(F_E(\hat{x})) \hat{\phi}_{2}(\hat{x}) \hat{\phi}_{2}(\hat{x})|b_E|\,\mathrm{d}\hat{x}.$$ Then $$\int_E \alpha \phi_{i(E,I)} \phi_{j(E,J)} \,\mathrm{d}s = \int_0^1\alpha(F_E(\hat{x})) \hat{\phi}_{I}(\hat{x}) \hat{\phi}_{J}(\hat{x})|b_E|\,\mathrm{d}\hat{x}$$ for every $I,J\in\{1,2\}$.