# Mixed Boundary Condition and Periodic System

Hi all,

I am interested in solving the Laplace equation in 2D with periodic boundary conditions and a mixed boundary condition on an inner circle.

The mixed boundary condition is

$$n \cdot \grad u = cos(x)$$

Where n is the normal to the circle.

I know that if you have a Neumann and periodic boundary conditions, you need a lagrange multiplier. I’m not certain how mixed BCs work for this.

My problem is that the solution is always zero everywhere, even though this does not satisfy the mixed boundary condition.

// Make the mesh, a circle in a box.
real a = 1;
border bordero1(t=-0.5, 0.5){x=a*t; y=-a/2; label=1;}//normal faces up
border bordero2(t=-0.5, 0.5){x=a/2; y=a*t; label=2;}//normal faces left
border bordero3(t=-0.5, 0.5){x=a*t; y=a/2; label=3;}//normal faces down
border bordero4(t=-0.5, 0.5){x=-a/2; y=a*t; label=4;}//normal faces right
border i1(t=0, 2.*pi){x=0.25*cos(t); y=-0.25*sin(t); label=7;}
mesh Th = buildmesh(bordero1(20) + bordero2(20) + bordero3(-20)  + bordero4(-20) + i1(50));

fespace Vh(Th,P1,periodic=[[1, x], [3, x], [2, y], [4, y]]);     // P1 FE space
int n = Vh.ndof;
int n1 = n+1;

Vh uh,vh;              // unknown and test function.
func f=0;                 //  right hand side function

varf va(uh,vh) =                    //  definition of  the problem
int2d(Th)( dx(uh)*dx(vh) + dy(uh)*dy(vh) ) //  bilinear form
+int1d(Th,7)(cos(x)*vh) // Mixed boundary condition.
;
varf vL(uh,vh)=  int2d(Th)( f*vh )  ;
varf vb(uh,vh)= int2d(Th)(1.*vh);

matrix A=va(Vh,Vh);

real[int] b(n);
b = vL(0,Vh);

real[int]  B = vb(0,Vh);
// the block matrix

matrix AA = [ [ A ,  B ] ,
[ B', 0 ] ] ;

real[int]  bb(n+1),xx(n+1),b1(1),l(1);
b1=0;
// build the block rhs
bb = [ b, b1];
set(AA,solver=sparsesolver);
xx = AA^-1*bb; // solve the linear system

[uh[],l] = xx;  // set the value
cout << " l = " << l(0) <<  " ,  b(u,1)  =" << B'*uh[]  << endl;

plot(uh,wait=1);