# Pointsource on specific points python

**URL:** <https://fenicsproject.discourse.group/t/pointsource-on-specific-points-python/1967>\
**Category:** Uncategorized\
**Created:** [November 25, 2019, 11:20am UTC](https://fenicsproject.discourse.group/t/pointsource-on-specific-points-python/1967 "2019-11-25T11:20:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![odysgros](https://avatars.discourse-cdn.com/v4/letter/o/ba9def/32.png) [@odysgros](https://fenicsproject.discourse.group/u/odysgros)\
**Post date:** [November 25, 2019, 11:20am UTC](https://fenicsproject.discourse.group/t/pointsource-on-specific-points-python/1967/1 "2019-11-25T11:20:58Z")

</div>

Hello, I want to ask how can i set values at specific points on boundary in python. I have a 3d box as mesh. Thank you !!!

---

<div class="post-metadata">

**Author:** ![kamensky](https://avatars.discourse-cdn.com/v4/letter/k/e95f7d/32.png) [@kamensky](https://fenicsproject.discourse.group/u/kamensky)\
**Post date:** [November 25, 2019, 3:21pm UTC](https://fenicsproject.discourse.group/t/pointsource-on-specific-points-python/1967/2 "2019-11-25T15:21:30Z")

</div>

Take a look at the following minimal example:

```python
from dolfin import *
N = 5
mesh = UnitSquareMesh(2*N,2*N)
V = FunctionSpace(mesh,"CG",1)

# Setting a value using a PointSource, as suggested in the post title:
p = PointSource(V,Point(1-DOLFIN_EPS,0.5),1.0)
p.apply(u.vector())

# Can also set using a BC, which has the advantage of being convenient
# for applying a constraint during a solve. The trick is that you need to
# pass the optional argument "pointwise".
bc = DirichletBC(V,Constant(1.0),"near(x[0],0)&&near(x[1],0.5)","pointwise")
u = Function(V)
bc.apply(u.vector())

# Note: In both cases, the point where the value is set needs to correspond to
# a DoF of the FunctionSpace.  

# Check: Function is set to 1 at both points:
from matplotlib import pyplot as plt
plot(u)
plt.show()

```

---

<div class="post-metadata">

**Author:** ![odysgros](https://avatars.discourse-cdn.com/v4/letter/o/ba9def/32.png) [@odysgros](https://fenicsproject.discourse.group/u/odysgros)\
**Post date:** [November 27, 2019, 1:30pm UTC](https://fenicsproject.discourse.group/t/pointsource-on-specific-points-python/1967/3 "2019-11-27T13:30:12Z")

</div>

Thank you very much !!!
