diff -r a4137aedcb3a -r c3a4f4bb87f7 src/dolfinx_access/function.cc --- a/src/dolfinx_access/function.cc Thu Feb 26 09:32:12 2026 -0500 +++ b/src/dolfinx_access/function.cc Wed Apr 22 22:32:00 2026 -0500 @@ -17,7 +17,6 @@ using namespace basix::element; using namespace dolfinx::graph; using namespace dolfinx::la; -namespace cell = basix::cell; namespace dolfinx_access { extern void drop_Function_f64(Function_f64* f) { @@ -29,9 +28,9 @@ auto el = fp->element()->basix_element(); return FunctionInfo{ .domain_dim = (uint32_t)fp->mesh()->geometry().dim(), - .codomain_dim = (uint32_t)fp->value_size(), + .codomain_dim = (uint32_t)fp->element()->value_size(), .order = (uint32_t)fp->element()->basix_element().degree(), - .triangular_mesh = el.cell_type() == cell::type::triangle, + .triangular_mesh = el.cell_type() == basix::cell::type::triangle, }; } @@ -41,15 +40,16 @@ } } - std::map>, std::shared_ptr>, - std::owner_less>>> + std::map>, + std::shared_ptr>, + std::owner_less>>> bb_tree_cache; /// Returns the cell containg x - int32_t cell_Mesh_f64(std::shared_ptr> mesh, + int32_t cell_Mesh_f64(std::shared_ptr> mesh, const std::array& x) { - std::weak_ptr> mesh_weak = mesh; + std::weak_ptr> mesh_weak = mesh; std::shared_ptr> bb_tree = bb_tree_cache[mesh_weak]; if (bb_tree == nullptr) { auto topo = mesh->topology(); @@ -68,7 +68,8 @@ assert(local_cells == index_map->size_global()); std::vector r(local_cells); std::iota(r.begin(), r.end(), 0); - bb_tree = std::make_shared>(BoundingBoxTree(*mesh, dim, r)); + bb_tree = + std::make_shared>(BoundingBoxTree(*mesh, dim, 0.0, r)); bb_tree_cache[mesh_weak] = bb_tree; } // Find colliding bounding boxes. This is an AdjancencyTree. @@ -143,13 +144,13 @@ } rust::Slice data_Function_f64(Function_f64 const* f) { - auto span = f->x()->array(); - return rust::Slice(span.data(), span.size()); + const std::vector& v = f->x()->array(); + return rust::Slice(v.data(), v.size()); } rust::Slice data_mut_Function_f64(Function_f64* f) { - auto span = f->x()->mutable_array(); - return rust::Slice(span.data(), span.size()); + std::vector& v = f->x()->array(); + return rust::Slice(v.data(), v.size()); } Function_f64* similar_Function_f64(Function_f64 const* f) { @@ -157,7 +158,20 @@ } Function_f64* clone_Function_f64(Function_f64 const* f) { - return new Function_f64(f->function_space(), std::make_shared>(*f->x())); + // return new Function_f64(f->function_space(), + // std::make_shared>(*f->x())); + auto f_copy = new Function_f64(f->function_space()); + auto fx = f->x(); + auto x_new = f_copy->x(); + const std::vector& a_old = fx->array(); + std::vector& a_new = x_new->array(); + std::copy(a_old.begin(), a_old.end(), a_new.begin()); + x_new->scatter_fwd(); + return f_copy; + } + + void scatter_fwd_Function_f64(Function_f64* f) { + f->x()->scatter_fwd(); } // PyObject* py_similar_Function_f64(Function_f64 const* f) {