An Energy-Based Interface Detection Method for Phase Change Processes in Nanoconfinements