How can I convert it to new Dolfinx Fenicsx?
Without writing what error you are getting with the code above, and what version of FEniCSx you are using, it is unlikely that you will get an answer to this question.
Thank you.
Error is:
TypeError Traceback (most recent call last)
Cell In[105], line 10
7 V = dolfinx.fem.FunctionSpace(domain, (“CG”, 2))
9 point = np.array([[0.2, 0.3, 0]])
—> 10 bb = dolfinx.geometry.BoundingBoxTree(domain, tdim)
11 bbox_collisions = dolfinx.geometry.compute_collisions(bb, point)
12 cells = dolfinx.geometry.compute_colliding_cells(domain, bbox_collisions, point)
TypeError: BoundingBoxTree.init() takes 2 positional arguments but 3 were given
I am using Dolfinx 0.8 and Fenicsx 0.7
Please note that your specification of versions doesn’t make sense, as
DOLFINx and FEniCSx represents the same package.
Here is an updated example for v0.7.x
from mpi4py import MPI
import dolfinx
import ufl
import numpy as np
domain = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 1, 1)
tdim = domain.topology.dim
V = dolfinx.fem.FunctionSpace(domain, ("CG", 2))
point = np.array([[0.2, 0.3, 0]])
bb = dolfinx.geometry.bb_tree(domain, tdim)
bbox_collisions = dolfinx.geometry.compute_collisions_points(bb, point)
cells = dolfinx.geometry.compute_colliding_cells(
domain, bbox_collisions, point)
cell = cells.links(0)[0]
cmap = domain.geometry.cmaps[0]
geom_dofs = domain.geometry.dofmap[cell]
x_ref = cmap.pull_back(point, domain.geometry.x[geom_dofs])
n = ufl.as_vector([0.1, 0.2])
expr = ufl.inner(ufl.grad(ufl.TestFunction(V)), n)
E = dolfinx.fem.Expression(expr, x_ref)
grad_u_at_x_ref = E.eval(domain, [cell])
print(
f"Cell: {cell}, Point: {point}, x_ref: {x_ref}, grad(u)*n {grad_u_at_x_ref}")