The presented work focuses on the numerical modeling of the solidification process, with a particular emphasis on two significant physical phenomena: shrinkage cavities and grain formation, which are influenced by the cooling rate. Cooling rate plays a crucial role in determining grain size and casting defects. Higher cooling rates result in finer grain structures, while slower rates promote larger grains. During solidification, atoms arrange into crystalline structures, forming grains. The cooling rate affects grain growth kinetics. Faster rates lead to smaller grains due to limited atomic diffusion, while slower rates allow for larger grain growth. Shrinkage cavities, localized regions in solidified material, form due to volume contraction during cooling, negatively impacting mechanical properties. In this paper, the main assumptions of the mathematical and the numerical model are presented. The numerical description of the problem is based on the finite element method, which is a widely used numerical technique for solving complex physical problems. The algorithm for the shrinkage cavity creation process is described, and an original computer program was developed using the numerical model. The computer simulation was conducted to obtain distributions of temperature, grain size, as well as the position and shapes of the shrinkage cavities.