The starting point for the development of this equation is an energy balance on a fixed control volume of fluid:
$$\int{\frac{\partial E}{\partial t}dV}=-\int{E(\vec{v}\cdot \vec{n})dA}+\int{(\vec{v}\cdot \vec{\sigma} \cdot \vec{n})dA}-\int{\vec{q}\cdot\vec{n}}dA$$
where dV is differential volume, dA is differential surface of the control volume, and $\vec{n}$ is a unit outwardly directed normal from the control volume at its surface. The term on the left hand side represents the rate of change of energy within the control volume. The first integral on the right hand side represents the net rate at which energy is leaving the control volume by by flow into and out of the control volume. The second integral on the right hand side represents the rate at which the surroundings are doing work on the material on the control volume. The third integral on the right hand side represents the rate at which heat is leaving the control volume. If we apply the divergence theorem to the area integrals on the right hand side, we obtain:
$$\int{\left(\frac{\partial E}{\partial t}+\nabla \cdot(E\vec{v})\right)dV}=\int{(\nabla \cdot{(\vec{\sigma}\cdot \vec{v})}-\nabla \cdot \vec{q})}dV$$
This then yields:$$\frac{\partial E}{\partial t}+\nabla \cdot(E\vec{v})=\nabla \cdot{(\vec{\sigma}\cdot \vec{v})}-\nabla \cdot \vec{q}\tag{1}$$
Eqn. 1 is identical to the relationship given in Transport Phenomena by Bird, Stewart, and Lightfoot, with$$E=\rho (u+\frac{v^2}{2}+\phi)$$where $\rho$ is the fluid density, u is the internal energy per unit mass, v is the magnitude of the velocity, and $\phi$ is the gravitational potential.
For an incompressible fluid, the left hand side reduces to:$$\frac{\partial E}{\partial t}+\nabla \cdot(E\vec{v})=\frac{\partial E}{\partial t}+\vec{v}\cdot \nabla E=\frac{DE}{Dt}$$
ALTERNATE METHOD:
An alternate method of arriving at these same results is to use a moving control volume (rather than a fixed control volum employed in the development above), which moves and deforms with the fluid, and which contains a fixed mass of fluid. So this system is essentially the closed system encountered is standard thermodynamics. The starting equation for this development is:
$$\frac{d}{dt}\left[\int{EdV}\right]=\dot{Q}-\dot{W}\tag{2}$$
where the left hand side is the rate of change of energy within the moving volume of fluid (system), $\dot{Q}$ is the rate of addition of heat to the system and $\dot{W}$ is the rate at which the system is doing work on the surroundings:
$$\dot{Q}=-\int{\vec{q}\cdot\vec{n}}dA$$
$$\dot{W}=-\int{(\vec{v}\cdot \vec{\sigma} \cdot \vec{n})dA}$$
If we apply the Reynolds Transport Theorem (i.e., the 3D generalization of the Leibnitz rule for differentiation under the integral sign) to the left hand side of Eqn. 2, we obtain:
$$\frac{d}{dt}\left[\int{EdV}\right]=\int{\frac{\partial E}{\partial t}dV}+\int{E(\vec{v}\cdot \vec{n})dA}$$
The remainder of the development is the same as above.