Modeling resistive switching materials and devices across scales