Due to the uneven distribution of electrolytes in the electrolyzer, gas retention zones are generated, which will reduce hydrogen production efficiency and shorten the lifespan of electrodes. Therefore, it is of great significance for developing water electrolysis to optimize channels' structure and improve electrolyte distribution uniformity. This article constructs a coupled model of electrochemical and multiphase flow. It calculates the overall process from the electrolyte flowing into the electrolyzer, to the electrochemical reaction inside the porous electrode, and then to the discharge of the electrolyte together with the product. The comparative analysis shows that due to the interaction between gas-liquid phases, there is a significant difference between the actual flow and the ideal single-phase flow. The average velocity of the electrolyte in the channel calculated by the coupling model is more than 20% different from that calculated by the single-phase flow model. Moreover, the velocity distribution is not directly related to the phase distribution. Based on the flow pattern of electrolytes in the flow channel, the structural parameters of the mastoid were optimized. The elliptical mastoid can evenly decrease the specific energy consumption by 45.87% compared to the circular mastoid. By reducing the ratio of mastoid distance to mastoid diameter from 7.14 to 5.71, the specific energy consumption can be evenly decreased by 30.28%.