Constructing microstructures of poly- and nanocrystalline materials for numerical modeling and simulation