I want to solve the PDE
$$ -\nabla (a \nabla y) = 0 \text{ on } \Omega $$
$$ a\frac{\partial y}{\partial \nu} = g $$
Now the problem is, that the solution for this PDE is if and only if unique, if there is a requirement for the mean value. I want the mean value for the solution to be zero.
Now if I use
y = y - assemble(y*dx)
the mean value of y is close to zero.
Is this the right way to do this? It feels strange..
Code
phi_init = Constant(0)
phi = interpolate(phi_init, V)
g_h = Expression("(near(x[0], 1) && ! near(x[1], 0))|| near(x[1], 1) ? k0 : k1", k0=-0.5, k1= 0.5, degree= 1)
a_phi = a_1 * (1 + phi)/2 + a_2 * (1 - phi)/2
Define variational problem
y = TrialFunction(V)
v = TestFunction(V)
a = a_phi(inner(grad(y), grad(v)))dx
L = g_hvds
Compute solution
y = Function(V)
solve(a == L, y)
#y = y - assemble(y*dx)