A Theoretical Model of Pattern Formation in Coral Reefs