Writing huge 2D vectors to text file too slow
The output-writing code should reside in a function that takes two parameters: the flowDirGrid and a filename.

Don't omit braces on multi-line conditionals.  It's a filthy habit, and someday you will contribute to a coding accident like this.

A performance problem is outputting std::endl at the end of every line, which causes a flush.  Output '\n' instead.