In finite element calculations, for example with $$$\vec{g} = -k(x) \nabla u$$$, the divergence theorem implies: $$$$-\int_{\Omega} \psi \left( \nabla \cdot k(x) \nabla u \right) \;\text{d}x = \int_{\Omega} \nabla\psi \cdot k(x) \nabla u \;\text{d}x - \int_{\partial\Omega} \psi\left(k(x) \nabla u \cdot \hat{n} \right) \; \text{d}s$$$$
We often use the following inner product notation to represent integrals since it is more compact: $$$$-\left( \psi, \nabla \cdot k(x)\nabla u \right) = \left( \nabla\psi, k(x)\nabla u \right) - \langle \psi, k(x)\nabla u \cdot \hat{n} \rangle$$$$
Rearrange to get zero on the right-hand side: $$$$- \nabla\cdot k\nabla u + \vec{\beta} \cdot \nabla u - f = 0 \phantom{\displaystyle \int}$$$$
Multiply by the test function $$$\psi$$$: $$$$- \psi \left(\nabla\cdot k\nabla u\right) + \psi\left(\vec{\beta} \cdot \nabla u\right) - \psi f = 0 \phantom{\displaystyle \int}$$$$
Integrate over the domain $$$\Omega$$$: $$$${- \displaystyle\int_\Omega\psi \left(\nabla\cdot k\nabla u\right)} + \displaystyle\int_\Omega\psi\left(\vec{\beta} \cdot \nabla u\right) - \displaystyle\int_\Omega\psi f = 0 \phantom{\displaystyle \int}$$$$
Apply the divergence theorem to the diffusion term: $$$$\displaystyle\int_\Omega\nabla\psi\cdot k\nabla u - \displaystyle\int_{\partial\Omega} \psi \left(k\nabla u \cdot \hat{n}\right) + \displaystyle\int_\Omega\psi\left(\vec{\beta} \cdot \nabla u\right) - \displaystyle\int_\Omega\psi f = 0$$$$
Write in inner product notation. Each term of the equation will inherit from an existing MOOSE type as shown below. $$$$\underbrace{\left(\nabla\psi, k\nabla u \right)}_{Kernel} - \underbrace{\langle\psi, k\nabla u\cdot \hat{n} \rangle}_{BoundaryCondition} + \underbrace{\left(\psi, \vec{\beta} \cdot \nabla u\right)}_{Kernel} - \underbrace{\left(\psi, f\right)}_{Kernel} = 0 \phantom{\displaystyle \int}$$$$