I have a question about surface integrals of vector fields.
The formula I was given is the following when the surface is a rectangle of sides $a$ and $b$ in the $xy$ plane and $\vec{u}(r)$ the vector field :
$$\iint_S \vec{u}.d\vec{S}=\int_0^b \int_0^a(\vec{u}\cdot\vec{e_z})dxdy=\int_0^b \int_0^au_zdxdy$$
Now I tried to use with a cube of sides $a$ like this one 
The formula seems to work with the field $\vec{u}(r)=(1,0,0)$ with $$\iint_S \vec{u}.d\vec{S}= \iint_{S_{x,1}} -u_x.dydz + \iint_{S_{x,2}} u_x.dydz = -\int_0^a \int_0^adydz+\int_0^a \int_0^adydz=0$$ But the same reasoning does not work for $\vec{u}(r)=(x,0,0)$ where I write $$\iint_S \vec{u}.d\vec{S}= \iint_{S_{x,1}} -u_x.dydz + \iint_{S_{x,2}} u_x.dydz = -\int_0^a \int_0^axdydz+\int_0^a \int_0^axdydz=0$$ But this is false because the correct value is $a^3$. Should I evaluate $\vec{u}$ on each surface before integrating ? That would give $$\int_0^a \int_0^a0dydz+\int_0^a \int_0^aadydz=a^3$$ What if the value is not the same for a face ? What if the field was $\vec{u}(r)=(x+y,0,0)$ ?
Please note that,
$S_{x,1}$ is in plane $x = 0$ so for the first integral $u_x = x = 0$
$S_{x,2}$ is in plane $x = a$ so for the second integral $u_x = x = a$
$\displaystyle \iint_S \vec{u}.d\vec{S}= \iint_{S_{x,1}} -u_x \ dy \ dz + \iint_{S_{x,2}} u_x \ dy \ dz$
$ \displaystyle = 0 + \int_0^a \int_0^a a \ dy \ dz = a^3$
If the vector field is $\vec{u} =(x+y,0,0)$
Then for the first integral, it is $(y, 0, 0)$ and for the second integral, it is $(a + y, 0, 0)$.
Can you see why the net flux through both surfaces will still be $a^3$?