Physics-informed convolutional neural networks for fluid flow through porous media Authors: Rafał Topolnicki, Paweł Dłotko, Maciej Matyka Published: 2026 ABSTRACT Accurate simulation of fluid flow in porous media is a challenging task due to the complexity of pore-space geometries and the computational cost of solving the Navier–Stokes equations. Traditional numerical solvers rely on carefully constructed meshes, often requiring manual intervention, and typically exhibit slow convergence. This difficulty is particularly pronounced in porous media, where the diffusive nature of momentum transport is hindered by intricate solid boundaries. These challenges limit the efficiency of numerical simulations, particularly when repeated evaluations are required. We present a neural-network-based framework for predicting pore-scale velocity fields directly from sample geometry. The method is based on a convolutional encoder–decoder architecture with skip connections, designed to preserve fine-grained structural information. Physical consistency is encouraged through a custom loss function composed of multiple terms: incompressibility, no-flow conditions within solids, periodicity constraints, and agreement with the global tortuosity index. We systematically analyze the influence of weight selection for these loss terms, quantifying their individual contributions to prediction accuracy. Several architectural variants inspired by computer vision are evaluated to identify one providing the best performance and robustness. The generalization ability of the trained network is assessed on samples outside the training distribution, including variations in boundary conditions, obstacle geometry, and porosity. Finally, we demonstrate additional practical applications in which network predictions are used to initialize the Lattice–Boltzmann simulations, a standard fluid dynamics solver, often used in complex boundary problems like porous media and used by us to train the network. We have used network-generated velocity field as a starting point and found that this significantly accelerates LBM solver convergence, achieving improvements in over 90% of cases. Introduction Porous materials are ubiquitous in nature and technology. Research on them covers a wide range of topics related to fluid transport, mechanics, and strength. One area with particular applications is the study of the permeability of porous samples, which has applications in oil extraction37, CO\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} storage3, and in medicine, with a prominent example of the blood-brain barrier as the drug delivery path, of which permeability is often of interest6. For the past few decades, solving the fluid transport problem required the use of advanced numerical methods to solve the Navier-Stokes equations2. The main time-demanding elements of standard computational fluid dynamics simulation pipelines are: solving large systems of linear equations, creating computational grids, utilizing high-powered computers, and the diffusive nature of momentum transport. In general, given boundary conditions, initial conditions, and physical parameters, the only way to find the trajectories of particles in water is to solve the non-linear Navier-Stokes equations in approximate, numerical, and iterative approaches. The use of a mesoscopic Lattice-Boltzmann Method12, in which we deal with the transport of a particle distribution function on regular grids, is promising and successful, particularly in irregular and porous geometries32. It comes, however, at an additional physical complexity in interpretation and additional cost of memory and time demand, thus requiring special optimizations22 and memory layouts for handling large datasets34. Meanwhile, we (humans) learn by observing physical systems. Looking at the ball thrown to the sky, we know that it will eventually fall, and we do this naturally, not knowing the PDEs behind. Similarly, for fluid flow in an open channel with an obstacle, we know approximately where the water will go and turn, as well as under what conditions a vortex may form. It is intuitively consistent that vortex-dominated flow occurs under conditions of increased velocity, and we are able to predict based on our knowledge and previous observations. Recent research has shown that this is also possible using artificial intelligence and deep convolutional neural networks. Guo et al. have demonstrated steady-state flow predictions for the flow over single objects immersed in a channel, utilizing convolutional neural networks (CNNs)11. Recently, the same authors have shown unsteady flow predictions over single obstacles in a channel10. We are, however, aiming to predict the flow in complex geometries of porous media, both at low and high porosity, where the complexity of the pore network poses a challenge for neural networks. In our recent work we have shown, that only geometry is enough to predict physical properties of porous samples to predict their macroscopic properties in fluid flow and diffusive processes using CNN’s8,9. Research record on the topic of predicting physical properties of physical samples using deep learning techniques is rich. Recently, Lin et al. studied the application of CNNs in predicting velocity and temperature distributions in metal foam samples, demonstrating the outstanding efficiency of the method compared to standard numerical procedures24. It has been shown that the prediction of physical fields using CNNs can be improved by incorporating a physically informed network to reproduce temperature fields36, a procedure that can be equivalent to solving differential equations and serves to generate physically correct results. Our work proposes using a combined physics-informed CNN approach for fluid flow in complex porous media at various porosity conditions. We use convolutional neural networks and a custom, physically motivated loss function. The main contributions of our work within CNN-based pore-scale flow prediction are summarized as follows: We implemented a complete process from constructing the porous samples, simulation using the Lattice Boltzmann Method, through CNN training for predicting velocity fields in fluid flow through a porous media at various porosities.We construct and evaluate a custom loss function tailored to pore-scale flow prediction, including terms related to periodicity of the computational grid and tortuosity matching. .We carried out tests on various types of porous media samples to demonstrate the generalization abilities of the neural network and predict beyond the data region on which the network was learned.We show practical application of CNNs for the Lattice Boltzmann Method: LBM solver can be significantly accelerated if the neural network’s predictions are used to initialize the fluid dynamics solver.We note that the general use of CNNs as surrogate models and the idea of incorporating physics-inspired constraints into neural-network training are well established. The contribution of the present work is therefore not the introduction of a new learning paradigm, but rather the formulation and evaluation of a problem-specific physics-informed loss for pore-scale flow prediction, together with a systematic assessment of its components, architecture dependence, out-of-distribution behavior, and use for LBM initialization. We implemented a complete process from constructing the porous samples, simulation using the Lattice Boltzmann Method, through CNN training for predicting velocity fields in fluid flow through a porous media at various porosities. We implemented a complete process from constructing the porous samples, simulation using the Lattice Boltzmann Method, through CNN training for predicting velocity fields in fluid flow through a porous media at various porosities. We construct and evaluate a custom loss function tailored to pore-scale flow prediction, including terms related to periodicity of the computational grid and tortuosity matching. . We construct and evaluate a custom loss function tailored to pore-scale flow prediction, including terms related to periodicity of the computational grid and tortuosity matching. . We carried out tests on various types of porous media samples to demonstrate the generalization abilities of the neural network and predict beyond the data region on which the network was learned. We carried out tests on various types of porous media samples to demonstrate the generalization abilities of the neural network and predict beyond the data region on which the network was learned. We show practical application of CNNs for the Lattice Boltzmann Method: LBM solver can be significantly accelerated if the neural network’s predictions are used to initialize the fluid dynamics solver. We show practical application of CNNs for the Lattice Boltzmann Method: LBM solver can be significantly accelerated if the neural network’s predictions are used to initialize the fluid dynamics solver. The paper is organized as follows: in Section Materials and methods, we introduce the physical model of porous media and discuss the fluid flow solver, the Lattice Boltzmann Method, which is used later to prepare the training velocity fields. We describe the procedure to synthesize porous medium models investigated in the paper. Additionally, the learning process is described in detail, including data augmentation and a detailed description of the loss function. We discuss the choice and analysis of the neural network architecture and describe details of the training protocol. In Section Materials and methods we present the results of predictions made by the trained network, both for tortuosity and permeability of the samples. Then, we discuss and present results on the generalization properties of our approach, including its ability to generalize to other porosities, shapes of obstacles, and other boundary conditions. We summarize our findings in Section Conclusions. Materials and methods Pore scale flow We describe porous samples at the pore-scale level, where solid obstacles, distributed randomly, fill the space up to the desired porosity of the sample. We assume periodic boundary conditions in both directions, which, for the two-dimensional case, directly represent a porous medium on a torus topology. The flow is driven by gravity, which accelerates the fluid to a certain level. Due to the no-slip boundary conditions, the system stabilizes to a so-called stationary flow. The governing equations for the fluid flow in pores are Navier-Stokes, that, for an incompressible fluid takes form:1\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \nabla \cdot \textbf{u}=0, \end{aligned}$$\end{document}2\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \varrho (\textbf{u} \cdot \nabla \textbf{u})=-\nabla p+\mu \nabla ^2 \textbf{u}+\textbf{f}, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{u}$$\end{document} is velocity, μ is dynamic viscosity, p is the pressure, and ϱ is its density. Here, we operate in the regime of low Reynolds numbers, for which the flow through porous matrix satisfies simpler Darcy’s linear law:3\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{q}=-\frac{k}{\mu }\left( \nabla P + \varrho \textbf{f}\right) , \end{aligned}$$\end{document}where q is Darcy flux, k is permeability \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$[L^2]$$\end{document} and f is the external force density (i.e. gravity). Permeability, k, is of utmost importance in applications and porous media research. It became a standard measure with a described protocol for the experimental treatment. For practical applications, it can be expressed in terms of tortuosity and porosity, i.e.:4\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} k=\frac{\varphi ^3}{c\tau ^2S}, \end{aligned}$$\end{document}where c is a material-specific constant, τ is tortuosity of the medium, and S is specific surface area of pores19. Such a definition of permeability allows for estimations based on the geometrical properties of the medium, except for the value of τ, which must be measured in the simulation or experiment. Tortuosity is a non-dimensional number representing elongation of porous media pores due to existence of solid matrix and it is driven by pore space geometry and physical process of channel formation. It can be investigated using streamlines generated on top of the velocity field, whose averaged elongation can be used to compute the tortuosity index18,26. We will use the velocity field to compute tortuosity by directly integrating the streamwise and total momentum in the pore space, which results in the following expression for tortuosity:5\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \tau =\frac{\langle v\rangle }{\langle v_x\rangle }, \end{aligned}$$\end{document}where brackets denote average over pore space, and x is the component of velocity parallel to the direction of external body force5,27. The Lattice Boltzmann method To solve the flow problem and obtain pore-space velocity fields to train the neural network, we utilize an indirect, mesoscopic Lattice Boltzmann Method (LBM). LBM works on a regular grid with a nine-component velocity discretization. It solves the Navier-Stokes flow equations indirectly by solving the transport equation of the particle distribution function \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$f(\textbf{x},t)$$\end{document}, which represents the probability of finding particles at a given velocity at a specific location and time. The method demonstrated its unique properties and accuracy in porous media flows, becoming popular primarily due to its simplicity in implementation and the ability to handle complex geometries using local no-slip boundary conditions. We will utilize its properties and solve the transport equation of the particle distribution function using the following model in the BGK (one-relaxation approximation) collision term32:6\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} f_i(\textbf{x}+\textbf{e}_i,t+\delta t)=f_i(\textbf{x},t)+\frac{f_i^{eq}(\textbf{x},t)-f_i(\textbf{x},t)}{\tau }, \end{aligned}$$\end{document}where τ is relaxation time, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$f_i^{eq}$$\end{document} is distribution function in equilibrium. Calculation of consecutive moments of the transported distribution function gives the macroscopic density \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\varrho (\textbf{x},t)$$\end{document} and velocity \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{u}(\textbf{x},t)$$\end{document} fields:7\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \varrho (\textbf{x},t)=\sum _i f_i(\textbf{x},t), \end{aligned}$$\end{document}8\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \varrho (\textbf{x},t)\textbf{u}(\textbf{x},t)=\sum _i f_i(\textbf{x},t)\mathbf {e_i}, \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathbf {e_i}$$\end{document} are the lattice vectors. Porous samples Two-dimensional porous structures were represented as binary images with a resolution of 256 × 256 pixels. The structures were generated by superimposing standing sinusoidal waves with a fixed wavelength and amplitude but varying random directions \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{q}_i$$\end{document} and phases \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\phi _i$$\end{document}. The resulting field is given by:9\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} f(\textbf{x}) = \sqrt{\frac{2}{N}} \sum _{i=1}^{N} \cos (\textbf{q}_i \cdot \textbf{x}+ \phi _i), \quad \textbf{x}\in [0,1] \times [0,1], \end{aligned}$$\end{document}where \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{x}$$\end{document} is the position vector, and the phases \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\phi _i$$\end{document} are randomly sampled from the interval [0, π ]. The wave vectors are defined as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{q}_{i,j} = 2k\pi$$\end{document}, where k is a randomly chosen integer within the range [-12,12]. For each generated structure, the number of superimposed standing waves, N, is randomly selected beforehand from the range [10, 100]. Given the random function (9), the different phases of the system are defined as10\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \textbf{x}\in \mathcal {B}&\text {if}&f(\textbf{x}) \le \varepsilon , \nonumber \\ \textbf{x}\in \mathcal {P}&\text {if}&f(\textbf{x}) > \varepsilon . \end{aligned}$$\end{document}Here, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {B}$$\end{document} represents the solid phase, while \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {P}$$\end{document} corresponds to the pore phase. The threshold value \varepsilon is chosen to achieve the desired porosity φ for each generated sample. The porosity values are uniformly sampled within the range \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$0.70 \le \varphi \le 0.95$$\end{document}. In this context, the porosity is defined as the ratio of void-phase pixels to the total number of pixels. Structures that do not allow fluid flow through the material were removed from the dataset. A total of 10,000 structures were generated and used for model training. Example of structures generated using this algorithm, along with its corresponding velocity fields, are presented in Fig. 1.Fig. 1Example porous structures and corresponding LBM solutions - color indicates velocity magnitude. The same color scale applied on all plots. Structure porosity is (a) 0.771, (b) 0.861, (c) 0.917.Fig. 2Statistical summaries of the LBM solutions for the dataset used to train the model. (a) Distribution of the trivial porosity (defined as the ratio of void area to total sample area). (b) Distribution of the mean and maximum fluid velocity within the porous structures. (c) Distribution of permeability values. (d) Distribution of tortuosity values across all samples. Red vertical lines on panels (b) and (c) indicate the prediction accuracy as indicated by the RMSE for the best model – see Table 2. Example porous structures and corresponding LBM solutions - color indicates velocity magnitude. The same color scale applied on all plots. Structure porosity is (a) 0.771, (b) 0.861, (c) 0.917. Statistical summaries of the LBM solutions for the dataset used to train the model. (a) Distribution of the trivial porosity (defined as the ratio of void area to total sample area). (b) Distribution of the mean and maximum fluid velocity within the porous structures. (c) Distribution of permeability values. (d) Distribution of tortuosity values across all samples. Red vertical lines on panels (b) and (c) indicate the prediction accuracy as indicated by the RMSE for the best model – see Table 2. Figure 2 presents the distributions of key physical and geometric properties derived from the dataset used for model training. Data augmentations Fig. 3(a) Example porous structure (top row) and corresponding LBM solution - color indicates velocity magnitude. (b) The same structure and velocity field after vertical flip is applied. (c) Effect of horizontal and vertical roll: 20% of image rows and columns (indicated by dashed lines in panel (a) where shifted beyond the original image and placed at the other end. (a) Example porous structure (top row) and corresponding LBM solution - color indicates velocity magnitude. (b) The same structure and velocity field after vertical flip is applied. (c) Effect of horizontal and vertical roll: 20% of image rows and columns (indicated by dashed lines in panel (a) where shifted beyond the original image and placed at the other end. During training, data augmentation techniques are applied to the structures to enhance the model’s generalization ability. The augmentations include random vertical flipping and random rolling. In the vertical flip augmentation, each structure is flipped along the vertical axis with a given probability (set to 0.5 in all experiments). The corresponding velocity field is adjusted accordingly by inverting the vertical velocity component (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$v_y \rightarrow -v_y$$\end{document}), see Fig. 3b. The random roll augmentation shifts a selected number of columns from the left side of the structure to the right and similarly moves a number of top rows to the bottom. The velocity field is adjusted consistently to maintain continuity. The effect is shown in Fig. 3c. The number of shifted columns and rows is randomly selected for each instance, ensuring that no more than 30% of the image is rolled. These augmentations allow the model to learn from a more diverse set of training samples, effectively increasing the variability of the dataset without requiring additional computationally expensive LBM simulations. Model architecture The solution employs a U-Net architecture30, a widely adopted neural network originally developed for pixel-wise image segmentation. U-Net features an encoder-decoder structure with skip connections, which facilitate the preservation of spatial details while enabling the extraction of hierarchical, multi-scale features. The input to the model is a 256× 256 binary image representing the porous structure. The image is processed through the encoder path, which is composed of a deep CNN backbone. In our study, we consider a range of architectures commonly used in computer vision, including classical models such as VGG31, ResNet13, and DenseNet15, as well as more recent designs such as ConvNeXt25, EfficientNet33, and MobileNetV3 14. These newer architectures have been proposed as either modernized or computationally efficient variants of standard convolutional networks. In particular, ConvNeXt incorporates several design elements inspired by transformer-based models while remaining fully convolutional, EfficientNet introduces a compound scaling strategy, and MobileNetV3 focuses on lightweight computation through the use of depthwise separable convolutions and optimized building blocks. All these architectures are used interchangeably as encoder backbones within the same framework, allowing for a consistent comparison. Next, a bottleneck layer refines the internal feature representation before upsampling. The decoder consists of transposed convolutional layers that successively restore spatial resolution. Additionally, skip connections from corresponding encoder layers are incorporated, mitigating information loss due to downsampling. These skip connections enhance the network’s ability to produce pixel-wise velocity predictions. The final output is a 256 × 256 velocity field with two channels, corresponding to the x and y components of the predicted velocity field (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$u_x$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$u_y$$\end{document}). This prediction is compared to the reference velocity field obtained via LBM simulation, and the discrepancy is quantified using the custom loss function defined in Equation (11). The loss is then backpropagated through the network to update the model parameters. Learning procedure For each porous structure in the dataset, the LBM solution was computed. The solution at each pixel is represented as a two-dimensional velocity vector \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{u} = (u_x, u_y)$$\end{document}. During the network training, the model receives the structure (binary image) as input and the corresponding LBM solution (pixel-size vector field) as output. The goal of training is to predict the LBM velocity field exclusively from the provided structure image of the structure. A notable feature of our approach is that the model backbone, which we use to construct the U-Net architecture, consists of convolutional neural networks (CNNs) of different architectures. Since CNNs operate as pattern recognition models, they are not explicitly aware of solving a differential equation. Instead, the network learns a mapping between the input structure and the output velocity field. To train the model, we employ a custom loss function \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}$$\end{document}, which is composed of multiple terms:11\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \mathcal {L}&= \mathcal {L}_\text {vel} + \alpha \mathcal {L}_\text {obstacle} + \beta \mathcal {L}_\text {div} + \gamma \mathcal {L}_\text {perio} + \delta \mathcal {L}_\text {tort} \end{aligned}$$\end{document}12\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned}&= \frac{1}{2|\Omega |} \sum _{j \in \{x, y\}} \int _{\Omega } \left( v_j(\textbf{x}) - u_j(\textbf{x}) \right) ^2 d\textbf{x}+ \frac{\alpha }{2|\mathcal {B}|} \sum _{j \in \{x, y\}} \int _{\mathcal {B}} |u_j(\textbf{x})| d\textbf{x}\end{aligned}$$\end{document}13\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned}&+ \frac{\beta }{|\mathcal {P}|} \int _{\mathcal {P}} (\nabla \cdot \textbf{u}(\textbf{x}))^2 d\textbf{x}\end{aligned}$$\end{document}14\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned}&+ \frac{\gamma }{2|\Omega |} \sum _{j \in \{x, y\}} \int _{\Omega } \left( u_j(\textbf{x}) - u_j^T(\textbf{x}) \right) ^2 d\textbf{x}+ \delta (\tau _v-\tau _u)^2 . \end{aligned}$$\end{document}where Ω denotes the full computational domain and |Ω | its area, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {B}$$\end{document} denotes the solid obstacle region and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$|\mathcal {B}|$$\end{document} its area, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {P}$$\end{document} denotes the fluid pore space and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$|\mathcal {P}|$$\end{document} its area. Furthermore, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{v}=(v_x, v_y)$$\end{document} is the reference velocity field obtained from the LBM solution, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{u}=(u_x, u_y)$$\end{document} is the velocity field predicted by the model, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\tau _v$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\tau _u$$\end{document} are the reference and predicted tortuosities, respectively. The coefficients α, β, γ, and δ are non-negative weights controlling the relative contributions of the individual loss components. All spatial integrals are evaluated numerically on the discrete 256× 256 computational grid. The loss function can be decomposed into five contributions. The first term, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {vel}$$\end{document}, represents the mean squared error between the predicted and reference velocity fields. The error is computed separately for each velocity component and then summed. The second term, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document}, imposes an additional penalty when nonzero flow velocity is predicted inside the obstacle regions. Specifically, within the solid domain \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {B}$$\end{document} (as defined in Equation (10)), the penalty is applied using the L1 norm instead of the L2 norm employed in the velocity loss term. The use of the L1 norm places greater emphasis on reducing even small nonzero velocity predictions inside obstacles. The third term, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document}, penalizes divergence in the predicted velocity field. In low-Mach number flows (which is our case), LBM solutions should satisfy the incompressibility condition \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\nabla \cdot \textbf{u} = 0$$\end{document} everywhere. This term ensures that the predicted velocity field adheres to this constraint by minimizing divergence errors.Fig. 4Explanation of the loss term \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} defined in equation (15). (a) The structure S and translation vector T. (b) Velocity field predicted for structure S – this velocity field is denoted as CNN(S). (c) Velocity field after imposing translation T. (d) Structure S after translation by vector T: i.e. T[S]. (e) Velocity field CNN(T[S]) predicted for translated structure T[S]. Finally \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} is computed as integrated squared difference between velocity fields predicted for transformed structure T[S] and transformed velocity field predicted for initial structure S. Explanation of the loss term \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} defined in equation (15). (a) The structure S and translation vector T. (b) Velocity field predicted for structure S – this velocity field is denoted as CNN(S). (c) Velocity field after imposing translation T. (d) Structure S after translation by vector T: i.e. T[S]. (e) Velocity field CNN(T[S]) predicted for translated structure T[S]. Finally \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} is computed as integrated squared difference between velocity fields predicted for transformed structure T[S] and transformed velocity field predicted for initial structure S. The fourth term, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document}, addresses the periodicity of the system. Convolutional neural networks (CNNs), by design, are not inherently aware of periodic boundary conditions. They typically implement border treatment via padding methods—such as zero, replicate, reflect, or circular—which are selected heuristically and do not enforce any physical periodicity. Several studies demonstrate that the choice of padding can significantly influence prediction accuracy, and that even circular padding fails to generalize across periodic domains without additional architectural constraints or context information1,7,16. To mitigate this limitation and foster consistency under periodic shifts, we introduce an additional loss term \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} that penalizes discrepancies between prediction for translated structure T[S] and translated prediction for structure S. The mechanism by which periodic consistency is promoted through this loss term is illustrated in Fig. 4. The translation T takes into account periodic conditions. For a given structure S and periodic translation T, this term is defined as15\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\begin{aligned} \mathcal {L}_\text {perio} = \frac{1}{2|\Omega |} \sum _{j \in \{x,y\}} \int _{\Omega } \left( u_j(\textbf{x}) - u_j^T(\textbf{x}) \right) ^2 d\textbf{x}. \end{aligned}$$\end{document}Here, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\textbf{u}^T$$\end{document} denotes the prediction obtained after applying a periodic translation to the input structure and translating the resulting predicted velocity field back to the original coordinate system. This encourages the network to produce predictions that are more consistent across periodic boundaries and better aligned with the periodic assumptions used in the LBM simulations. During training, several choices of the translation vector T were tested, including random translations. In the final implementation, we used T=[L/2,L/2], which provided a practical compromise between training cost and prediction accuracy. Finally, the fifth term, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {tort}$$\end{document}, penalizes discrepancies between the predicted tortuosity \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\tau _u$$\end{document} and the reference tortuosity \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\tau _v$$\end{document}, which is computed from the ground-truth LBM solution. Tortuosity is a key macroscopic transport property that quantifies the effective elongation of flow paths due to the geometry of the porous medium. Accurate estimation of tortuosity is crucial in many real-world applications—including filtration, catalysis, and subsurface flow—where it directly impacts performance and efficiency metrics. By explicitly incorporating tortuosity into the loss function, we ensure that the model not only captures local velocity features but also respects global structural characteristics of the flow field, thereby enhancing the reliability of the model for downstream physical analysis and design tasks. All the integrals in Equations (11) and (15) were approximated by discrete sums over all pixels. Similarly the divergence in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document} i.e. \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\nabla \cdot \textbf{u} = \frac{\partial u_x}{\partial x} + \frac{\partial u_y}{\partial y}$$\end{document} was approximated by first-order discrete derivatives. We emphasize that the model is trained in a supervised manner using velocity fields generated by the LBM solver. Thus, the network should be interpreted as a surrogate model for the numerical solution under the considered assumptions, rather than as a solver that independently derives the governing equations. In this work, the term physics-informed refers to the use of additional physically motivated penalty terms in the loss function, which guide the supervised learning process toward predictions that better satisfy local and global physical constraints. Components of the loss function - analysis Table 1Performance metrics for models trained with different combinations of loss function components. Each model shares the same ResNet-101 architecture and dataset. The table reports the average value of each individual loss component as well as the coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document}) for tortuosity prediction. α β γ δ \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {vel}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {tort}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document} 00002.26E-054.68E-046.68E-063.27E-056.22E-030.12750003.68E-054.43E-066.41E-063.34E-056.85E-040.90151002.00E-051.45E-062.00E-062.30E-051.09E-030.833510.101.79E-051.42E-061.84E-061.86E-058.71E-040.873510.10.012.07E-051.85E-062.09E-062.22E-051.24E-040.983 Table 1Performance metrics for models trained with different combinations of loss function components. Each model shares the same ResNet-101 architecture and dataset. The table reports the average value of each individual loss component as well as the coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document}) for tortuosity prediction. α β γ δ \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {vel}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {tort}$$\end{document} \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document} 00002.26E-054.68E-046.68E-063.27E-056.22E-030.12750003.68E-054.43E-066.41E-063.34E-056.85E-040.90151002.00E-051.45E-062.00E-062.30E-051.09E-030.833510.101.79E-051.42E-061.84E-061.86E-058.71E-040.873510.10.012.07E-051.85E-062.09E-062.22E-051.24E-040.983 Performance metrics for models trained with different combinations of loss function components. Each model shares the same ResNet-101 architecture and dataset. The table reports the average value of each individual loss component as well as the coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document}) for tortuosity prediction. Table 1 presents a quantitative comparison of models trained with different configurations of the custom loss function. All models share the same ResNet-101 architecture, which was identified as the most performant among those evaluated, and were trained, validated, and tested on identical datasets. The values reported represent the average magnitude of each loss component on the test set. Additionally, the accuracy of tortuosity prediction is evaluated using the coefficient of determination \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document}. The baseline model was trained using only the velocity loss component, i.e., \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L} = \mathcal {L}_\text {vel}$$\end{document}. This model achieved the lowest mean squared error (MSE) in terms of velocity prediction but failed to suppress spurious flow within obstacle regions, as illustrated in Fig. 5. Furthermore, it demonstrated poor accuracy in predicting tortuosity, with \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau = 0.127$$\end{document}. In the second experiment, we introduced the obstacle loss term \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document} with a weighting factor of α = 5. This addition significantly reduced flow predictions within solid regions, with the average \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document} decreasing by over two orders of magnitude. It also led to a substantial improvement in tortuosity prediction, increasing \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_\tau$$\end{document} to 0.901 and reducing the MSE in \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {tort}$$\end{document} by one order of magnitude. However, the divergence loss \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document} remained similar due to the unconstrained divergence of the predicted field. To address this, the third model incorporated the divergence loss term \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {div}$$\end{document} with β = 1. This further reduced the average divergence in the predicted velocity fields and yielded improvements in both \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {vel}$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {obstacle}$$\end{document}, indicating better generalization in void regions and at fluid–solid interfaces. Despite these improvements, qualitative analysis (see Fig. 5) revealed that the model occasionally failed to enforce periodic boundary conditions. To address this issue, the fourth model introduced the periodic consistency loss \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document}, weighted by γ = 0.1. This modification improved the model’s ability to handle periodic translations, reducing \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {perio}$$\end{document} and ensuring greater physical consistency across domain boundaries. Finally, the fifth and most complete model incorporated the tortuosity consistency loss \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\mathcal {L}_\text {tort}$$\end{document}, with a weighting factor of δ = 0.01. This led to the most accurate tortuosity predictions, achieving an \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2_{\tau }$$\end{document} value of 0.983. Additionally, it exhibited the lowest penalties for both obstacle violation and divergence, while maintaining a velocity prediction error comparable to the baseline. The final model thus represents the best trade-off among local accuracy, physical plausibility, and global flow characteristics. The above analysis illustrates the contribution of each individual loss function component to the overall model performance. The sequential inclusion of these terms not only often improves local accuracy in velocity prediction but also enforces key physical constraints such as impermeability of solid regions, incompressibility, and periodic boundary conditions, while enhancing the fidelity of global transport metrics like tortuosity. Based on these findings, all subsequent models presented in this study were trained using the full loss function with fixed weighting coefficients: α = 5, β = 1, γ = 0.1, and δ = 0.01. A more detailed sensitivity analysis of these hyperparameters, including their interactions, is provided in the Supplementary Information (Section S3).Fig. 5(left) Reference velocity field obtained from the LBM simulation. (middle) Prediction from a model trained with a minimal loss function configuration (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha =\beta =\gamma =\delta =0$$\end{document}), illustrating several failure modes. The red box indicates flow erroneously penetrating solid obstacles. The green box highlights spurious flow induced by the model’s failure to respect periodic boundary conditions. The purple box shows a region confined by obstacles on three sides, where the model incorrectly predicts the location of the outflow. These prediction artifacts are fixed when the full loss function is used, with optimized weights: α =5, β =1, γ =0.1, and δ =0.01. (left) Reference velocity field obtained from the LBM simulation. (middle) Prediction from a model trained with a minimal loss function configuration (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha =\beta =\gamma =\delta =0$$\end{document}), illustrating several failure modes. The red box indicates flow erroneously penetrating solid obstacles. The green box highlights spurious flow induced by the model’s failure to respect periodic boundary conditions. The purple box shows a region confined by obstacles on three sides, where the model incorrectly predicts the location of the outflow. These prediction artifacts are fixed when the full loss function is used, with optimized weights: α =5, β =1, γ =0.1, and δ =0.01. Training protocol During training, the dataset was randomly split into training, validation, and test sets, comprising 70%, 15%, and 15% of the structures, respectively. The model’s weights were initialized randomly. We employed a two-stage training strategy. In the first stage, a pilot model was trained with divergence, periodicity and tortuosity contributions to total loss set to zero, i.e. \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\beta =\gamma =\delta =0$$\end{document} in (11). In the second stage, the pilot model’s weights were used as a starting point and were then fine-tuned using the full loss formulation with final values of hyperparameters, i.e. \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\beta =1, \gamma =0.1$$\end{document} and δ =0.01. This staged approach improved training stability and reduced sensitivity to the random dataset split. To prevent data leakage, both the pilot and final models were trained using the exact same data split. Optimization was carried out using the Adam algorithm17. For the pilot model, a learning rate of 0.0005 and gradient clipping28 with a threshold of 1.0 were used. For the final model, the learning rate was reduced to \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$10^{-5}$$\end{document} with gradient clipping at 0.1. In both cases, training continued as long as loss measure on validation set decreases (early stopping technique). Further training details are provided in the Supplementary Information (Section S2). Only test set metrics are reported in the paper. To improve robustness, three different random data splits were evaluated for each model architecture, and the reported results in Table 2 reflect the average and standard deviation across these splits. Results Table 2Performance metrics for various evaluated neural network architectures. The pixel-wise root mean squared error (RMSE) is reported for velocity field predictions. For tortuosity and permeability, three metrics are provided: RMSE, mean absolute percentage error (MAPE), and coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document}). The best result for each metric is highlighted in bold, second-best with bold+italic, while the third best is shown in italic. For velocity RMSE standard deviation is reported based on three independent runs with different dataset splits.velocitytortuositypermeabilityRMSEstd(RMSE)RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} VGG161.09E-02 5.62E-04 1.91E-021.00.9491.87E+039.10.985ResNet181.07E-022.20E-032.70E-021.50.8972.67E+0317.20.971ResNet508.58E-032.89E-03 1.89E-02 1.10.950 1.53E+03 7.0 0.990ResNet101 5.10E-03 1.92E-03 1.13E-02 0.6 0.983 8.69E+02 4.8 0.997 ResNet1527.74E-032.95E-032.01E-021.00.9441.89E+0311.80.985DenseNet121 6.45E-03 5.71E-034.11E-022.90.7631.70E+0310.50.988DenseNet201 7.48E-03 2.93E-03 1.81E-02 0.9 0.954 2.03E+0313.20.983ConvNext Tiny7.74E-032.45E-032.07E-021.10.9401.55E+038.60.990ConvNext Small9.24E-03 1.65E-03 2.41E-021.30.9191.71E+039.90.987ConvNext Base4.40E-021.94E-022.22E-021.20.928 1.47E+03 8.9 0.991 EfficientNet B21.20E-023.18E-032.40E-021.40.9191.93E+0313.90.983EfficientNet V2 S1.15E-024.51E-032.86E-021.60.8862.41E+0312.80.975MobileNet V3 Small1.00E-021.90E-032.49E-021.30.9131.81E+0310.60.985MobileNet V3 Large6.60E-033.57E-03 1.68E-02 0.9 0.961 1.26E+03 7.1 0.993 Table 2Performance metrics for various evaluated neural network architectures. The pixel-wise root mean squared error (RMSE) is reported for velocity field predictions. For tortuosity and permeability, three metrics are provided: RMSE, mean absolute percentage error (MAPE), and coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document}). The best result for each metric is highlighted in bold, second-best with bold+italic, while the third best is shown in italic. For velocity RMSE standard deviation is reported based on three independent runs with different dataset splits.velocitytortuositypermeabilityRMSEstd(RMSE)RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} VGG161.09E-02 5.62E-04 1.91E-021.00.9491.87E+039.10.985ResNet181.07E-022.20E-032.70E-021.50.8972.67E+0317.20.971ResNet508.58E-032.89E-03 1.89E-02 1.10.950 1.53E+03 7.0 0.990ResNet101 5.10E-03 1.92E-03 1.13E-02 0.6 0.983 8.69E+02 4.8 0.997 ResNet1527.74E-032.95E-032.01E-021.00.9441.89E+0311.80.985DenseNet121 6.45E-03 5.71E-034.11E-022.90.7631.70E+0310.50.988DenseNet201 7.48E-03 2.93E-03 1.81E-02 0.9 0.954 2.03E+0313.20.983ConvNext Tiny7.74E-032.45E-032.07E-021.10.9401.55E+038.60.990ConvNext Small9.24E-03 1.65E-03 2.41E-021.30.9191.71E+039.90.987ConvNext Base4.40E-021.94E-022.22E-021.20.928 1.47E+03 8.9 0.991 EfficientNet B21.20E-023.18E-032.40E-021.40.9191.93E+0313.90.983EfficientNet V2 S1.15E-024.51E-032.86E-021.60.8862.41E+0312.80.975MobileNet V3 Small1.00E-021.90E-032.49E-021.30.9131.81E+0310.60.985MobileNet V3 Large6.60E-033.57E-03 1.68E-02 0.9 0.961 1.26E+03 7.1 0.993 Performance metrics for various evaluated neural network architectures. The pixel-wise root mean squared error (RMSE) is reported for velocity field predictions. For tortuosity and permeability, three metrics are provided: RMSE, mean absolute percentage error (MAPE), and coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document}). The best result for each metric is highlighted in bold, second-best with bold+italic, while the third best is shown in italic. For velocity RMSE standard deviation is reported based on three independent runs with different dataset splits. Table 2 presents the predictive performance metrics for all evaluated architectures, covering a range of convolutional backbones with varying levels of architectural complexity and computational efficiency. The accuracy of the velocity field predictions is assessed using the component-wise, pixel-averaged root mean squared error (RMSE) defined as \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\text {RMSE}=\sqrt{\text {MSE}}$$\end{document}. To provide additional context for these values, Fig. 2b shows the distributions of both the mean and maximum fluid velocities in the dataset. The std(RMSE) column show the standard deviation of that RMSE computed out of three independent runs with different dataset splits. The next columns show the performance metrics, i.e. the RMSE, Mean Absolute Percentage Error (MAPE) and coefficient of determination \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} for tortuosity and permeability computed from the velocity field predicted by the model and compared with the LBM solution. Among all tested models, ResNet-101 consistently achieves the highest performance across nearly all metrics. It yields the lowest RMSE for velocity predictions at \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$5.1 \cdot 10^{-3}$$\end{document}, which corresponds to the average magnitude of the prediction error per velocity component. Given the median fluid velocity of approximately \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2.5 \cdot 10^{-2}$$\end{document} (Fig. 2b), this error reflects high predictive accuracy. Moreover, the low std(RMSE) value for ResNet-101 indicates robustness and stable generalization across dataset variations. Architectures designed with a focus on computational efficiency, such as EfficientNet and MobileNetV3, tend to exhibit higher errors across both velocity reconstruction and derived physical quantities. ConvNeXt, which follows a more modern convolutional design, achieves performance comparable to some of the classical architectures, but does not surpass the best-performing models. This trend is consistent across the evaluated metrics, including RMSE, MAPE, and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document}.Fig. 6(left) Reference velocity field obtained from LBM simulation. (middle) Prediction from model. (right) Difference in velocity magnitude between reference and predicted velocity fields. Results for a selected, representative sample for which the RMSE prediction of the velocity field is 5.8E-03, minimally greater than the average RMSE of the entire test-set of the model (5.1E-03, c.f. Table 2). (left) Reference velocity field obtained from LBM simulation. (middle) Prediction from model. (right) Difference in velocity magnitude between reference and predicted velocity fields. Results for a selected, representative sample for which the RMSE prediction of the velocity field is 5.8E-03, minimally greater than the average RMSE of the entire test-set of the model (5.1E-03, c.f. Table 2). In Fig. 6, we present the prediction results for a selected porous sample in graphical form. In addition to the velocity field from the LBM method and from the ResNet-101 prediction, we also show the difference in the absolute value of the velocity field. A visual analysis of these results confirms that the CNN network can correctly predict fluid flow paths. Analysis of the error distribution map did not yield any systematic conclusions. The differences between two methods are not significant and fluctuate around a value of 0, not betraying any trend towards one of the methods. It is worth noting the excellent continuity of the system at the periodic edges, which is a result of the periodic term in the loss function introduced by us. Additional error-bound analysis is provided in the Supplementary Information (Section S1). Based on the velocity fields, the tortuosity and permeability of each structure were inferred and compared with the LBM ground truth. For tortuosity, ResNet-101 achieves an RMSE of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1.13 \cdot 10^{-2}$$\end{document}—small relative to the mean dataset value of 1.1719 (Fig. 2d)—and a remarkably low MAPE of 0.6%. This indicates that, on average, the predicted tortuosity deviates by less than 1% from the reference. As shown in Fig. 7a, the predicted tortuosity values align closely with the exact LBM values, lying along the diagonal with only minor deviations at higher tortuosity values. The associated error distribution is symmetric and tightly centered around zero. For permeability, ResNet-101 again demonstrates the best performance, achieving the lowest RMSE and MAPE, and the highest \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} across all models. The MAPE remains below 5%, and the RMSE of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$8.69 \cdot 10^2$$\end{document}, when compared to the average dataset permeability of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$2.3 \cdot 10^5$$\end{document} (Fig. 2d), confirms the accuracy of the predictions. Figure 7b further supports this, showing predicted permeability values tightly clustered around the true LBM values.Fig. 7(a) Tortuosity predicted by the best-performing model as the function of LBM computed tortuosity. Inset shows error distribution. (b) The same for permeability. (a) Tortuosity predicted by the best-performing model as the function of LBM computed tortuosity. Inset shows error distribution. (b) The same for permeability. Overall, the results in Table 2 demonstrate that, with the exception of ResNet-18, most architectures yield comparable performance. ResNet-50 consistently performs well and emerges as the second-best choice, balancing both velocity field prediction and macroscopic property estimation. The performance achieved by the DenseNet family of convolutional neural networks seems to be systematically lower than that achieved by the simpler ResNet architecture. Notably, the VGG16 architecture, despite its simpler design and lack of residual or dense connections, achieves competitive results—typically falling between the performance of the ResNet and DenseNet families. These results suggest that, for the task of mapping pore geometry to velocity fields on a fixed grid, increased architectural complexity or efficiency-oriented design does not necessarily translate into improved predictive accuracy. A comparison with a Fourier Neural Operator 20,23 model is provided in the Supplementary Information (Section S4). Generalization to different systems Table 3Performance metrics of the model on various datasets that are different from the one used to train the model.velocitytortuositypermeabilityRMSERMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=1.0$$\end{document}9.20E-031.2E-020.820.9582.92E+034.390.994shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.5$$\end{document}1.90E-021.7E-021.150.9428.56E+034.590.981shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.0$$\end{document}2.25E-022.2E-021.560.8971.15E+045.600.976pipe5.59E-031.6E-020.760.9639.18E+024.090.997pipe (central)6.39E-031.6E-020.790.9628.49E+024.450.998porosity 0.7-0.83.52E-031.5E-020.760.9585.70E+026.700.961porosity 0.6-0.72.64E-036.7E-022.500.7943.36E+0213.740.916porosity 0.5-0.61.86E-036.6E-0112.320.1162.65E+0277.180.635Li-O\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} Electrodes6.41E-033.4E-022.080.7981.75E+039.710.986 Table 3Performance metrics of the model on various datasets that are different from the one used to train the model.velocitytortuositypermeabilityRMSERMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} RMSEMAPE \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=1.0$$\end{document}9.20E-031.2E-020.820.9582.92E+034.390.994shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.5$$\end{document}1.90E-021.7E-021.150.9428.56E+034.590.981shape, \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.0$$\end{document}2.25E-022.2E-021.560.8971.15E+045.600.976pipe5.59E-031.6E-020.760.9639.18E+024.090.997pipe (central)6.39E-031.6E-020.790.9628.49E+024.450.998porosity 0.7-0.83.52E-031.5E-020.760.9585.70E+026.700.961porosity 0.6-0.72.64E-036.7E-022.500.7943.36E+0213.740.916porosity 0.5-0.61.86E-036.6E-0112.320.1162.65E+0277.180.635Li-O\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} Electrodes6.41E-033.4E-022.080.7981.75E+039.710.986 Performance metrics of the model on various datasets that are different from the one used to train the model. While the model is trained on a specific dataset of porous structures, generated using random trigonometric polynomials, the underlying architecture and training methodology can be applied to similar physical systems. The use of convolutional neural networks allows the model to learn spatially invariant features, enabling it to generalize to geometries and flow patterns that differ from those seen during training. Moreover, the inclusion of physical constraints in the loss function—such as incompressibility, zero-flow conditions inside solid regions, and periodicity—encourages the model to learn representations that are physically meaningful rather than dataset-specific. It is important to emphasize that all results presented in the following sections were obtained using the best-performing model, ResNet-101, trained solely on the original dataset. No further training, fine-tuning, or modification was performed for the out-of-distribution samples tested here, and the model had no prior exposure to these novel porous structures. An important question we investigate in the following sections is whether this approach can extend to porous systems with substantially different porosity distributions, obstacle geometries, or boundary conditions, while maintaining predictive accuracy and physical plausibility. To this end, additional porous structures—distinct from those in the original training dataset—were generated to serve as out-of-distribution test cases. The velocity fields predicted by the model for these new samples were then compared with the corresponding LBM solutions to assess the model’s generalization capabilities. Obstacles of different shape Fig. 8LBM computed and neural-network predicted velocity fields for exemplary systems with circular and square obstacles. (a) Circle-only structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=1.0$$\end{document}), (b) Mixed structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.5$$\end{document}), (c) Square-only structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.0$$\end{document}). LBM computed and neural-network predicted velocity fields for exemplary systems with circular and square obstacles. (a) Circle-only structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=1.0$$\end{document}), (b) Mixed structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.5$$\end{document}), (c) Square-only structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}=0.0$$\end{document}). A set of porous structures was generated using randomly placed circles and squares. Obstacle sizes were sampled uniformly between 3 and 8 pixels, and objects were added until the target porosity—randomly chosen between 0.70 and 0.95—was achieved. Each obstacle was a circle with probability \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle}$$\end{document} or a square with probability \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$1 - P_\text {circle}$$\end{document}. Three datasets were created with \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle} = {0.00, 0.50, 1.00}$$\end{document}, corresponding to square-only, mixed, and circle-only configurations. Figure 8 illustrates representative examples of the porous geometries, along with the corresponding LBM solutions and model predictions. Notably, despite the presence of obstacle shapes that differ from those used during model training, the predictions remain closely aligned with the LBM reference solutions, indicating encouraging generalization to this class of modified geometries. As summarized in Table 3, the prediction quality shows a clear dependence on obstacle shape. Specifically, as the proportion of square obstacles increases, the accuracy of the predicted flow fields deteriorates. For the circle-only dataset (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle} = 1.00$$\end{document}), the model achieves performance comparable to that on the original training set, with mean squared errors (MSEs) of the same order of magnitude and high coefficients of determination: \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2 = 0.958$$\end{document} for tortuosity and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2 = 0.994$$\end{document} for permeability. As the proportion of square obstacles increases, all performance metrics gradually degrade; however, even in the most challenging square-only case (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$P_\text {circle} = 0.00$$\end{document}), the model maintains a mean absolute percentage error (MAPE) below 2% for tortuosity and below 6% for permeability, indicating overall robust generalization across varying geometric configurations. Another boundary conditions Fig. 9LBM computed and neural-network predicted velocities fields for exemplary porous systems constrained by two linear obstacles (pipe) at porosities (a) 0.896 and (b) 0.838. Fig. 10The same as Fig. 9 but with linear obstacle placed in the center of the system at porosities (a) 0.927, (b) 0.792. LBM computed and neural-network predicted velocities fields for exemplary porous systems constrained by two linear obstacles (pipe) at porosities (a) 0.896 and (b) 0.838. The same as Fig. 9 but with linear obstacle placed in the center of the system at porosities (a) 0.927, (b) 0.792. Periodic boundary conditions were modified by introducing solid vertical obstacles along the horizontal edges of the porous domain, aligned with the direction of fluid flow. While periodicity is preserved along the horizontal axis, the added boundaries effectively transform the system into an infinite channel or pipe reducing the effect of finite-size anisotropy and an inclination angle between external body force and resulting streamwise velocity21. Importantly, the model was not trained on systems with confined pipe-like geometries or with any constraint that explicitly prohibited flow across the horizontal edges. Figure 9 shows the model’s predictions for three example systems with pipe-like geometries and periodic boundary conditions. Although the model was not explicitly trained on such configurations, it correctly reconstructs the overall flow profile. Importantly, the velocity component perpendicular to the pipe axis remains negligible, demonstrating that the model implicitly respects the physical constraint of unidirectional flow in these settings. An equivalent physical setup can be achieved by placing a single solid barrier horizontally across the center of the sample. Although this configuration is physically analogous to side-wall confinement, it may pose a greater challenge to the model, as it relies more strongly on accurately capturing internal boundary effects rather than edge constraints alone – some exemplary predictions made by the model are shown in Fig. 10. As shown by the performance metrics in Table 3, the model maintains high predictive accuracy for the in-pipe systems, with only a slight reduction in performance compared to the original dataset. The coefficient of determination (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document}) exceeds 0.96 for tortuosity and 0.99 for permeability, while the mean absolute percentage error (MAPE) remains below 0.8% and 4.5%, respectively. These results indicate that the model generalizes well to previously unseen pipe-like geometries and continues to provide accurate predictions for both macroscopic transport properties in these test cases. Generalization to different porosities Fig. 11LBM computed and neural-network predicted velocities fields for exemplary porous systems of lower porosity. Systems have porosities: (a) 0.752, (b) 0.649, (c) 0.512. LBM computed and neural-network predicted velocities fields for exemplary porous systems of lower porosity. Systems have porosities: (a) 0.752, (b) 0.649, (c) 0.512. Three additional datasets were constructed to evaluate the model’s performance on structures with decreasing porosity. The first dataset includes samples with porosity in the range 0.7< φ < 0.8, the second with 0.6< φ < 0.7, and the third with 0.5< φ < 0.6. Each dataset consists of 500 structures generated using the method defined in Equation (9), with the threshold parameter \varepsilon in Equation (10) adjusted to achieve the desired porosity. Figure 11 shows representative LBM solutions and corresponding predictions made by the model, each taken from a randomly selected sample within the respective datasets. Performance metrics for each case are summarized in Table 3. The results reveal a clear dependency of model accuracy on porosity. As porosity decreases, prediction performance deteriorates—as reflected by declining \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2$$\end{document} scores and increasing MAPE for both tortuosity and permeability. Notably, the first dataset (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$0.7\!<\!\varphi \!<\!0.8$$\end{document}) falls within the porosity range used during model training, and the model performs well on these samples. For the second dataset (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$0.6\!<\!\varphi \!<\!0.7$$\end{document}), which lies outside the training distribution, the model still achieves reasonably high accuracy, with \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2 \approx 0.8$$\end{document} for tortuosity and over 0.9 for permeability, while MAPE values remain within acceptable bounds. However, for the most dense structures (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$0.5\!<\!\varphi \!<\!0.6$$\end{document}), a substantial drop in performance is observed across all metrics. As the system approaches the percolation threshold, where critical phenomena begin to dominate transport behavior, the model’s predictive capability breaks down. This highlights a fundamental limitation in the current approach—its reduced transferability in regimes exhibiting extreme porosity and critical connectivity transitions. The purpose of this experiment was to assess out-of-distribution generalization without modifying the training set, rather than to claim reliable performance across all porosity regimes. Low-porosity systems are particularly challenging because transport becomes increasingly controlled by narrow channels, connectivity effects, and proximity to the percolation threshold. The observed deterioration therefore identifies a limitation of the present model. Improving accuracy in this regime would likely require enriching the training data with additional low-porosity samples, for example through adaptive sampling or curriculum learning strategies.Fig. 12LBM computed and neural-network predicted velocities fields for exemplary real Li-O\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} electrodes. Systems have porosities: (a) 0.728, (b) 0.771, (c) 0.802. LBM computed and neural-network predicted velocities fields for exemplary real Li-O\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} electrodes. Systems have porosities: (a) 0.728, (b) 0.771, (c) 0.802. Real porous structures To evaluate the model on highly irregular real geometries, we tested it on the Li-O\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$_2$$\end{document} electrodes dataset (DRP-1129v2 from the4,29,35). This dataset consists of three-dimensional lithium-ion battery electrode microstructures reconstructed from Nano-CT scans, with porosity in the range of approximately 0.73–0.91. These structures differ substantially from the synthetic training data, exhibiting complex, heterogeneous pore networks formed through physical manufacturing processes. In our study, two-dimensional slices were extracted from the volumetric data and used as inputs, with corresponding velocity fields computed using LBM simulations. The results, summarized in Table 3, show that the model maintains reasonable predictive accuracy despite the significant domain shift, with a velocity RMSE of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$6.41 \cdot 10^{-3}$$\end{document} and high agreement for permeability (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2 = 0.986$$\end{document}). At the same time, the accuracy for tortuosity decreases (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$R^2 = 0.798$$\end{document}), reflecting the increased geometric complexity. These findings indicate that the model generalizes to realistic, highly irregular porous structures, while also highlighting the expected degradation in performance outside the training distribution. Figure 12 shows representative LBM solutions and corresponding predictions made by the model. Use of CNN predictions for LBM initialization One of the problems with calculating flows in porous media using the LBM method at extremely high and low porosities is the hindered convergence of the method due to the diffusive nature of momentum transport26. The classic, so-called ’cold’ start of the LBM method involves running the calculation from a zero-velocity field. It turns out that even the imperfect velocity field predictions from neural networks can be an effective remedy to this problem and serve as a starting condition for the LBM method, which adds to the system at the end, smoothing out errors. Fig. 13The graph presents the number of steps of the LBM when starting from the output of the CNN (so-called warm start, x axis) to the number of steps whether the LBM starts from zero (so-called cold start, y axis). All points below the line mean the LBM+CNN procedure gain time. Points are coloured by porosity. The graph presents the number of steps of the LBM when starting from the output of the CNN (so-called warm start, x axis) to the number of steps whether the LBM starts from zero (so-called cold start, y axis). All points below the line mean the LBM+CNN procedure gain time. Points are coloured by porosity. We decided to test this method on samples outside the scope of network learning and perform a test in which a neural network trained on trigonometric data makes predictions of flows in arrangements of overlapping figures, and then feeds such prepared data back to the LBM solver. As a result of starting from an approximate velocity field generated by the CNNs, the LBM method in 90% systems converged faster to the correct solution (see Fig. 13), compared to the solver that started from a zero velocity field. The median reduction in the number of iterations was approximately 50%, meaning that in half of the tested systems the reduction was greater than 50%, and in half it was smaller. The interquartile range, given by \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$Q_1 \approx 22\%$$\end{document} and \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$Q_3 \approx 68\%$$\end{document}, indicates that 50% of the systems exhibit reductions within this interval. A bootstrap procedure (based on repeated resampling of the dataset and recomputation of the median) yields a 95% confidence interval of approximately \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$[46\%, 54\%]$$\end{document}, which quantifies the statistical uncertainty of the estimated median reduction and shows that this value is stable across the dataset. A paired Wilcoxon signed-rank test confirms that this improvement is highly statistically significant (\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$p\approx 4 \times 10^{-70}$$\end{document}). With the additional observation that the trained neural network produces results orders of magnitude faster, these findings provide hope for the practical application of our results. Computational time comparison Neural network enables fast inference. The average prediction time is just 5 ms per structure on GPU (NVIDIA GeForce RTX 4090), while on a CPU (AMD Ryzen 9 5950X) it averages 190 ms. Importantly, the inference time remains consistent regardless of porosity or other structural properties. In comparison, performing LBM calculations the same set of structures requires an average of 560 ms per structure (utilizing the same CPU and the same number of cores). It should be noted that this comparison concerns inference only. Training is computationally expensive but performed once and amortized over repeated predictions. Conclusions We have presented a complete pipeline for predicting pore-scale fluid flow through porous media using physics-informed convolutional neural networks. The main contribution of this work is the construction and evaluation of a custom loss function tailored to this problem, combining velocity-field reconstruction with penalties for flow inside solid regions, incompressibility, periodic consistency, and tortuosity matching. Our analysis of weights for loss function components showed complex dependency of each part on the overall error of fluid flow predictions with the winning combination of \documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$\alpha =5, \beta =1, \gamma =0.1$$\end{document} and δ =0.01. We suggest there is still space to optimize both the choice of the neural network architecture (ResNet-101 in our case), its size and combination of loss weights. Future work may further improve performance through systematic architecture search, automated loss-weight optimization, or adaptive sampling of challenging regimes. The key finding of this work, however, is generalization. While the model is trained on a specific dataset of porous structures, the underlying architecture and training methodology are designed to be broadly applicable to a wide class of similar physical systems. The use of convolutional neural networks allows the model to learn spatially invariant features, enabling it to generalize to geometries and flow patterns that differ from those seen during training. Moreover, the inclusion of physical constraints in the loss function-such as incompressibility, zero-flow conditions inside solid regions, and periodicity-encourages the model to learn representations that are physically meaningful rather than overly dataset-specific. As a result, the trained model can be adapted to other porous systems, including those with different porosity distributions, obstacle shapes, or boundary conditions, provided that they share the same fundamental flow characteristics. For significantly different domains, transfer learning or fine-tuning on a small number of new samples may be sufficient to adapt the model while retaining much of the learned structure. Future work could explore this direction in more detail by systematically evaluating the model’s performance on out-of-distribution datasets or synthetic benchmarks with known analytical properties. Despite the encouraging results, several limitations remain. The present implementation is restricted to two-dimensional, fixed-resolution geometries, and its accuracy decreases for strongly out-of-distribution cases, such as low-porosity structures near connectivity transitions. However, the approach is, by design, naturally extendable to three-dimensional systems: the same encoder–decoder concept, backbone-based architecture, and physics-informed loss strategy can be retained, with two-dimensional convolutional operations replaced by their three-dimensional counterparts. Moreover, the physical constraints are imposed through penalty terms and are therefore only approximately enforced. Future work should explore full three-dimensional implementations, transfer learning for experimentally obtained microstructures, systematic optimization of loss weights, and possible integration with other physics-informed or operator-learning frameworks, such as PINNs, Fourier Neural Operators, or DeepONets. Supplementary Information Supplementary Information. Supplementary Information.