Generalized N-body problems: a framework for scalable computation