src/dolfinx_access/function.rs

changeset 12
a0d61ac3719e
parent 3
c3a4f4bb87f7
equal deleted inserted replaced
11:c4f923017349 12:a0d61ac3719e
14 use itertools::izip; 14 use itertools::izip;
15 use pyo3::ffi::c_str; 15 use pyo3::ffi::c_str;
16 use pyo3::prelude::*; 16 use pyo3::prelude::*;
17 use pyo3::types::{PyDict, PyFunction}; 17 use pyo3::types::{PyDict, PyFunction};
18 use std::ffi::CStr; 18 use std::ffi::CStr;
19 use std::mem::MaybeUninit;
19 20
20 /// A helper structure of dealing with dolfinx functions. 21 /// A helper structure of dealing with dolfinx functions.
21 /// `N` is the domain dimension, `O` the order, and `D` is the codomain dimension. 22 /// `N` is the domain dimension, `O` the order, and `D` is the codomain dimension.
22 #[allow(non_camel_case_types)] 23 #[allow(non_camel_case_types)]
23 pub struct DolfinxPyFunction_f64<'py, const N: u32, const O: u32 = 1, const D: u32 = 1> { 24 pub struct DolfinxPyFunction_f64<'py, const N: u32, const O: u32 = 1, const D: u32 = 1> {
272 Loc::ORIGIN 273 Loc::ORIGIN
273 } else { 274 } else {
274 let (model, _) = unsafe { 275 let (model, _) = unsafe {
275 // Find the coordinates of the corresponding triangle. We guarantee a 276 // Find the coordinates of the corresponding triangle. We guarantee a
276 // triangular mesh in the constructor of `DolfinxPyFunction_f64`. 277 // triangular mesh in the constructor of `DolfinxPyFunction_f64`.
277 let simplex_coords = ffi::cell_coords_Function_f64_triangle(f, cell); 278 //let simplex_coords = ffi::cell_coords_Function_f64_triangle(f, cell);
278 // Construct a new P2 model on that cell, as this is easier than dealing 279 // Construct a new P2 model on that cell, as this is easier than dealing
279 // with the awful documentation of Dolphinx and C++, and probably having 280 // with the awful documentation of Dolphinx and C++, and probably having
280 // to reimplemen our P2 stuff anyway, to do any optimisation with the basix 281 // to reimplemen our P2 stuff anyway, to do any optimisation with the basix
281 // basis functions. 282 // basis functions.
282 super::model_dolfinx_p2_cell(f, &simplex_coords, cell, false) 283 let coords_uninit: [MaybeUninit<f64>; 18] = [const { MaybeUninit::uninit() }; 18];
284 let vals_uninit: [MaybeUninit<f64>; 6] = [const { MaybeUninit::uninit() }; 6];
285 let mut coords = MaybeUninit::array_assume_init(coords_uninit);
286 let mut vals = MaybeUninit::array_assume_init(vals_uninit);
287 ffi::cell_dofs_Function_f64_p2(f, cell, &mut coords, &mut vals);
288 super::model_dolfinx_p2_cell(coords, vals, false)
283 }; 289 };
284 model.differential(&x_own) 290 model.differential(&x_own)
285 } 291 }
286 } 292 }
287 } 293 }

mercurial