Dear all,
I am trying to compute the values of a function on the top boundary of my domain by means of the following function, where I have used some snippets of code provided in the discourse group for previous questions in this topic. This function is a method of an object PC in which I define the whole problem.
def compute_values_on_top(self, u, p):
domain, facet_markers = PC.domain, PC.facet_markers
boundary_facets = facet_markers.indices[facet_markers.values == PC.facets_top_tag]
bb_tree = dolfinx.geometry.bb_tree(domain, domain.topology.dim, padding=10)
domain.topology.create_connectivity(domain.topology.dim-1, domain.topology.dim)
boundary_vertices = dolfinx.mesh.compute_incident_entities(domain.topology, boundary_facets, domain.topology.dim-1, 0)
boundary_coordinates = []
for ind in boundary_vertices:
boundary_coordinates.append(domain.geometry.x[ind].tolist())
l = list(np.argsort(np.array(boundary_coordinates)[:,0]).astype(np.int32))
boundary_coordinates = np.array(boundary_coordinates)[l]
# Points on boundary
points = np.array(boundary_coordinates).transpose()
cells = []
points_on_proc = []
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, points.T)
colliding_cells = dolfinx.geometry.compute_colliding_cells(domain, cell_candidates, points.T)
for i, point in enumerate(points.T):
if len(colliding_cells.links(i)) > 0:
points_on_proc.append(point)
cells.append(colliding_cells.links(i)[0])
# The function continues but the rest of the code is non relevant and has been ommitted.
I know this is not a MWE but it is difficult to provide one in this case since the problem I am facing deals with a domain whose upper boundary is moving and the complete code to reproduce it is very long. In fact, I have removed some non relevant part of the code from this function to make it more readable.
When I run the whole code, the following error is thrown after 50 time iterations using a very thin mesh. I do not see where the problem is as I can run the code perfectly for the first 49 time iterations. Moreover, if I use coarse meshes I can run the code during any number of time iterations.
Plant_cell_model.py", line 773, in time_iterator
values_inter_bnd = PC.compute_values_on_top(u, p)
File "/data/Nextcloud/Universidad/Investigacion/Papers/Flow plant cell model/Plant_cell_model/src/Plant_cell_model.py", line 458, in compute_values_on_top
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, points.T)
File "/home/danielacos/micromamba/envs/fenicsx/lib/python3.13/site-packages/dolfinx/geometry.py", line 175, in compute_collisions_points
return _cpp.geometry.compute_collisions_points(tree._cpp_object, x)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
ValueError: vector::reserve
I have thought that, since the upper part of the domain becomes more complex over time, the number of points that I have on the top boundary increases and it may cause some issues with the C++ backend of FEniCSx.
For reference, I am using FEniCSx v.0.9 and here is a picture of the solution at the last time step computed.