Layered Ising model: Spontaneous magnetization under influence of grain boundaries and surfaces