# Specifying the source term in poissons equation from another solution

**URL:** <https://fenicsproject.discourse.group/t/specifying-the-source-term-in-poissons-equation-from-another-solution/19595>\
**Category:** dolfinx\
**Created:** [March 11, 2026, 2:50am UTC](https://fenicsproject.discourse.group/t/specifying-the-source-term-in-poissons-equation-from-another-solution/19595 "2026-03-11T02:50:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [March 11, 2026, 6:03am UTC](https://fenicsproject.discourse.group/t/specifying-the-source-term-in-poissons-equation-from-another-solution/19595/2 "2026-03-11T06:03:44Z")

</div>

> [@mdbarrett](#):
>
> What I am not overly sure about is the form/type that f has.

`f` is a symbolic expression in your code (ufl expression). When you call `dolfinx.fem.form` or `assemble_vector` this is turned in to an evaluation of the symbolic expression at the quadrature points of your rhs integral and accumulated into the global vector, doing exactly what you set out to do.

> [@mdbarrett](#):
>
> Well I am at it - how do I get the array of points that goes with f?

You do not need the array to solve the problem. However if you would like to inspect f, you cal use dolfinx.fem.Expression:

```python
f_compiled = dolfinx.fem.Expression(f, points_in reference_element)
Values = f_compiled.eval(mesh, np.arange(num_cells_local, dtype=np.int32))

```

As discussed in

> **[dolfinx.fem.Expression - Function and expression evaluation — FEniCS Workshop](https://jsdokken.com/FEniCS-workshop/src/deep_dive/expressions.html#evaluate-a-ufl-expression)**
>
> In this section, we will look at how we can extract data once we have solved our variational problem. To make this section concise, we will use functions with expressions that are already defined (not through a PDE), but through interpolation.

> [@How to estimate the gradient along the vector between the two centers of adjacent cells?](https://fenicsproject.discourse.group/t/how-to-estimate-the-gradient-along-the-vector-between-the-two-centers-of-adjacent-cells/17990/2):
>
> Here is an example of how to get the midpoints, and the values of u at the midpoints: from mpi4py import MPI import dolfinx import numpy as np mesh = dolfinx.mesh.create\_unit\_square(MPI.COMM\_WORLD, 10, 10) V = dolfinx.fem.functionspace(mesh, ("CG", 2)) u = dolfinx.fem.Function(V) u.interpolate(lambda x: x[0] + x[1] \*\* 2) Q = dolfinx.fem.functionspace(mesh, ("DG", 0, (mesh.geometry.dim,))) q = dolfinx.fem.Function(Q) q.interpolate(lambda x: x[: mesh.geometry.dim]) num\_cells\_local = ( mes…

---

_[View the full topic](https://fenicsproject.discourse.group/t/specifying-the-source-term-in-poissons-equation-from-another-solution/19595)._
