An approach to freely combining 3D discrete and finite element methods. A freely combined three-dimensional (3D) discrete and finite element (FE) algorithm is developed. The algorithm, which is based on the method combining the discrete element (DE) and the corresponding node of the FE proposed by {it Z. Lei} and {it M. Zang} [Comput. Mech. 46, No. 4, 609--619 (2010; Zbl 05774049)], treats each combined point on the facet of the FE as the corresponding node of the method. This new algorithm includes global search, local search and the combined force calculation processes. The combined force between the DE and FE is processed by using a penalty function method. Following that, the corresponding numerical code is implemented into the in-house developed code, a dynamic explicit DE/FE code named CDFP. To test the accuracy of the proposed algorithm and the corresponding numerical code, the vibration process of two beams under dynamic force and the vibration process of two glass plates under impact of rigid sphere are simulated in elastic range. By comparing the results with those calculated by using LS-DYNA, it is shown that they agree with each other very well.