Direct simulation of electrical and hydraulic tortuosity in porous solids