This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Inconsistent behaviour in intersected_cells() method

0 votes

Hello,

I am trying to assemble a point source load vector manually since vector elements aren't supported by the PointSource() class.

As a first pass, I will need to get the cell enclosing the source point. I have found the intersect method, but every time I run the following code, I get a different answer.

from dolfin import *
mesh = Mesh("wholespace_mesh.xml")
source_pt= Point(0.0,0.0,0.0)
print intersect(mesh,source_pt).intersected_cells()

Here is a link to the mesh file that I'm using:
https://www.dropbox.com/s/s98gyuc4u9t91f0/wholespace_mesh.xml?dl=0

asked Apr 1, 2016 by brk888 FEniCS Novice (990 points)

Hi,
i don't know why happens what you described above, but if you want to apply PointSource to a VectorFunctionSpace consider this:

from dolfin import *

mesh = UnitSquareMesh(10, 10, "crossed")
V = VectorFunctionSpace(mesh, "CG", 1, dim=2)

u = TrialFunction(V)
v = TestFunction(V)
f = Constant((0.0, 0.0))

a = inner(u, v)*dx
L = inner(f, v)*dx

A, b = assemble_system(a, L)

# Create and apply PointSource to the lhs (to the first component)
source_0 = PointSource(V.sub(0), Point(0., 0.), 100)
source_0.apply(b)

# Create and apply PointSource to the lhs (to the second component)
source_1 = PointSource(V.sub(1), Point(0., 0.), 100)
source_1.apply(b)
...