Selective laser melting (SLM) of the powder bed is one of the promising techniques for additive manufacturing of metals. Laser powder bed fusion is an inherently multiscale process and calls for an approach using multiple coupled models. In this work we developed the macroscopic thermodynamic model of SLM involving sequential deposition of powder layers on the plate followed by their melting. The accompanying processes of heat transfer, Marangoni convection and evolution of the melt free surface are included in the model. This model gives self-consistent consideration to the distributions of temperature and melt velocities during SLM. Modeling of the free surface evolution is performed by the VOF method. For numerical calculations the program software has been developed and tested. Its realization involved the C++ class library of numerical modeling OpenFOAM 2.4. Thermal flows, melt velocities and resulting profiles of sintered layers depending on the SLM parameters (beam power, scanning speed, powder layer) have been obtained. The calculated distributions demonstrate the development of widespread defects in SLM, e.g. residual porosity inside the solidified metal in the form of gas bubbles, incomplete penetration and bonding of the substrate metal and the particles. The results show that capillary effects play an important role in the liquid phase dynamics and, correspondingly, in the formation of final profile and structure of the deposed layer. The macro-level data (heat removal rate, cooling rate) can be used as the input parameters in boundary condition formulation for solving the microstructure evolution and the residual stress formation problems during SLM.