Galerkin method + FEM - clarification for Poisson equation with mixed boundary conditions I will be refering to this link, but I am interested in slightly easier equation:
$$
-\Delta c = f, \quad (x, y) \in \Omega
$$
with the following (mixed) boundary condition:
$$
\begin{aligned}
1. & \; c = g_1, \quad (x, y) \in \Gamma_1 \\
2. & \; \frac{\partial c}{\partial n} = g_2, \quad (x, y) \in \Gamma_2 \\
3. & \; \sigma c + \frac{\partial c}{\partial n} = g_3, \quad (x, y) \in \Gamma_3
\end{aligned} \quad \quad \Gamma = \Gamma_1 \, \cup \; \Gamma_2 \, \cup \; \Gamma_3
$$
To my understanding the derivation goes like this:
First, we multiply both sides of the equation by some test function $v$ and integrate over $\Omega$
$$
\int \limits_\Omega \left( -\Delta c \right) v \, \mathrm{d} \Omega = \int \limits_\Omega f v \, \mathrm{d} \Omega
$$
Then we use per partes + Gauss thm to obtain
$$
\int \limits_\Omega \left( \vec{\nabla} c \right) \cdot \left( \vec{\nabla} v \right) \, \mathrm{d} \Omega - \int \limits_\Gamma \frac{\partial c}{\partial n} v \: \mathrm{d} \Gamma = \int \limits_\Omega f v \, \mathrm{d} \Omega
$$
Now we divide integral over $\Gamma$ to three parts
$$
\int \limits_\Omega \left( \vec{\nabla} c \right) \cdot \left( \vec{\nabla} v \right) \, \mathrm{d} \Omega - \int \limits_{\Gamma_1} \frac{\partial c}{\partial n} v \: \mathrm{d} \Gamma - \int \limits_{\Gamma_2} \frac{\partial c}{\partial n} v \: \mathrm{d} \Gamma - \int \limits_{\Gamma_3} \frac{\partial c}{\partial n} v \: \mathrm{d} \Gamma = \int \limits_\Omega f v \, \mathrm{d} \Omega
$$
The first integral over $\Gamma_1$ obtains $c$ with essential BC, so we require $v = 0$ on $\Gamma_1$ and this integral will drop out. In the second one, Neumann BC can be directly substituted from (2.) and in the third one, Robin BC can be substituted from (3.):
$$
\int \limits_\Omega \left( \vec{\nabla} c \right) \cdot \left( \vec{\nabla} v \right) \, \mathrm{d} \Omega - \int \limits_{\Gamma_2} g_2 v \: \mathrm{d} \Gamma - \int \limits_{\Gamma_3} ( g_3 - \sigma c ) \, v \: \mathrm{d} \Gamma = \int \limits_\Omega f v \, \mathrm{d} \Omega
$$
This is just cosmetic; we separate terms with $c$ and without $c$
$$
\int \limits_\Omega \left( \vec{\nabla} c \right) \cdot \left( \vec{\nabla} v \right) \, \mathrm{d} \Omega + \int \limits_{\Gamma_3} \sigma c \, v \: \mathrm{d} \Gamma = \int \limits_\Omega f v \, \mathrm{d} \Omega + \int \limits_{\Gamma_2} g_2 v \: \mathrm{d} \Gamma + \int \limits_{\Gamma_3} g_3 v \: \mathrm{d} \Gamma
$$
Now we expand the solution $c$ to piecewise (linear, quadratic, ...) basis functions:
$$
c(x,y) = \sum_i c_i \lambda_i (x, y) + c_0 (x, y)
$$
$c_0$ is there to satisfy the essential (Dirichlet) BC:
$$
\begin{aligned}
1. & \; c0 = g_1, \quad (x, y) \in \Gamma_1 \\
2. & \; \lambda_i = 0, \quad (x, y) \in \Gamma_1
\end{aligned}
$$
To work out coefficients $c_i$ we take $v = \lambda_i$ (test functions are basis functions themselves):
$$
\int \limits_\Omega \left( \vec{\nabla} \left( \sum_j c_j \lambda_j + c_0\right) \right) \cdot \left( \vec{\nabla} \lambda_i \right) \, \mathrm{d} \Omega + \int \limits_{\Gamma_3} \sigma \left( \sum_j c_j \lambda_j + c_0 \right) \, \lambda_i \: \mathrm{d} \Gamma =\\= \int \limits_\Omega f \lambda_i \, \mathrm{d} \Omega + \int \limits_{\Gamma_2} g_2 \lambda_i \: \mathrm{d} \Gamma + \int \limits_{\Gamma_3} g_3 \lambda_i \: \mathrm{d} \Gamma
$$
$$
\sum_j c_j \left[ \int \limits_\Omega \left( \vec{\nabla} \lambda_j \right) \cdot \left( \vec{\nabla} \lambda_i \right) \, \mathrm{d} \Omega + \int \limits_{\Gamma_3} \sigma \lambda_j \, \lambda_i \: \mathrm{d} \Gamma \right] = \int \limits_\Omega f \, \lambda_i \, \mathrm{d} \Omega + \int \limits_{\Gamma_2} g_2 \, \lambda_i \: \mathrm{d} \Gamma + \int \limits_{\Gamma_3} g_3 \lambda_i \, \mathrm{d} \Gamma - \\- \int \limits_\Omega \left( \vec{\nabla} c_0 \right) \cdot \left( \vec{\nabla} \lambda_i \right) \, \mathrm{d} \Omega - \int \limits_{\Gamma_3} \sigma \, c_0 \, \lambda_i \: \mathrm{d} \Gamma
$$
This is what I arrived on by following the logic. I have several questions about this:


