Set material in mesh.elements

I have a question about setting material,
Sometime i want to set a specific material in each element of a mesh ( for example for elemnts x>0 … )
In some solvers we have this :
for a region n
I do get_dof_on_region(n)
then i apply what i want in each dof