I recently had trouble producing a proper streamline plot in Mathematica, and apparently the problem is a good bit harder than I appreciated. I would like to know if there exist general algorithms to produce streamline plots which deal appropriately with line spacings and terminations.
Let me make the problem specific. Consider a vector field $\vec F(\vec x)$, in two or in three dimensions. A streamline is an integral curve of the vector field, that is, a curve $\vec\alpha(s)$ whose derivative $\frac{d\vec\alpha}{ds}$ is proportional at every point to the vector field $\vec F(\vec\alpha(s))$ at that point. A streamline plot represents a collection of such streamlines, and it is an extremely useful tool for visualizing the field, and its direction in particular.
There are, however, additional ways to make the diagrams convey information about the field's magnitude and its divergence.
If $\vec F$ is divergence-free (i.e. $\nabla\cdot\vec F=0$), then it is customary to draw streamlines that do not terminate unless they meet a zero or singularity of the field or go out of the plot, and to space the streamlines such that the vector field flow $$ \int_L\vec F\cdot \text d\vec x$$ is constant for $L$ connecting any two adjacent streamlines. (In three dimensions this is harder to define appropriately, but the flow $ \int_S\vec F\cdot \text d\vec a$ should be constant over any 'unit cell' whose corners are streamlines.)
This allows for a direct reading of the intensity of the vector field from the line spacing, which is guaranteed to be smaller where the field is more intense.
If $\vec F$ has a nonzero divergence, then it is still customary to keep the line spacing such that the flow between streamlines is approximately constant, though this requires that lines terminate or initiate in the middle of the diagram.
This allows one to visualize regions with positive or negative divergence - volume sources and sinks of the field - as those in which streamlines initiate or terminate, respectively.
So: I would like to know if there exist algorithms that will take a vector field $\vec F$ and a region $R$, in two or three dimensions (mostly two), and which will produce a set of streamline termini such that the field flow in between streamlines is (approximately) constant? It should therefore have lines initiate and terminate at and only at regions with positive and negative field divergence.