A stream function is an implicit flow representation in form of a function, whose values are constant along streamlines of the underlying velocity field. To generate a stream function, a common approach is to use a streamline tracking technique after assigning scalar function values on the inflow/outflow domain boundary (pre-processing step). However, non-trivial flows generally have streamlines that do not start or end at the domain boundary. We propose an automatic approach that defines a stream function along such streamlines. To do so, we construct optimal termination surfaces inside the domain and assign scalar values to all streamlines crossing these surfaces. Furthermore, we propose a proper functional to characterize the quality of the approximated stream function. Using a variational
approach, we derive a partial differential equation for the minimization of the derived functional. This minimization procedure is an effective tool to improve the stream function. It can also be used to significantly improve the pre-computation times by creating a high-quality high-resolution stream function from a low-resolution estimate. Once the implicit flow representation is established and improved, we can efficiently extract flow geometry such as stream ribbons, stream tubes, stream surfaces, etc. by applying fast marching algorithms. Tracking time recorded during the pre-processing step can be coupled with the stream function or used directly to extract time surfaces. Thus, the entire flow field can be explored interactively. There is no need for time-consuming particle tracking and mesh refinement during the visual exploration process.