Surface energy of a nematic liquid crystal in contact with structured surfaces