diff --git a/examples/rust/ex1-volume/src/main.rs b/examples/rust/ex1-volume/src/main.rs index 6120d41999..ab9273f17f 100644 --- a/examples/rust/ex1-volume/src/main.rs +++ b/examples/rust/ex1-volume/src/main.rs @@ -19,7 +19,9 @@ // line argument (-ceed). use clap::Parser; -use libceed::{prelude::*, Ceed}; +use libceed::{ + BasisOpt, Ceed, ElemRestrictionOpt, QFunctionInputs, QFunctionOpt, QFunctionOutputs, VectorOpt, +}; mod opt; mod transform; @@ -75,10 +77,20 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { let ceed = Ceed::init(&ceed_spec); // Mesh and solution bases - let basis_mesh = - ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?; - let basis_solution = - ceed.basis_tensor_H1_Lagrange(dim, 1, solution_degree + 1, num_qpts, QuadMode::Gauss)?; + let basis_mesh = ceed.basis_tensor_H1_Lagrange( + dim, + ncomp_x, + mesh_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; + let basis_solution = ceed.basis_tensor_H1_Lagrange( + dim, + 1, + solution_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; // Determine mesh size from approximate problem size let num_xyz = mesh::cartesian_mesh_size(dim, solution_degree, problem_size); @@ -157,9 +169,9 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { }; let qf_build_closure = ceed .q_function_interior(1, Box::new(build_mass))? - .input("dx", ncomp_x * dim, EvalMode::Grad)? - .input("weights", 1, EvalMode::Weight)? - .output("qdata", 1, EvalMode::None)?; + .input("dx", ncomp_x * dim, libceed::EvalMode::Grad)? + .input("weights", 1, libceed::EvalMode::Weight)? + .output("qdata", 1, libceed::EvalMode::None)?; // -- QFunction from gallery let qf_build_named = { let name = format!("Mass{}DBuild", dim); @@ -204,9 +216,9 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { }; let qf_mass_closure = ceed .q_function_interior(1, Box::new(apply_mass))? - .input("u", 1, EvalMode::Interp)? - .input("qdata", 1, EvalMode::None)? - .output("v", 1, EvalMode::Interp)?; + .input("u", 1, libceed::EvalMode::Interp)? + .input("qdata", 1, libceed::EvalMode::None)? + .output("v", 1, libceed::EvalMode::Interp)?; // -- QFunction from gallery let qf_mass_named = ceed.q_function_interior_by_name("MassApply")?; // -- QFunction for use with Operator @@ -233,7 +245,7 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { op_mass.apply(&u, &mut v)?; // Compute the mesh volume - let volume: Scalar = v.view()?.iter().sum(); + let volume: libceed::Scalar = v.view()?.iter().sum(); // Output results if !quiet { diff --git a/examples/rust/ex1-volume/src/transform.rs b/examples/rust/ex1-volume/src/transform.rs index 6ebe14bc6f..32521212d6 100644 --- a/examples/rust/ex1-volume/src/transform.rs +++ b/examples/rust/ex1-volume/src/transform.rs @@ -5,23 +5,21 @@ // // This file is part of CEED: http://github.com/ceed -use libceed::prelude::*; - // ---------------------------------------------------------------------------- // Transform mesh coordinates // ---------------------------------------------------------------------------- pub(crate) fn transform_mesh_coordinates( dim: usize, mesh_size: usize, - mesh_coords: &mut Vector, -) -> libceed::Result { + mesh_coords: &mut libceed::Vector, +) -> libceed::Result { // Transform coordinates if dim == 1 { for coord in mesh_coords.view_mut()?.iter_mut() { // map [0,1] to [0,1] varying the mesh density *coord = 0.5 - + 1.0 / (3.0 as Scalar).sqrt() - * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() + + 1.0 / (3.0 as libceed::Scalar).sqrt() + * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin() } } else { let mut coords = mesh_coords.view_mut()?; @@ -30,7 +28,7 @@ pub(crate) fn transform_mesh_coordinates( // map (x,y) from [0,1]x[0,1] to the quarter annulus with polar // coordinates, (r,phi) in [1,2]x[0,pi/2] with area = 3/4*pi let u = 1.0 + coords[i]; - let v = std::f64::consts::PI as Scalar / 2.0 * coords[i + num_nodes]; + let v = std::f64::consts::PI as libceed::Scalar / 2.0 * coords[i + num_nodes]; coords[i] = u * v.cos(); coords[i + num_nodes] = u * v.sin(); } @@ -39,7 +37,7 @@ pub(crate) fn transform_mesh_coordinates( // Exact volume of transformed region let exact_volume = match dim { 1 => 1.0, - _ => 3.0 / 4.0 * std::f64::consts::PI as Scalar, + _ => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar, }; Ok(exact_volume) } diff --git a/examples/rust/ex2-surface/src/main.rs b/examples/rust/ex2-surface/src/main.rs index 1c44e7cba5..e804f15287 100644 --- a/examples/rust/ex2-surface/src/main.rs +++ b/examples/rust/ex2-surface/src/main.rs @@ -20,7 +20,9 @@ // line argument (-ceed). use clap::Parser; -use libceed::{prelude::*, Ceed}; +use libceed::{ + BasisOpt, Ceed, ElemRestrictionOpt, QFunctionInputs, QFunctionOpt, QFunctionOutputs, VectorOpt, +}; mod opt; mod transform; @@ -80,10 +82,20 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { let ceed = Ceed::init(&ceed_spec); // Mesh and solution bases - let basis_mesh = - ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?; - let basis_solution = - ceed.basis_tensor_H1_Lagrange(dim, 1, solution_degree + 1, num_qpts, QuadMode::Gauss)?; + let basis_mesh = ceed.basis_tensor_H1_Lagrange( + dim, + ncomp_x, + mesh_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; + let basis_solution = ceed.basis_tensor_H1_Lagrange( + dim, + 1, + solution_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; // Determine mesh size from approximate problem size let num_xyz = mesh::cartesian_mesh_size(dim, solution_degree, problem_size); @@ -199,9 +211,9 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { }; let qf_build_closure = ceed .q_function_interior(1, Box::new(build_diff))? - .input("dx", ncomp_x * dim, EvalMode::Grad)? - .input("weights", 1, EvalMode::Weight)? - .output("qdata", dim * (dim + 1) / 2, EvalMode::None)?; + .input("dx", ncomp_x * dim, libceed::EvalMode::Grad)? + .input("weights", 1, libceed::EvalMode::Weight)? + .output("qdata", dim * (dim + 1) / 2, libceed::EvalMode::None)?; // -- QFunction from gallery let qf_build_named = { let name = format!("Poisson{}DBuild", dim); @@ -280,9 +292,9 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { }; let qf_diff_closure = ceed .q_function_interior(1, Box::new(apply_diff))? - .input("du", dim, EvalMode::Grad)? - .input("qdata", dim * (dim + 1) / 2, EvalMode::None)? - .output("dv", dim, EvalMode::Grad)?; + .input("du", dim, libceed::EvalMode::Grad)? + .input("qdata", dim * (dim + 1) / 2, libceed::EvalMode::None)? + .output("dv", dim, libceed::EvalMode::Grad)?; // -- QFunction from gallery let qf_diff_named = { let name = format!("Poisson{}DApply", dim); @@ -319,7 +331,7 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { op_diff.apply(&u, &mut v)?; // Compute the mesh surface area - let area: Scalar = v.view()?.iter().map(|v| (*v).abs()).sum(); + let area: libceed::Scalar = v.view()?.iter().map(|v| (*v).abs()).sum(); // Output results if !quiet { diff --git a/examples/rust/ex2-surface/src/transform.rs b/examples/rust/ex2-surface/src/transform.rs index 085d9bc94d..97bfc58aa5 100644 --- a/examples/rust/ex2-surface/src/transform.rs +++ b/examples/rust/ex2-surface/src/transform.rs @@ -5,21 +5,19 @@ // // This file is part of CEED: http://github.com/ceed -use libceed::prelude::*; - // ---------------------------------------------------------------------------- // Transform mesh coordinates // ---------------------------------------------------------------------------- pub(crate) fn transform_mesh_coordinates( dim: usize, - mesh_coords: &mut Vector, -) -> libceed::Result { + mesh_coords: &mut libceed::Vector, +) -> libceed::Result { // Transform coordinates for coord in mesh_coords.view_mut()?.iter_mut() { // map [0,1] to [0,1] varying the mesh density *coord = 0.5 - + 1.0 / (3.0 as Scalar).sqrt() - * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() + + 1.0 / (3.0 as libceed::Scalar).sqrt() + * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin() } // Exact surface area of transformed region diff --git a/examples/rust/ex3-vector-volume/src/main.rs b/examples/rust/ex3-vector-volume/src/main.rs index a2102e5d0f..b37c896184 100644 --- a/examples/rust/ex3-vector-volume/src/main.rs +++ b/examples/rust/ex3-vector-volume/src/main.rs @@ -20,7 +20,9 @@ // line argument (-ceed). use clap::Parser; -use libceed::{prelude::*, Ceed}; +use libceed::{ + BasisOpt, Ceed, ElemRestrictionOpt, QFunctionInputs, QFunctionOpt, QFunctionOutputs, VectorOpt, +}; mod opt; mod transform; @@ -77,14 +79,19 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { let ceed = Ceed::init(&ceed_spec); // Mesh and solution bases - let basis_mesh = - ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?; + let basis_mesh = ceed.basis_tensor_H1_Lagrange( + dim, + ncomp_x, + mesh_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; let basis_solution = ceed.basis_tensor_H1_Lagrange( dim, ncomp_u, solution_degree + 1, num_qpts, - QuadMode::Gauss, + libceed::QuadMode::Gauss, )?; // Determine mesh size from approximate problem size @@ -166,9 +173,9 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { }; let qf_build_closure = ceed .q_function_interior(1, Box::new(build_mass))? - .input("dx", ncomp_x * dim, EvalMode::Grad)? - .input("weights", 1, EvalMode::Weight)? - .output("qdata", 1, EvalMode::None)?; + .input("dx", ncomp_x * dim, libceed::EvalMode::Grad)? + .input("weights", 1, libceed::EvalMode::Weight)? + .output("qdata", 1, libceed::EvalMode::None)?; // -- QFunction from gallery let qf_build_named = { let name = format!("Mass{}DBuild", dim); @@ -217,9 +224,9 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { }; let qf_mass_closure = ceed .q_function_interior(1, Box::new(apply_mass))? - .input("u", ncomp_u, EvalMode::Interp)? - .input("qdata", 1, EvalMode::None)? - .output("v", ncomp_u, EvalMode::Interp)?; + .input("u", ncomp_u, libceed::EvalMode::Interp)? + .input("qdata", 1, libceed::EvalMode::None)? + .output("v", ncomp_u, libceed::EvalMode::Interp)?; // -- QFunction from gallery let qf_mass_named = ceed.q_function_interior_by_name("Vector3MassApply")?; // -- QFunction for use with Operator @@ -255,7 +262,7 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { op_mass.apply(&u, &mut v)?; // Compute the mesh volume - let volume: Scalar = v.view()?.iter().sum::() + let volume: libceed::Scalar = v.view()?.iter().sum::() / ((ncomp_u * (ncomp_u + 1)) / 2) as libceed::Scalar; // Output results diff --git a/examples/rust/ex3-vector-volume/src/transform.rs b/examples/rust/ex3-vector-volume/src/transform.rs index 6ebe14bc6f..32521212d6 100644 --- a/examples/rust/ex3-vector-volume/src/transform.rs +++ b/examples/rust/ex3-vector-volume/src/transform.rs @@ -5,23 +5,21 @@ // // This file is part of CEED: http://github.com/ceed -use libceed::prelude::*; - // ---------------------------------------------------------------------------- // Transform mesh coordinates // ---------------------------------------------------------------------------- pub(crate) fn transform_mesh_coordinates( dim: usize, mesh_size: usize, - mesh_coords: &mut Vector, -) -> libceed::Result { + mesh_coords: &mut libceed::Vector, +) -> libceed::Result { // Transform coordinates if dim == 1 { for coord in mesh_coords.view_mut()?.iter_mut() { // map [0,1] to [0,1] varying the mesh density *coord = 0.5 - + 1.0 / (3.0 as Scalar).sqrt() - * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() + + 1.0 / (3.0 as libceed::Scalar).sqrt() + * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin() } } else { let mut coords = mesh_coords.view_mut()?; @@ -30,7 +28,7 @@ pub(crate) fn transform_mesh_coordinates( // map (x,y) from [0,1]x[0,1] to the quarter annulus with polar // coordinates, (r,phi) in [1,2]x[0,pi/2] with area = 3/4*pi let u = 1.0 + coords[i]; - let v = std::f64::consts::PI as Scalar / 2.0 * coords[i + num_nodes]; + let v = std::f64::consts::PI as libceed::Scalar / 2.0 * coords[i + num_nodes]; coords[i] = u * v.cos(); coords[i + num_nodes] = u * v.sin(); } @@ -39,7 +37,7 @@ pub(crate) fn transform_mesh_coordinates( // Exact volume of transformed region let exact_volume = match dim { 1 => 1.0, - _ => 3.0 / 4.0 * std::f64::consts::PI as Scalar, + _ => 3.0 / 4.0 * std::f64::consts::PI as libceed::Scalar, }; Ok(exact_volume) } diff --git a/examples/rust/ex4-vector-surface/src/main.rs b/examples/rust/ex4-vector-surface/src/main.rs index 5b788274e8..c18d42599b 100644 --- a/examples/rust/ex4-vector-surface/src/main.rs +++ b/examples/rust/ex4-vector-surface/src/main.rs @@ -21,7 +21,9 @@ // line argument (-ceed). use clap::Parser; -use libceed::{prelude::*, Ceed}; +use libceed::{ + BasisOpt, Ceed, ElemRestrictionOpt, QFunctionInputs, QFunctionOpt, QFunctionOutputs, VectorOpt, +}; mod opt; mod transform; @@ -82,14 +84,19 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { let ceed = Ceed::init(&ceed_spec); // Mesh and solution bases - let basis_mesh = - ceed.basis_tensor_H1_Lagrange(dim, ncomp_x, mesh_degree + 1, num_qpts, QuadMode::Gauss)?; + let basis_mesh = ceed.basis_tensor_H1_Lagrange( + dim, + ncomp_x, + mesh_degree + 1, + num_qpts, + libceed::QuadMode::Gauss, + )?; let basis_solution = ceed.basis_tensor_H1_Lagrange( dim, ncomp_u, solution_degree + 1, num_qpts, - QuadMode::Gauss, + libceed::QuadMode::Gauss, )?; // Determine mesh size from approximate problem size @@ -206,9 +213,9 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { }; let qf_build_closure = ceed .q_function_interior(1, Box::new(build_diff))? - .input("dx", ncomp_x * dim, EvalMode::Grad)? - .input("weights", 1, EvalMode::Weight)? - .output("qdata", dim * (dim + 1) / 2, EvalMode::None)?; + .input("dx", ncomp_x * dim, libceed::EvalMode::Grad)? + .input("weights", 1, libceed::EvalMode::Weight)? + .output("qdata", dim * (dim + 1) / 2, libceed::EvalMode::None)?; // -- QFunction from gallery let qf_build_named = { let name = format!("Poisson{}DBuild", dim); @@ -301,9 +308,9 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { }; let qf_diff_closure = ceed .q_function_interior(1, Box::new(apply_diff))? - .input("du", dim * ncomp_u, EvalMode::Grad)? - .input("qdata", dim * (dim + 1) / 2, EvalMode::None)? - .output("dv", dim * ncomp_u, EvalMode::Grad)?; + .input("du", dim * ncomp_u, libceed::EvalMode::Grad)? + .input("qdata", dim * (dim + 1) / 2, libceed::EvalMode::None)? + .output("dv", dim * ncomp_u, libceed::EvalMode::Grad)?; // -- QFunction from gallery let qf_diff_named = { let name = format!("Vector3Poisson{}DApply", dim); @@ -349,7 +356,7 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { op_diff.apply(&u, &mut v)?; // Compute the mesh surface area - let area: Scalar = v + let area: libceed::Scalar = v .view()? .iter() .map(|v| (*v).abs()) diff --git a/examples/rust/ex4-vector-surface/src/transform.rs b/examples/rust/ex4-vector-surface/src/transform.rs index 085d9bc94d..97bfc58aa5 100644 --- a/examples/rust/ex4-vector-surface/src/transform.rs +++ b/examples/rust/ex4-vector-surface/src/transform.rs @@ -5,21 +5,19 @@ // // This file is part of CEED: http://github.com/ceed -use libceed::prelude::*; - // ---------------------------------------------------------------------------- // Transform mesh coordinates // ---------------------------------------------------------------------------- pub(crate) fn transform_mesh_coordinates( dim: usize, - mesh_coords: &mut Vector, -) -> libceed::Result { + mesh_coords: &mut libceed::Vector, +) -> libceed::Result { // Transform coordinates for coord in mesh_coords.view_mut()?.iter_mut() { // map [0,1] to [0,1] varying the mesh density *coord = 0.5 - + 1.0 / (3.0 as Scalar).sqrt() - * ((2.0 / 3.0) * std::f64::consts::PI as Scalar * (*coord - 0.5)).sin() + + 1.0 / (3.0 as libceed::Scalar).sqrt() + * ((2.0 / 3.0) * std::f64::consts::PI as libceed::Scalar * (*coord - 0.5)).sin() } // Exact surface area of transformed region diff --git a/examples/rust/mesh/src/lib.rs b/examples/rust/mesh/src/lib.rs index 9ad2810381..df40938e55 100644 --- a/examples/rust/mesh/src/lib.rs +++ b/examples/rust/mesh/src/lib.rs @@ -5,7 +5,7 @@ // // This file is part of CEED: http://github.com/ceed -use libceed::{prelude::*, Ceed}; +use libceed::{Ceed, ElemRestriction, Vector}; // ---------------------------------------------------------------------------- // Determine problem size in each dimension from size and dimenison @@ -91,7 +91,7 @@ pub fn build_cartesian_restriction( num_comp, scalar_size, num_comp * scalar_size, - MemType::Host, + libceed::MemType::Host, &elem_nodes, )?; @@ -101,7 +101,7 @@ pub fn build_cartesian_restriction( elem_qpts, num_comp, num_comp * elem_qpts * num_elem, - CEED_STRIDES_BACKEND, + libceed::CEED_STRIDES_BACKEND, )?; Ok((rstr, rstr_qdata)) } @@ -125,13 +125,14 @@ pub fn cartesian_mesh_coords( } // Lobatto points - let lobatto_basis = ceed.basis_tensor_H1_Lagrange(1, 1, 2, p, QuadMode::GaussLobatto)?; + let lobatto_basis = + ceed.basis_tensor_H1_Lagrange(1, 1, 2, p, libceed::QuadMode::GaussLobatto)?; let nodes_corners = ceed.vector_from_slice(&[0.0, 1.0])?; let mut nodes_full = ceed.vector(p)?; lobatto_basis.apply( 1, - TransposeMode::NoTranspose, - EvalMode::Interp, + libceed::TransposeMode::NoTranspose, + libceed::EvalMode::Interp, &nodes_corners, &mut nodes_full, )?; @@ -146,8 +147,9 @@ pub fn cartesian_mesh_coords( let mut r_nodes = gs_nodes; for d in 0..dim { let d_1d = r_nodes % num_d[d]; - coords[gs_nodes + scalar_size * d] = - ((d_1d / (p - 1)) as Scalar + nodes[d_1d % (p - 1)]) / num_xyz[d] as Scalar; + coords[gs_nodes + scalar_size * d] = ((d_1d / (p - 1)) as libceed::Scalar + + nodes[d_1d % (p - 1)]) + / num_xyz[d] as libceed::Scalar; r_nodes /= num_d[d]; } } diff --git a/rust/libceed/src/basis.rs b/rust/libceed/src/basis.rs index 4c11fb79b4..813e1e3fb3 100644 --- a/rust/libceed/src/basis.rs +++ b/rust/libceed/src/basis.rs @@ -8,7 +8,7 @@ //! A Ceed Basis defines the discrete finite element basis and associated //! quadrature rule. -use crate::prelude::*; +use crate::{prelude::*, vector::Vector, EvalMode, TransposeMode}; // ----------------------------------------------------------------------------- // Basis option @@ -37,7 +37,7 @@ impl<'a> BasisOpt<'a> { /// Check if a BasisOpt is Some /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let b = ceed.basis_tensor_H1_Lagrange(1, 2, 3, 4, QuadMode::Gauss)?; @@ -59,7 +59,7 @@ impl<'a> BasisOpt<'a> { /// Check if a BasisOpt is None /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let b = ceed.basis_tensor_H1_Lagrange(1, 2, 3, 4, QuadMode::Gauss)?; @@ -108,7 +108,7 @@ impl<'a> fmt::Display for Basis<'a> { /// View a Basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let b = ceed.basis_tensor_H1_Lagrange(1, 2, 3, 4, QuadMode::Gauss)?; @@ -339,7 +339,7 @@ impl<'a> Basis<'a> { /// * `v` - Output Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, TransposeMode, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// const Q: usize = 6; @@ -412,7 +412,7 @@ impl<'a> Basis<'a> { /// Returns the dimension for given Basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let dim = 2; @@ -432,7 +432,7 @@ impl<'a> Basis<'a> { /// Returns number of components for given Basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ncomp = 2; @@ -452,7 +452,7 @@ impl<'a> Basis<'a> { /// Returns total number of nodes (in dim dimensions) of a Basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let p = 3; @@ -473,7 +473,7 @@ impl<'a> Basis<'a> { /// Basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let q = 4; @@ -502,7 +502,7 @@ impl<'a> Basis<'a> { /// points and weights. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, TransposeMode, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let coarse = ceed.basis_tensor_H1_Lagrange(1, 1, 2, 3, QuadMode::Gauss)?; diff --git a/rust/libceed/src/elem_restriction.rs b/rust/libceed/src/elem_restriction.rs index 950a840403..09c36be0ba 100644 --- a/rust/libceed/src/elem_restriction.rs +++ b/rust/libceed/src/elem_restriction.rs @@ -8,7 +8,7 @@ //! A Ceed ElemRestriction decomposes elements and groups the degrees of freedom //! (dofs) according to the different elements they belong to. -use crate::prelude::*; +use crate::{prelude::*, vector::Vector, TransposeMode}; // ----------------------------------------------------------------------------- // ElemRestriction option @@ -38,7 +38,7 @@ impl<'a> ElemRestrictionOpt<'a> { /// Check if an ElemRestrictionOpt is Some /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, ElemRestrictionOpt, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -66,7 +66,7 @@ impl<'a> ElemRestrictionOpt<'a> { /// Check if an ElemRestrictionOpt is None /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, ElemRestrictionOpt, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -121,7 +121,7 @@ impl<'a> fmt::Display for ElemRestriction<'a> { /// View an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -323,7 +323,7 @@ impl<'a> ElemRestriction<'a> { /// Create an Lvector for an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -352,7 +352,7 @@ impl<'a> ElemRestriction<'a> { /// Create an Evector for an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -381,7 +381,7 @@ impl<'a> ElemRestriction<'a> { /// Create Vectors for an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -422,7 +422,7 @@ impl<'a> ElemRestriction<'a> { /// decided by the backend. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType, Scalar, TransposeMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -466,7 +466,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the Lvector component stride /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -492,7 +492,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the total number of elements in the range of a ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -517,7 +517,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the size of elements in the ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -543,7 +543,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the size of the Lvector for an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -568,7 +568,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the number of components in the elements of an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -594,7 +594,7 @@ impl<'a> ElemRestriction<'a> { /// Returns the multiplicity of nodes in an ElemRestriction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; diff --git a/rust/libceed/src/lib.rs b/rust/libceed/src/lib.rs index bf7de98e07..70d291a55e 100755 --- a/rust/libceed/src/lib.rs +++ b/rust/libceed/src/lib.rs @@ -19,18 +19,6 @@ use crate::prelude::*; use std::sync::Once; pub mod prelude { - pub use crate::{ - basis::{self, Basis, BasisOpt}, - elem_restriction::{self, ElemRestriction, ElemRestrictionOpt}, - operator::{self, CompositeOperator, Operator, OperatorField}, - qfunction::{ - self, QFunction, QFunctionByName, QFunctionField, QFunctionInputs, QFunctionOpt, - QFunctionOutputs, - }, - vector::{self, Vector, VectorOpt, VectorSliceWrapper}, - ElemTopology, EvalMode, MemType, NormType, QuadMode, Scalar, TransposeMode, - CEED_STRIDES_BACKEND, EPSILON, MAX_QFUNCTION_FIELDS, - }; pub(crate) use libceed_sys::bind_ceed; pub(crate) use std::convert::TryFrom; pub(crate) use std::ffi::{CStr, CString}; @@ -157,6 +145,19 @@ impl fmt::Display for Error { } } +// ----------------------------------------------------------------------------- +// Internal error checker +// ----------------------------------------------------------------------------- +pub use crate::{ + basis::{Basis, BasisOpt}, + elem_restriction::{ElemRestriction, ElemRestrictionOpt}, + operator::{CompositeOperator, Operator, OperatorField}, + qfunction::{ + QFunction, QFunctionByName, QFunctionField, QFunctionInputs, QFunctionOpt, QFunctionOutputs, + }, + vector::{Vector, VectorOpt, VectorSliceWrapper}, +}; + // ----------------------------------------------------------------------------- // Internal error checker // ----------------------------------------------------------------------------- @@ -424,7 +425,7 @@ impl Ceed { /// `[0, lsize - 1]`. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -483,7 +484,7 @@ impl Ceed { /// orientation. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -547,7 +548,7 @@ impl Ceed { /// unknowns upon restriction. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -716,7 +717,7 @@ impl Ceed { /// accuracy for the quadrature) /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QuadMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let b = ceed.basis_tensor_H1_Lagrange(2, 1, 3, 4, QuadMode::Gauss)?; @@ -752,7 +753,7 @@ impl Ceed { /// the reference element /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, ElemTopology}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let interp = [ @@ -883,7 +884,7 @@ impl Ceed { /// the reference element /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, ElemTopology}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let interp = [ @@ -980,7 +981,7 @@ impl Ceed { /// the reference element /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, ElemTopology}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let interp = [ @@ -1074,7 +1075,7 @@ impl Ceed { /// * `f` - Boxed closure to evaluate weak form at quadrature points. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -1132,7 +1133,7 @@ impl Ceed { /// Jacobian of the qf (or qfunction_none) /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QFunctionOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; diff --git a/rust/libceed/src/operator.rs b/rust/libceed/src/operator.rs index bd5d7f37f4..ee632bd862 100644 --- a/rust/libceed/src/operator.rs +++ b/rust/libceed/src/operator.rs @@ -9,7 +9,13 @@ //! Ceed QFunction. A Ceed Operator connects Ceed ElemRestrictions, //! Ceed Bases, and Ceed QFunctions. -use crate::prelude::*; +use crate::{ + basis::{Basis, BasisOpt}, + elem_restriction::{ElemRestriction, ElemRestrictionOpt}, + prelude::*, + qfunction::QFunctionOpt, + vector::{Vector, VectorOpt}, +}; // ----------------------------------------------------------------------------- // Operator Field context wrapper @@ -27,7 +33,7 @@ impl<'a> OperatorField<'a> { /// Get the name of an OperatorField /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -74,7 +80,7 @@ impl<'a> OperatorField<'a> { /// Get the ElemRestriction of an OperatorField /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -123,7 +129,7 @@ impl<'a> OperatorField<'a> { } else { let slice = unsafe { std::slice::from_raw_parts( - &ptr as *const bind_ceed::CeedElemRestriction as *const crate::ElemRestriction, + &ptr as *const bind_ceed::CeedElemRestriction as *const ElemRestriction, 1 as usize, ) }; @@ -134,7 +140,7 @@ impl<'a> OperatorField<'a> { /// Get the Basis of an OperatorField /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -181,7 +187,7 @@ impl<'a> OperatorField<'a> { } else { let slice = unsafe { std::slice::from_raw_parts( - &ptr as *const bind_ceed::CeedBasis as *const crate::Basis, + &ptr as *const bind_ceed::CeedBasis as *const Basis, 1 as usize, ) }; @@ -192,7 +198,7 @@ impl<'a> OperatorField<'a> { /// Get the Vector of an OperatorField /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -237,7 +243,7 @@ impl<'a> OperatorField<'a> { } else { let slice = unsafe { std::slice::from_raw_parts( - &ptr as *const bind_ceed::CeedVector as *const crate::Vector, + &ptr as *const bind_ceed::CeedVector as *const Vector, 1 as usize, ) }; @@ -296,7 +302,7 @@ impl<'a> fmt::Display for OperatorCore<'a> { /// View an Operator /// /// ``` -/// # use libceed::prelude::*; +/// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -336,7 +342,7 @@ impl<'a> fmt::Display for Operator<'a> { /// View a composite Operator /// /// ``` -/// # use libceed::prelude::*; +/// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// @@ -534,7 +540,7 @@ impl<'a> Operator<'a> { /// * 'name' - Name to set /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -575,7 +581,7 @@ impl<'a> Operator<'a> { /// * `output` - Output Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -653,7 +659,7 @@ impl<'a> Operator<'a> { /// * `output` - Output Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -733,7 +739,7 @@ impl<'a> Operator<'a> { /// /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -782,7 +788,7 @@ impl<'a> Operator<'a> { /// Get a slice of Operator inputs /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -814,7 +820,7 @@ impl<'a> Operator<'a> { /// # Ok(()) /// # } /// ``` - pub fn inputs(&self) -> crate::Result<&[crate::OperatorField]> { + pub fn inputs(&self) -> crate::Result<&[OperatorField]> { // Get array of raw C pointers for inputs let mut num_inputs = 0; let mut inputs_ptr = std::ptr::null_mut(); @@ -830,10 +836,7 @@ impl<'a> Operator<'a> { self.op_core.check_error(ierr)?; // Convert raw C pointers to fixed length slice let inputs_slice = unsafe { - std::slice::from_raw_parts( - inputs_ptr as *const crate::OperatorField, - num_inputs as usize, - ) + std::slice::from_raw_parts(inputs_ptr as *const OperatorField, num_inputs as usize) }; Ok(inputs_slice) } @@ -841,7 +844,7 @@ impl<'a> Operator<'a> { /// Get a slice of Operator outputs /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -873,7 +876,7 @@ impl<'a> Operator<'a> { /// # Ok(()) /// # } /// ``` - pub fn outputs(&self) -> crate::Result<&[crate::OperatorField]> { + pub fn outputs(&self) -> crate::Result<&[OperatorField]> { // Get array of raw C pointers for outputs let mut num_outputs = 0; let mut outputs_ptr = std::ptr::null_mut(); @@ -889,10 +892,7 @@ impl<'a> Operator<'a> { self.op_core.check_error(ierr)?; // Convert raw C pointers to fixed length slice let outputs_slice = unsafe { - std::slice::from_raw_parts( - outputs_ptr as *const crate::OperatorField, - num_outputs as usize, - ) + std::slice::from_raw_parts(outputs_ptr as *const OperatorField, num_outputs as usize) }; Ok(outputs_slice) } @@ -900,7 +900,7 @@ impl<'a> Operator<'a> { /// Check if Operator is setup correctly /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -943,7 +943,7 @@ impl<'a> Operator<'a> { /// /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -980,7 +980,7 @@ impl<'a> Operator<'a> { /// /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let qf = ceed.q_function_interior_by_name("Mass1DBuild")?; @@ -1027,7 +1027,7 @@ impl<'a> Operator<'a> { /// * `assembled` - Vector to store assembled Operator diagonal /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -1134,7 +1134,7 @@ impl<'a> Operator<'a> { /// /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -1246,7 +1246,7 @@ impl<'a> Operator<'a> { /// `[nodes, component out, component in]`. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, EvalMode, MemType, QFunctionInputs, QFunctionOpt, QFunctionOutputs, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -1385,7 +1385,7 @@ impl<'a> Operator<'a> { /// `[nodes, component out, component in]`. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, EvalMode, MemType, QFunctionInputs, QFunctionOpt, QFunctionOutputs, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -1517,7 +1517,7 @@ impl<'a> Operator<'a> { /// * `basis_coarse` - Coarse grid active vector basis /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 15; @@ -1677,7 +1677,7 @@ impl<'a> Operator<'a> { /// * `interp_c_to_f` - Matrix for coarse to fine /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, EvalMode, MemType, QFunctionOpt, QuadMode, Scalar, TransposeMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 15; @@ -1835,7 +1835,7 @@ impl<'a> Operator<'a> { p_mult_fine: &Vector, rstr_coarse: &ElemRestriction, basis_coarse: &Basis, - interpCtoF: &Vec, + interpCtoF: &Vec, ) -> crate::Result<(Operator<'b>, Operator<'b>, Operator<'b>)> { let mut ptr_coarse = std::ptr::null_mut(); let mut ptr_prolong = std::ptr::null_mut(); @@ -1868,7 +1868,7 @@ impl<'a> Operator<'a> { /// * `interp_c_to_f` - Matrix for coarse to fine /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, EvalMode, MemType, QFunctionOpt, QuadMode, Scalar, TransposeMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 15; @@ -2026,7 +2026,7 @@ impl<'a> Operator<'a> { p_mult_fine: &Vector, rstr_coarse: &ElemRestriction, basis_coarse: &Basis, - interpCtoF: &[Scalar], + interpCtoF: &[crate::Scalar], ) -> crate::Result<(Operator<'b>, Operator<'b>, Operator<'b>)> { let mut ptr_coarse = std::ptr::null_mut(); let mut ptr_prolong = std::ptr::null_mut(); @@ -2073,7 +2073,7 @@ impl<'a> CompositeOperator<'a> { /// * 'name' - Name to set /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// @@ -2130,7 +2130,7 @@ impl<'a> CompositeOperator<'a> { /// * `output` - Output Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -2227,7 +2227,7 @@ impl<'a> CompositeOperator<'a> { /// * `output` - Output Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, Scalar, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; @@ -2323,7 +2323,7 @@ impl<'a> CompositeOperator<'a> { /// * `subop` - Sub-Operator /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, QFunctionOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut op = ceed.composite_operator()?; @@ -2349,7 +2349,7 @@ impl<'a> CompositeOperator<'a> { /// Check if CompositeOperator is setup correctly /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, BasisOpt, ElemRestrictionOpt, MemType, QFunctionOpt, QuadMode, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let ne = 4; diff --git a/rust/libceed/src/qfunction.rs b/rust/libceed/src/qfunction.rs index 0d32d01d28..9723674284 100644 --- a/rust/libceed/src/qfunction.rs +++ b/rust/libceed/src/qfunction.rs @@ -10,7 +10,7 @@ use std::pin::Pin; -use crate::prelude::*; +use crate::{prelude::*, vector::Vector, MAX_QFUNCTION_FIELDS}; pub type QFunctionInputs<'a> = [&'a [crate::Scalar]; MAX_QFUNCTION_FIELDS]; pub type QFunctionOutputs<'a> = [&'a mut [crate::Scalar]; MAX_QFUNCTION_FIELDS]; @@ -82,7 +82,7 @@ impl<'a> QFunctionField<'a> { /// Get the evaluation mode of a QFunctionField /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// const Q: usize = 8; @@ -150,7 +150,7 @@ impl<'a> QFunctionOpt<'a> { /// Check if a QFunctionOpt is Some /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOpt, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -191,7 +191,7 @@ impl<'a> QFunctionOpt<'a> { /// Check if a QFunctionOpt is SomeQFunction /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOpt, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -232,7 +232,7 @@ impl<'a> QFunctionOpt<'a> { /// Check if a QFunctionOpt is SomeQFunctionByName /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOpt, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -282,7 +282,7 @@ impl<'a> QFunctionOpt<'a> { /// Check if a QFunctionOpt is None /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOpt, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -389,7 +389,7 @@ impl<'a> fmt::Display for QFunctionCore<'a> { /// View a QFunction /// /// ``` -/// # use libceed::prelude::*; +/// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -466,7 +466,7 @@ impl<'a> QFunctionCore<'a> { self.check_error(ierr) } - pub fn inputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn inputs(&self) -> crate::Result<&[QFunctionField]> { // Get array of raw C pointers for inputs let mut num_inputs = 0; let mut inputs_ptr = std::ptr::null_mut(); @@ -482,15 +482,12 @@ impl<'a> QFunctionCore<'a> { self.check_error(ierr)?; // Convert raw C pointers to fixed length slice let inputs_slice = unsafe { - std::slice::from_raw_parts( - inputs_ptr as *const crate::QFunctionField, - num_inputs as usize, - ) + std::slice::from_raw_parts(inputs_ptr as *const QFunctionField, num_inputs as usize) }; Ok(inputs_slice) } - pub fn outputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn outputs(&self) -> crate::Result<&[QFunctionField]> { // Get array of raw C pointers for outputs let mut num_outputs = 0; let mut outputs_ptr = std::ptr::null_mut(); @@ -506,10 +503,7 @@ impl<'a> QFunctionCore<'a> { self.check_error(ierr)?; // Convert raw C pointers to fixed length slice let outputs_slice = unsafe { - std::slice::from_raw_parts( - outputs_ptr as *const crate::QFunctionField, - num_outputs as usize, - ) + std::slice::from_raw_parts(outputs_ptr as *const QFunctionField, num_outputs as usize) }; Ok(outputs_slice) } @@ -661,7 +655,7 @@ impl<'a> QFunction<'a> { /// * `output` - Array of output Vectors /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -729,7 +723,7 @@ impl<'a> QFunction<'a> { /// gradients, `EvalMode::Weight` to use quadrature weights /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -780,7 +774,7 @@ impl<'a> QFunction<'a> { /// gradients /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -823,7 +817,7 @@ impl<'a> QFunction<'a> { /// Get a slice of QFunction inputs /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -847,14 +841,14 @@ impl<'a> QFunction<'a> { /// # Ok(()) /// # } /// ``` - pub fn inputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn inputs(&self) -> crate::Result<&[QFunctionField]> { self.qf_core.inputs() } /// Get a slice of QFunction outputs /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| { @@ -877,7 +871,7 @@ impl<'a> QFunction<'a> { /// # Ok(()) /// # } /// ``` - pub fn outputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn outputs(&self) -> crate::Result<&[QFunctionField]> { self.qf_core.outputs() } } @@ -909,7 +903,7 @@ impl<'a> QFunctionByName<'a> { /// * `output` - Array of output Vectors /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, EvalMode, QFunctionInputs, QFunctionOutputs, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// const Q: usize = 8; @@ -982,7 +976,7 @@ impl<'a> QFunctionByName<'a> { /// # Ok(()) /// # } /// ``` - pub fn inputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn inputs(&self) -> crate::Result<&[QFunctionField]> { self.qf_core.inputs() } @@ -1001,7 +995,7 @@ impl<'a> QFunctionByName<'a> { /// # Ok(()) /// # } /// ``` - pub fn outputs(&self) -> crate::Result<&[crate::QFunctionField]> { + pub fn outputs(&self) -> crate::Result<&[QFunctionField]> { self.qf_core.outputs() } } diff --git a/rust/libceed/src/vector.rs b/rust/libceed/src/vector.rs index c90d8a295a..473c2b0458 100644 --- a/rust/libceed/src/vector.rs +++ b/rust/libceed/src/vector.rs @@ -45,7 +45,7 @@ impl<'a> VectorOpt<'a> { /// Check if a VectorOpt is Some /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let vec = libceed::vector::Vector::from_slice(&ceed, &[1., 2., 3.])?; @@ -71,7 +71,7 @@ impl<'a> VectorOpt<'a> { /// Check if a VectorOpt is Active /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let vec = libceed::vector::Vector::from_slice(&ceed, &[1., 2., 3.])?; @@ -97,7 +97,7 @@ impl<'a> VectorOpt<'a> { /// Check if a VectorOpt is Some /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, VectorOpt}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let vec = libceed::vector::Vector::from_slice(&ceed, &[1., 2., 3.])?; @@ -125,7 +125,7 @@ impl<'a> VectorOpt<'a> { // Vector borrowed slice wrapper // ----------------------------------------------------------------------------- pub struct VectorSliceWrapper<'a> { - pub(crate) vector: crate::Vector<'a>, + pub(crate) vector: Vector<'a>, pub(crate) _slice: &'a mut [crate::Scalar], } @@ -149,7 +149,7 @@ impl<'a> Drop for VectorSliceWrapper<'a> { // ----------------------------------------------------------------------------- impl<'a> VectorSliceWrapper<'a> { fn from_vector_and_slice_mut<'b>( - vec: &'b mut crate::Vector, + vec: &'b mut Vector, slice: &'a mut [crate::Scalar], ) -> crate::Result { assert_eq!(vec.length(), slice.len()); @@ -168,7 +168,7 @@ impl<'a> VectorSliceWrapper<'a> { vec.check_error(ierr)?; Ok(Self { - vector: crate::Vector::from_raw(vec.ptr_copy_mut()?)?, + vector: Vector::from_raw(vec.ptr_copy_mut()?)?, _slice: slice, }) } @@ -276,7 +276,7 @@ impl<'a> Vector<'a> { /// * `vec_source` - vector to copy array values from /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let a = ceed.vector_from_slice(&[1., 2., 3.])?; @@ -290,7 +290,7 @@ impl<'a> Vector<'a> { /// # } /// ``` /// ``` - pub fn copy_from(&mut self, vec_source: &crate::Vector) -> crate::Result { + pub fn copy_from(&mut self, vec_source: &Vector) -> crate::Result { let ierr = unsafe { bind_ceed::CeedVectorCopy(vec_source.ptr, self.ptr) }; self.check_error(ierr) } @@ -305,7 +305,7 @@ impl<'a> Vector<'a> { /// # use libceed::prelude::*; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); - /// let vec = vector::Vector::from_slice(&ceed, &[1., 2., 3.])?; + /// let vec = libceed::Vector::from_slice(&ceed, &[1., 2., 3.])?; /// assert_eq!(vec.length(), 3, "Incorrect length from slice"); /// # Ok(()) /// # } @@ -423,7 +423,7 @@ impl<'a> Vector<'a> { /// * `slice` - values to into self; length must match /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut vec = ceed.vector(4)?; @@ -459,7 +459,7 @@ impl<'a> Vector<'a> { /// * `slice` - values to wrap in self; length must match /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut vec = ceed.vector(4)?; @@ -501,7 +501,7 @@ impl<'a> Vector<'a> { &mut self, slice: &'b mut [crate::Scalar], ) -> crate::Result> { - crate::VectorSliceWrapper::from_vector_and_slice_mut(self, slice) + VectorSliceWrapper::from_vector_and_slice_mut(self, slice) } /// Sync the Vector to a specified memtype @@ -511,7 +511,7 @@ impl<'a> Vector<'a> { /// * `mtype` - Memtype to be synced /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let len = 10; @@ -583,7 +583,7 @@ impl<'a> Vector<'a> { /// * `ntype` - Norm type One, Two, or Max /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, NormType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let vec = ceed.vector_from_slice(&[1., 2., 3., 4.])?; @@ -615,7 +615,7 @@ impl<'a> Vector<'a> { /// * `alpha` - scaling factor /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut vec = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?; @@ -642,7 +642,7 @@ impl<'a> Vector<'a> { /// * `x` - second vector, must be different than self /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let x = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?; @@ -656,7 +656,7 @@ impl<'a> Vector<'a> { /// # } /// ``` #[allow(unused_mut)] - pub fn axpy(mut self, alpha: crate::Scalar, x: &crate::Vector) -> crate::Result { + pub fn axpy(mut self, alpha: crate::Scalar, x: &Vector) -> crate::Result { let ierr = unsafe { bind_ceed::CeedVectorAXPY(self.ptr, alpha, x.ptr) }; self.check_error(ierr)?; Ok(self) @@ -671,7 +671,7 @@ impl<'a> Vector<'a> { /// * `x` - second vector, must be different than self /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let x = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?; @@ -689,7 +689,7 @@ impl<'a> Vector<'a> { mut self, alpha: crate::Scalar, beta: crate::Scalar, - x: &crate::Vector, + x: &Vector, ) -> crate::Result { let ierr = unsafe { bind_ceed::CeedVectorAXPBY(self.ptr, alpha, beta, x.ptr) }; self.check_error(ierr)?; @@ -704,7 +704,7 @@ impl<'a> Vector<'a> { /// * `y` - second vector for product /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut w = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?; @@ -719,7 +719,7 @@ impl<'a> Vector<'a> { /// # } /// ``` #[allow(unused_mut)] - pub fn pointwise_mult(mut self, x: &crate::Vector, y: &crate::Vector) -> crate::Result { + pub fn pointwise_mult(mut self, x: &Vector, y: &Vector) -> crate::Result { let ierr = unsafe { bind_ceed::CeedVectorPointwiseMult(self.ptr, x.ptr, y.ptr) }; self.check_error(ierr)?; Ok(self) @@ -732,7 +732,7 @@ impl<'a> Vector<'a> { /// * `x` - second vector for product /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut w = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?; @@ -746,7 +746,7 @@ impl<'a> Vector<'a> { /// # } /// ``` #[allow(unused_mut)] - pub fn pointwise_scale(mut self, x: &crate::Vector) -> crate::Result { + pub fn pointwise_scale(mut self, x: &Vector) -> crate::Result { let ierr = unsafe { bind_ceed::CeedVectorPointwiseMult(self.ptr, self.ptr, x.ptr) }; self.check_error(ierr)?; Ok(self) @@ -755,7 +755,7 @@ impl<'a> Vector<'a> { /// Compute the pointwise multiplication w = w .* w for a Vector /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, Scalar}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let mut w = ceed.vector_from_slice(&[0., 1., 2., 3., 4.])?;