Comprehensive physical modeling of forming and switching operations in HfO2 RRAM devices