Working function of mainPBCMovingFrame.cpp