Hello,
I want to know if it is possible, using the solution (u) with a source term (f) of the poisson equation, to measure that solution on the boundaries instead of an “inner” measure.
It would be similar to the Electrical Impedance Tomography measure, where we have eletroces on the boundary measuring the solution (u) :
Here is my code inspired mainly from the dolfin example Pure neumann poisson :
from dolfin import *
from mshr import *
resolution = 15
domain_geometry = Circle(dolfin.Point(0.5, 0.5), 0.5+0.01)
mesh = generate_mesh(domain_geometry, resolution)
# Build function space with Lagrange multiplier
P1 = FiniteElement("Lagrange", mesh.ufl_cell(), 1)
R = FiniteElement("Real", mesh.ufl_cell(), 0)
W = FunctionSpace(mesh, P1 * R)
# Define variational problem
(u, c) = TrialFunction(W)
(v, d) = TestFunctions(W)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
g = Constant("0.0")
a = (inner(grad(u), grad(v)) + c*v + u*d)*dx
L = f*v*dx + g*v*ds
# Compute solution
w = Function(W)
solve(a == L, w)
(u, c) = w.split()
# Save solution in VTK format
file = File("neumann_poisson.pvd")
file << u
Another code I did based on this poisson example Poisson equation :
from dolfin import *
from mshr import *
# Create mesh and define function space
resolution = 15
domain_geometry = Circle(dolfin.Point(0.5, 0.5), 0.5+0.01)
mesh = generate_mesh(domain_geometry, resolution)
V = FunctionSpace(mesh, "Lagrange", 1)
def boundary(x, on_boundary):
return on_boundary
# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression("10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)", degree=2)
g = Constant(0.0)
a = inner(grad(u), grad(v))*dx
L = f*v*dx + g*v*ds
# Compute solution
u = Function(V)
solve(a == L, u, bc)
# Save solution in VTK format
file = File("poisson.pvd")
file << u
Thank you for your help.
Great day to you