Tengyuan Hao, Zubaer M. Hossain
• A transformer model, whose self-attention mechanism captures the non-local physics of crack-pore interactions, accurately predicts fracture paths in porous media. • A variable-stiffness boundary condition (VSBC) enables stable crack growth simulation, yielding consistent, high-fidelity training data with minimal computational overhead. • A physically guided crack-tip domain extraction strategy focuses learning on essential microstructural features, reducing data requirements by orders of magnitude without sacrificing predictive fidelity. • The model exhibits robust compositional generalization, accurately predicting crack paths in pore configurations and local porosity levels far beyond the training distribution (up to 17 % local porosity). • The integrated FEM-ML framework serves as a rapid surrogate to finite-element analysis, accelerating the in silico design and optimization of microstructures for fracture-resistant materials. Predicting crack paths in brittle porous media with geometric or material discontinuities remains a central challenge in fracture mechanics. In this work, we present a machine learning (ML) framework trained on finite element method (FEM) simulation data to predict crack propagation in a heterogeneous medium containing a random distribution of discontinuities or defects. Our findings underscore the necessity of constructing high-quality training datasets from accurate FEM results to capture crack paths reliably. To support this, we used a special boundary condition termed as the ‘variable-stiffness boundary condition’, built on the so-called surfing boundary condition, that stabilizes crack growth even in densely distributed pores or discontinuities. The framework enables consistent data extraction for model training. This targeted dataset generation approach not only improves the relevance of the training data but also reduces the computational cost of the learning process. The trained ML model demonstrates high accuracy in predicting crack trajectories across various distributions of defects and remains robust even beyond the porosity levels used during training. These results highlight the potential of integrating ML with fracture mechanics to enable efficient and precise crack path prediction in porous media, advancing the design of next-generation composite materials.