- Have a life outside work
- Only work so many hours
- Sleep 9 hours a day (not kidding - My doctor has told me research backs this up)
- Get a good amount of exercise
- Stop smoking/drinking
- Take vitamins (B, and some people recommend fish oil)
- Have a fun project to work on
- On top of having a life outside work, code outside work - Work on your own projects, read up on the industry and new technologies (and investigate them), read books/whitepapers, practices your existing skills
- Have other hobbies/things to do to relax
- If you are so inclined, practice spirituality/philosophy
Talk to a doctor before you a lot of the stuff on this list.
Beyond this, you could look into prescription drugs. For example, I had a friend who had a problem getting into the flow at work, and happened to be going to a psychiatrist for a while. He later got diagnosed with ADD (or ADHD, I forget), was prescribed medication, and all has gone well since, flow-wise. Edit Check out the comments for a cautionary note about taking stimulants, and again, talk to a shrink and only get prescribed if it makes sense!
These all apply to base-flow, as well.
Edit: Mindfulness exercises (such as meditation or visualization) can also help, as can exercises for mental blocks (automatic writing, for example). For more on mental blocks, you can check out "The Artist's Way".