this is an example of the code I want to implement on FreeFem++
local function func_kappa(x,y)
ni=27; nj=27;
-- (not so) aligned to the mesh
r1=1./32.*3./ni ; k1=1.; k3=1.; -- radius and kappa of the inner squared cell
r2=1./16.*3./ni ; k2=10000.0; -- radius and kappa of the outer square cell
for j=0,(nj-1) do
yj=(2.*j+1.)/(2.*nj);
for i=0,(ni-1) do
xi=(2.*i+1.)/(2.*ni);
if ( (x>=(xi-r1)) and (x<=(xi+r1)) and (y>=(yj-r1)) and (y<=(yj+r1))) then
return k1;
end
if ( (x>=(xi-r2)) and (x<=(xi+r2)) and (y>=(yj-r2)) and (y<=(yj+r2))) then
return k2;
end
end
end
return k3; -- kappa of the embedding matrix
end
kappa = func_kappa,
The technics is very slow, you function kappa is defined by
with a Gh grid (x_i,y_i) of size ni, nj you want
let us call dist00(x,y) is the minimal distance of (x,y) the the point of the grid in norme infini
now the fonction is just k3+(dist00(x,y) < r1)(k1-k3) + (dist00(x,y) < r2)(k2-k1-k3)