//  created with md2edp examples/examples/condensor.md
int C1 = 1; // labels to identify the 2 plates C1,C3 and the containner C2
int C2 = 2; // could be any number
int C3 = 3;
// Mesh
border C0(t=0, 2*pi){x=5*cos(t); y=5*sin(t); label=C2;}

border C11(t=0, 1){ x=1+t;  y=3;      label=C1;}
border C12(t=0, 1){ x=2;    y=3-6*t;  label=C1;}
border C13(t=0, 1){ x=2-t;  y=-3;     label=C1;}
border C14(t=0, 1){ x=1;    y=-3+6*t; label=C1;}

border C21(t=0, 1){ x=-2+t; y=3;      label=C3;}
border C22(t=0, 1){ x=-1;   y=3-6*t;  label=C3;}
border C23(t=0, 1){ x=-1-t; y=-3;     label=C3;}
border C24(t=1, 0){ x=-2;   y=-3+6*t; label=C3;}

mesh Th=buildmesh(C0(50)
    +C11(5)+C12(20)+C13(5)+C14(20)
    +C21(5)+C22(20)+C23(5)+C24(-20));
plot(Th, wait=true);
fespace Vh(Th, P1);
Vh u, v;

// Problem
solve a(u, v)
    = int2d(Th)(
          dx(u)*dx(v) + dy(u)*dy(v)
    )
    + on(C1, u=1) + on(C2, u=0) + on(C3, u=-1);

// Plot
plot(u, value=true, ps="condersor.ps");
