Consider, for concreteness, the finite element (FE) method applied to stationary heat conduction in a domain $\Omega \subset \mathbb{R}^3$. Let the heat flux (thermal energy per unit area and time) be denoted by $\mathbf{q}$, and let the source term (applied thermal energy per unit volume and time) be denoted by $Q$. The strong form of the equation is simply given by the balance law $$1) \nabla \cdot \mathbf{q}=Q.$$ Suppose that we prescribe Neumann conditions on the whole boundary, i.e. $\mathbf{q}\cdot \mathbf{n} = g$ on $\partial \Omega$, where $\mathbf{n}$ denotes the outward unit normal, and $g$ denotes some function defined on $\Omega$. Integrating the conservation law 1) over $\Omega$ and using Gauss' theorem along with the boundary conditions, shows that $g$ and $Q$ must be related according to $$2)\int_\Omega QdV =\int_{\partial \Omega}gdA.$$ Consider now the FE formulation of 1). Let's assume a constitutive relation $\mathbf{q} = -\mathbf{D}\nabla T$, where $\mathbf{D}$ denotes the constitutive matrix and $T$ the temperature field. Let $\mathbf{N} = [N_1 \ ... \ N_n]$ denote the global shapefunction vector. The FE formulation then takes the form $$3)\mathbf{K}\mathbf{a}=\mathbf{f}_b+\mathbf{f}_l=\mathbf{f},$$ where $\mathbf{K}$ is the stiffness matrix given by $$4)\mathbf{K} = \int_{\Omega}(\nabla \mathbf{N})^T\mathbf{D}(\nabla \mathbf{N})dV$$ and we have the boundary force vector $\mathbf{f}_b$ and the load force vector $\mathbf{f}_l$, given by $$5)\mathbf{f}_b = -\int_{\partial \Omega}\mathbf{N}^TgdA $$ and $$6)\mathbf{f}_l = \int_{\Omega}\mathbf{N}^TQdV, $$ respectively.
Question 1
My first question, which was not really addressed in the book I'm using, concerns how the integrals in 4), 5) and 6) are actually defined. The shape functions are of course only defined on the elements in the FE mesh, whose domain we can call $M$. If our elements have straight boundaries but $\Omega$ does not have a straight boundary, then $M \neq \Omega$ and $\partial M \neq \partial \Omega$. Therefore, the integrals in 4), 5) and 6) should really be written as $$4')\mathbf{K} = \int_{M}(\nabla \mathbf{N})^T\mathbf{D}(\nabla \mathbf{N})dV,$$ $$5')\mathbf{f}_b = -\int_{\partial M}\mathbf{N}^TgdA $$ and $$6')\mathbf{f}_l = \int_{M}\mathbf{N}^TQdV, $$ respectively. However, then another issue appears. While the integrals in 4') and 6') are well-defined, since $M \subset \Omega$ and $Q$ is defined on $\Omega$, the integral in 5') is not well-defined a-priori, since $\partial M \not\subset \partial \Omega$ while $g$ is defined on $\partial \Omega$. Say for example that $\Omega$ is the quarter ball $\Omega = \{(x,y,z)|x^2+y^2+z^2 \leq 1, x,y,z, \geq 0\}$ and that we use a single element in the form of a tetrahedron, so that $M$ is the tetrahedron with vertices $(0,0,0),(1,0,0),(0,1,0)$ and $(0,0,1)$. Then the "spherical part" $(\partial\Omega)_s =\{(x,y,z)|x^2+y^2+z^2=1\}\cap \partial \Omega$ of $\partial\Omega$ does not coincide with the corresponding face $(\partial M)_s = \{(x,y,z)|x+y+z=1\}\cap \partial M$ of $\partial M$. If $g$ is constant, it probably makes sense to define $\mathbf{f}_b$ as $$5'')\mathbf{f}_b = -g\int_{\partial M}\mathbf{N}^TdA \ (\mathrm{for} \ g \ \mathrm{constant}).$$ However, say that we have defined $g$ on $(\partial \Omega)_s$ by $g|_{(\partial \Omega)_s} = \sqrt{x^2+y^2+z^2-0.9}$, which is well defined. However, we cannot just use the same "formula" $g(x,y,z) = \sqrt{x^2+y^2+z^2-0.9}$ when integrating over $(\partial M)_s$ since e.g. at the point $(1/3,1/3,1/3)$ the argument of the square root becomes negative. In this case, how should one then actually define the integral $-\int_{(\partial M)_s}\mathbf{N}^TgdA$?
Question 2
My second question concerns conservation laws in the FE method, and connects to the issues raised in the first question. In the book that I am using, the authors claim that the FE method exactly reproduces the conservation law in 1). They note that the shape functions satisfy the identity $$7) \sum_{i=1}^n N_i = 1.$$ If we define a total force vector $\mathbf{f}$ by $\mathbf{f}=\mathbf{f}_b+\mathbf{f}_l$ and use equation 7), then from 2), 5) and 6) we obtain $$8)\sum_{i=1}^n f_i = 0. $$
However, as we discussed above, we cannot actually use 5) and 6) to calculate $\mathbf{f}_b$ and $\mathbf{f}_l$, but we must rather use 5') and 6'). Doing so, the relation 8) will of course no longer hold. I argued this point in a course I took based on the aforementioned book, and the reply I got (unless I misunderstood it) was that the FE method does indeed exactly implement the conservation law 1). However, based on the arguments just presented, I don't see how that can be the case.
Thus, my question is whether the FE method does indeed correctly implement the conservation law 1), and if so, how?