normalization (average zero) condition for Neumann problem did not work
Hello,
I have a simple (solvable) Poisson-Neumann problem. I solved it and made an a posteriori 'normalization', by subtracting the average of the solution. But the function still has no zero average.
Below the code, thanks!!!
from dolfin import *
# Create mesh and define function space
mesh = UnitSquare(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)
n=FacetNormal(mesh)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression(
g = Expression(
h = Expression("x[0]")
a = inner(grad(u), grad(v))*dx
L = f*v*dx+
# Compute solution
u = Function(V)
solve(a == L, u)
print assemble(u * dx, mesh=mesh)
u_array = u.vector().array() - assemble(u * dx, mesh=mesh)
u.vector()[:] = u_array
average_u = assemble( u * dx, mesh=mesh)
print average_u
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Daniel Bare for more information if necessary.