I use several different groupings at the beginning of the semester so people can see who they might work well with. After 3 or 4 weeks, I try to set groups that will stay together for the rest of the semester. Since I wanted to encourage cooperative studying outside of class, I used the same groups all semester. For the mature students this was effective. Occasionally, dysfunctional groups have been reconfigured during the semester.
Groups tend to coalesce when things go well.
When not, some group is dysfunctional and its members will probably not work too well in another group either. Once I forcibly broke the groups up mid-way through the semester, but no one liked the process. In most of my classes the groups exist for the duration of a project or assignment and then break up and reform for the next project or assignment. I let them choose their own groups. Mid-semester, students individually evaluate how well their group is operating.