A scheme is described for performing molecular dynamics simulations on polymers under nonperiodic, stochastic boundary conditions. It has been designed to allow later the embedding of a particle domain treated by molecular dynamics into a continuum environment treated by finite elements. It combines, in the boundary region, harmonically restrained particles to confine the system with dissipative particle dynamics to dissipate energy and to thermostat the simulation. The equilibrium position of the tethered particles, the so-called anchor points, are well suited for transmitting deformations, forces and force derivatives between the particle and continuum domains. In the present work the particle scheme is tested by comparing results for coarse-grained polystyrene melts under nonperiodic and regular periodic boundary conditions. Excellent agreement is found for thermodynamic, structural, and dynamic properties.