Phase-field modeling of pores and precipitates in polycrystalline systems