A numerical study of thermal and chemical structures at the core-mantle boundary