Entanglement generation and dynamics for a Bose–Hubbard model in a double-well potential