Regions permittivity

Hello colleagues,

I have a domain with two different regions ( region 1 and region 2). I need to define a function for permittivity so that in region 1 it considers the permittivity of air but in the region 2 another permittivity.
Does this command is proper to get this goal:

real ep = 12;
real er= 1;
func erregion = (region == 1 ? er : ep);

thanks for your help.

func erregion = er*(region == 1) + ep*(region==2);

thanks, but I have tried this command before, but it doesn’t give me the answer…
the one that I suggested is wrong?

Use a piecewise constant function.

fespace Ph(Th, P0);
Ph erregion = (region == 1 ? er : ep);

I get error via this command;
can you please help me in defining proper command for permittivity of a domain with 2 regions ? Its like considering a dielectric object in free space.

I’ve tried my previous script, it works as expected, assuming you have properly defined the mesh Th of course.

Thanks for your quick response. I changed sth and it works now.
The problem by defining as func erregion = (region == 1 ? er : ep); was that when I changed it to " func erregion = (region == 2 ? ep : er); " , the solotion became different. I guess it was just considering the first permittivity not other one.

May you tell me please what was wrong with difining as func ?

thanks alot.

remark, in this examples you can do is you have only 2 regions 1 and 2.

real[int] ee=[0.,1.,12.] ;
func erregion = ee[region];