src/dolfinx_access/function.rs

changeset 12
a0d61ac3719e
parent 3
c3a4f4bb87f7
--- a/src/dolfinx_access/function.rs	Mon Jun 29 00:20:42 2026 +0300
+++ b/src/dolfinx_access/function.rs	Sun Oct 04 13:02:26 2026 -0500
@@ -16,6 +16,7 @@
 use pyo3::prelude::*;
 use pyo3::types::{PyDict, PyFunction};
 use std::ffi::CStr;
+use std::mem::MaybeUninit;
 
 /// A helper structure of dealing with dolfinx functions.
 /// `N` is the domain dimension, `O` the order, and `D` is the codomain dimension.
@@ -274,12 +275,17 @@
                     let (model, _) = unsafe {
                         // Find the coordinates of the corresponding triangle. We guarantee a
                         // triangular mesh in the constructor of `DolfinxPyFunction_f64`.
-                        let simplex_coords = ffi::cell_coords_Function_f64_triangle(f, cell);
+                        //let simplex_coords = ffi::cell_coords_Function_f64_triangle(f, cell);
                         // Construct a new P2 model on that cell, as this is easier than dealing
                         // with the awful documentation of Dolphinx and C++, and probably having
                         // to reimplemen our P2 stuff anyway, to do any optimisation with the basix
                         // basis functions.
-                        super::model_dolfinx_p2_cell(f, &simplex_coords, cell, false)
+                        let coords_uninit: [MaybeUninit<f64>; 18] = [const { MaybeUninit::uninit() }; 18];
+                        let vals_uninit: [MaybeUninit<f64>; 6] = [const { MaybeUninit::uninit() }; 6];
+                        let mut coords = MaybeUninit::array_assume_init(coords_uninit);
+                        let mut vals = MaybeUninit::array_assume_init(vals_uninit);
+                        ffi::cell_dofs_Function_f64_p2(f, cell, &mut coords, &mut vals);
+                        super::model_dolfinx_p2_cell(coords, vals, false)
                     };
                     model.differential(&x_own)
                 }

mercurial