*

*I know the data $g_1$ on $\Gamma_1$, however, this approach requires me to somehow "extend" this data to the whole domain along with its gradient (see the term $\int \limits_\Omega \left( \vec{\nabla} c_0 \right) \cdot \left( \vec{\nabla} \lambda_i \right) \, \mathrm{d} \Omega$ containing $c_0$). How am I supposed to know $c_0$ on whole $\Omega$?

*In the pdf from the beginning (page 12, formula no. 22) there is the term analogous to $\int \limits_\Omega \left( \vec{\nabla} c_0 \right) \cdot \left( \vec{\nabla} \lambda_i \right) \, \mathrm{d} \Omega$, however there is no term with $c_0$ integrated over $\Gamma_3$. Is this just a typo in the pdf, or am I missing something?

*Everyone claims that $\sigma$ in Robin BC is a positive constant. Why can't be $\sigma$ a positive function instead? I see no problem with it being a function, not just a constant - all we have to do is to treat it like every other function ($g_2$, $g_3$) that pops out under these integrals - expand it with basis functions, or if possible, obtain those definite integrals analytically. What am I missing here?

 A: *

*I suspect that the author of the resource you mentioned assumes that the function $g_1(x, y)$ is known in the entire closed domain $\bar\Omega $, but only enforced at the boundary $\Gamma_1$, i.e., $c_0(x, y) \overset{!}{=} g_1(x, y) \text{ on } \Gamma_1$.


*Good question, I could imagine that the definition of $c_0(x, y)$ is somewhat incomplete in the sense that $$ c_0(x, y) = \begin{cases} g_1(x,y ) & \text{on } \Gamma_1 \\
0 & \mathrm{else} \end{cases},$$
but done in a way ensuring that you can still take the derivative $\nabla c_o $ needed for the integrals on the RHS.
I have to say that the way how $c^n$ is constructed is not very classic. Normally, you would see something like $$c^n(x, y) = \sum_i c_i \phi_i(x, y) $$ with basis functions $\phi_i(x, y)$ that are equal to $1$ at the associated node. The dirichlet boundary conditions can then be enforced by setting the coefficient to the function value $g_1(x, y)$ at that node. Possibly the author gives a formulation like that in the document to be able to formulate the problem before already discretizing it into intervals.


*The difficulty lies in showing existence for a function $\sigma$. If you are interested take a look at this or this. In the beginning of this lecture notes, it is casually stated that variable coefficients do not pose a problem, although no more in-depth discussion is given.
