In many marriages in modern times, a couple will sign a prenuptial agreement that outlines what should happen if they (chas v'shalom) get divorced. Among the things commonly agreed upon in a prenuptial agreement is what should happen with the children in such a case.
If there is no prenuptial agreement, and a divorce is being litigated in a secular court, the judge uses some method to determine who should get custody of the children (I don't know what that method is. I don't think it's important for this question). Is there some kind of method that a beit din would follow in a similar situation to determine how custody of children should be assigned in a Jewish divorce?