Towards a multiscale analysis of periodic masonry brickwork: A FEM algorithm with damage and friction