Hello,
I am trying to solve a homogeneous (insulated) Poisson equation similar to the example real_function_space.py on scifem . In my example the both the g
and h
functions are identically zero and the function f
is a sum of two Dirac delta functions.
I am trying to model my solution approach on the scifem example point_source.py.
However, I cannot merge the two approaches together. I must be missing some subtle point.
From the real_function_space.py
example I have the variational problem
a00 = ufl.inner(ufl.grad(u), ufl.grad(du)) * ufl.dx
a01 = ufl.inner(lmbda, du) * ufl.dx
a10 = ufl.inner(u, dl) * ufl.dx
L0 = ufl.inner(f, du) * ufl.dx
L1 = ufl.inner(zero, dl) * ufl.dx
a = dolfinx.fem.form([[a00, a01], [a10, None]])
L = dolfinx.fem.form([L0, L1])
Next, following the point_source.py
example, I created the source and sink points as follows:
# We are now ready to apply the point source.
# First, we create the right hand side vector for the problem, and initialize it as zero.
bp = dolfinx.fem.Function(V)
bp.x.array[:] = 0
# Secondly we define the point sources we want to apply.
#
# ```{warning}
# Note that if running in parallel, we only supply the points on a single process.
# The other process gets an empty array.
# ```
geom_dtype = mesh.geometry.x.dtype
# firstly the source point
if mesh.comm.rank == 0:
points = np.array([[0.475, 0.5, 0]], dtype=geom_dtype)
else:
points = np.zeros((0, 3), dtype=geom_dtype)
# Next, we create the point source object and apply it to the right hand side vector.
gamma = 1.
point_source = scifem.PointSource(V, points, magnitude=gamma)
point_source.apply_to_vector(bp)
# now the sink point
if mesh.comm.rank == 0:
points = np.array([[0.525, 0.5, 0]], dtype=geom_dtype)
else:
points = np.zeros((0, 3), dtype=geom_dtype)
gamma = -1.
point_source = scifem.PointSource(V, points, magnitude=gamma)
point_source.apply_to_vector(bp)
My problem is that I can’t work out how to incorporate the information in bp
into the form L
.
I did manage to work out that I could use this definition of bp
as f
in the expression for L0
above and everything works fine. However, I didn’t think that this was the way the point_source
function was supposed to work.
I would be grateful if someone could provide me with some insights as to the points I am missing or correct the mistakes that I have made.
BTW, I am using fenicsx 0.9.0 and scifem 0.3.0.
Thank you very much for taking the time read this long message. Any insights would be much appreciated.
Peter.