Towards a Multiscale Analysis of Periodic Masonry Brickwork: a FEM algorithm with damage and friction