I am confused by the concept of flux as used in vector calculus. Suppose I have a sphere. On the inside of this sphere is a spherically symmetric electric charge distribution. Now I want to find the flux through the surface of the sphere.
Obviously, the electric field of that charge distribution is a vector field. So presumably I can apply a surface integral here to find the total flux through the surface.
But this is what I am having trouble understanding. What am I adding up with a surface integral in computing the flux through a surface? In other words, I have heard flux described as "Field lines per unit area" of the surface. How can we quantify the density of a vector field? I thought in a vector space like $\Bbb{R}^3$ there would be an infinite number of possible lines going through a patch of a surface. In that sense, then this definition of flux as "Field lines per unit area" makes no sense.
My Question:
Can someone clarify the definition of flux in a rigorous enough way that some of the mathematical contradictions (ie infinite number of lines through surface) I named are clarified?
EDIT:
Tom Apostol mentions the term "flux density vector field" that essentially assigns a flux density vector to each point in space. Perhaps answerers could clarify what this is as I think it's likely related to my question.
I think the "infinite number of field lines through the surface" is to be understood in the sense that one field line goes through one surface element. We take the limit as the area of the surface element goes to zero and the corresponding limit of infinite field lines. This is of course heuristic.
Let us discuss flux in three dimensions.$^1$ Let $\Pi\subset\mathbb{R}^3$ be a parallelepiped and $S:=\partial\Pi$. Let $d\sigma$ be a measure-valued 1-form. We define the outward flux of the field $A$ as $$F(\Pi)=\int_S \langle A,d\sigma\rangle$$ Very laborious mathematics allows us to derive from this the general Stokes theorem in any dimension. See Arnold's book for a derivation using so-called chains.$^2$ In any case, the general definition of flux for a general manifold $M$ and $D\subset M,\partial D=:S$ is $$F(D)=\int_S\langle A,d\sigma\rangle$$ where the inner product is now taken with respect to the possibly curved metric. Gauss' theorem is $$\int_S\langle A,d\sigma\rangle=\int_D (\operatorname{div}A)\,dv$$ where $dv$ is the canonical measure on $M$. For the electric field we of course have $\operatorname{div}E=\rho$, so the flux is just the charge in $D$.
Flux density is simply the vector field $A$ used above.
$^1$ I am taking material from V.I. Arnold, Mathematical Methods of Classical Mechanics (1997) and Straumann, General Relativity (2013).
$^2$ Section 36. This book is an almost scarily complex discussion of classical mechanics. Definitely worthy of the label "Graduate Texts in Mathematics".