If not, what other idioms could be used to express that one is thinking?
I'm not sure if this will be widely understood. It's likely to be confused with to grind someone's gears, which means
To greatly or specifically irritate or annoy someone
An alternative is to rack one's brain(s):
to think very hard, usually in order to remember something or to find a solution to a problem
(sources: The Free Dictionary)