// meditddm.edp
load "medit"

/********************************************
 Initial Problem:
Resolution of the following EDP:
$- \Delta u = f$ on   $\Omega =\{ (x,y) |  1 \leq sqrt(x^2+y^2) \geq 2}$
$- \Delta u = f1$ on  $\Omega_{1} =\{ (x,y) |  0.5 \leq sqrt(x^2+y^2) \geq 1.}$
$u = 1$ on $\Gamma$  +  Null Neumman condition on $\Gamma_{1}$ and on $\Gamma_{2}$	
We find the solution $u$ in solving two EDP defined on domain $\Omega$ and $\Omega_{1}$
This solution is vizualize with ffmedit 
*********************************************/
verbosity=3;

border Gamma(t=0,2*pi){x=cos(t); y=sin(t); label=1;};
border Gamma1(t=0,2*pi){x=2*cos(t); y=2*sin(t); label=2;};
border Gamma2(t=0,2*pi){x=0.5*cos(t); y=0.5*sin(t); label=3;};

// construction of mesh of domain $\Omega$
mesh Th=buildmesh(Gamma1(40)+Gamma(-40)); 

fespace Vh(Th,P2);
func f=sqrt(x*x+y*y);
Vh us,v;
macro Grad2(us) [dx(us),dy(us)]  // EOM

problem Lap2dOmega(us,v,init=false)=int2d(Th)(Grad2(v)' *Grad2(us)) - int2d(Th)(f*v)+on(Gamma,us=1) ;
//  Resolution of EDP defined on the domain $\Omega$
// $- \Delta u = f$ on $\Omega$ 
//      $u = 1$  on $\Gamma
//   + Null Neumann condition on $\Gamma_{1}$
Lap2dOmega;

// construction of mesh of domain $\Omega1 =\{ (x,y) |  0.5 \leq sqrt(x^2+y^2) \geq 1.}$
mesh Th1=buildmesh(Gamma(40)+Gamma2(-40));

fespace Vh1(Th1,P2);
func f1=10*sqrt(x*x+y*y);
Vh1 u1,v1;
macro Grad21(u1) [dx(u1),dy(u1)]  // EOM

problem Lap2dOmega1(u1,v1,init=false)=int2d(Th1)(Grad21(v1)' *Grad21(u1)) - int2d(Th1)(f1*v1)+on(Gamma,u1=1) ;
//   Resolution of EDP defined on the domain $\Omega_{1}$
// $- \Delta u = f1$ on $\Omega_{1}$ 
//      $u = 1$ on $\Gamma$
//   + Null Neumann condition on $\Gamma_{2}$
Lap2dOmega1; 

// vizualisation of solution of the initial problem
medit("solution",Th,us,Th1,u1,order=1,meditff="ffmedit",save="testsavemedit.solb",wait=1);	
