Modeling of hysteresis in multidomain nanostructures