Evolving dunes under flow reversals: from an initial heap toward an inverted dune