diff --git a/examples/rust/ex1-volume/src/main.rs b/examples/rust/ex1-volume/src/main.rs index 6120d41999..749800fe04 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; @@ -44,17 +46,20 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { quiet, gallery, } = options; - assert!(dim >= 1 && dim <= 3); + assert!((1..=3).contains(&dim)); assert!(mesh_degree >= 1); assert!(solution_degree >= 1); assert!(num_qpts >= 1); let ncomp_x = dim; - let problem_size: i64; - if problem_size_requested < 0 { - problem_size = if test { 8 * 16 } else { 256 * 1024 }; + let problem_size: i64 = if problem_size_requested < 0 { + if test { + 8 * 16 + } else { + 256 * 1024 + } } else { - problem_size = problem_size_requested; - } + problem_size_requested + }; // Summary output if !quiet { @@ -75,10 +80,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); @@ -90,7 +105,7 @@ fn example_1(options: opt::Opt) -> libceed::Result<()> { if dim > 2 { print!(", nz = {}", num_xyz[2]); } - print!("\n"); + println!(); } // Build ElemRestriction objects describing the mesh and solution discrete @@ -157,9 +172,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 +219,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 +248,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..34b5b7fdea 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; @@ -45,21 +47,20 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { quiet, gallery, } = options; - assert!(dim >= 1 && dim <= 3); + assert!((0..=3).contains(&dim)); assert!(mesh_degree >= 1); assert!(solution_degree >= 1); assert!(num_qpts >= 1); let ncomp_x = dim; - let problem_size: i64; - if problem_size_requested < 0 { - problem_size = if test { + let problem_size: i64 = if problem_size_requested < 0 { + if test { 16 * 16 * (dim * dim) as i64 } else { 256 * 1024 - }; + } } else { - problem_size = problem_size_requested; - } + problem_size_requested + }; // Summary output if !quiet { @@ -80,10 +81,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); @@ -95,7 +106,7 @@ fn example_2(options: opt::Opt) -> libceed::Result<()> { if dim > 2 { print!(", nz = {}", num_xyz[2]); } - print!("\n"); + println!(); } // Build ElemRestriction objects describing the mesh and solution discrete @@ -199,9 +210,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 +291,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 +330,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..1d69aca19e 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; @@ -45,17 +47,20 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { quiet, gallery, } = options; - assert!(dim >= 1 && dim <= 3); + assert!((0..=3).contains(&dim)); assert!(mesh_degree >= 1); assert!(solution_degree >= 1); assert!(num_qpts >= 1); let ncomp_x = dim; - let problem_size: i64; - if problem_size_requested < 0 { - problem_size = if test { 8 * 16 } else { 256 * 1024 }; + let problem_size: i64 = if problem_size_requested < 0 { + if test { + 8 * 16 + } else { + 256 * 1024 + } } else { - problem_size = problem_size_requested; - } + problem_size_requested + }; let ncomp_u = 3; // Summary output @@ -77,14 +82,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 @@ -97,7 +107,7 @@ fn example_3(options: opt::Opt) -> libceed::Result<()> { if dim > 2 { print!(", nz = {}", num_xyz[2]); } - print!("\n"); + println!(); } // Build ElemRestriction objects describing the mesh and solution discrete @@ -166,9 +176,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 +227,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 +265,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..65915d9957 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; @@ -46,21 +48,20 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { quiet, gallery, } = options; - assert!(dim >= 1 && dim <= 3); + assert!((0..=3).contains(&dim)); assert!(mesh_degree >= 1); assert!(solution_degree >= 1); assert!(num_qpts >= 1); let ncomp_x = dim; - let problem_size: i64; - if problem_size_requested < 0 { - problem_size = if test { + let problem_size: i64 = if problem_size_requested < 0 { + if test { 16 * 16 * (dim * dim) as i64 } else { 256 * 1024 - }; + } } else { - problem_size = problem_size_requested; - } + problem_size_requested + }; let ncomp_u = 3; // Summary output @@ -82,14 +83,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 @@ -102,7 +108,7 @@ fn example_4(options: opt::Opt) -> libceed::Result<()> { if dim > 2 { print!(", nz = {}", num_xyz[2]); } - print!("\n"); + println!(); } // Build ElemRestriction objects describing the mesh and solution discrete @@ -206,9 +212,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 +307,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 +355,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 2e719097e7..08a3f64218 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)?; @@ -343,7 +343,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; @@ -416,7 +416,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; @@ -436,7 +436,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; @@ -456,7 +456,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; @@ -477,7 +477,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; @@ -506,7 +506,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 081e08c61b..e535a73ad2 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; @@ -328,7 +328,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; @@ -357,7 +357,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; @@ -386,7 +386,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; @@ -426,7 +426,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; @@ -469,7 +469,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; @@ -495,7 +495,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; @@ -520,7 +520,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; @@ -546,7 +546,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; @@ -571,7 +571,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; @@ -597,7 +597,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 b248aa9fa7..31f5a8681c 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 // ----------------------------------------------------------------------------- @@ -308,7 +309,7 @@ impl Ceed { // Call to libCEED let mut ptr = std::ptr::null_mut(); - let mut ierr = unsafe { bind_ceed::CeedInit(c_resource.as_ptr() as *const i8, &mut ptr) }; + let mut ierr = unsafe { bind_ceed::CeedInit(c_resource.as_ptr(), &mut ptr) }; if ierr != 0 { panic!("Error initializing backend resource: {}", resource) } @@ -427,7 +428,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; @@ -486,7 +487,7 @@ impl Ceed { /// orientation. /// /// ``` - /// # use libceed::prelude::*; + /// # use libceed::{prelude::*, MemType}; /// # fn main() -> libceed::Result<()> { /// # let ceed = libceed::Ceed::default_init(); /// let nelem = 3; @@ -550,7 +551,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; @@ -719,7 +720,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)?; @@ -755,7 +756,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 = [ @@ -886,7 +887,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 = [ @@ -983,7 +984,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 = [ @@ -1077,7 +1078,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| { @@ -1135,7 +1136,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 828ac5b998..61b8e44218 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 @@ -61,14 +67,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -108,14 +114,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -180,14 +186,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -242,14 +248,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -340,14 +346,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; -/// let q = 4 as usize; +/// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -380,13 +386,13 @@ 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(); /// /// // Sub operator field arguments /// let ne = 3; -/// let q = 4 as usize; +/// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -571,14 +577,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -612,7 +618,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; @@ -690,7 +696,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; @@ -770,7 +776,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")?; @@ -802,7 +808,7 @@ impl<'a> Operator<'a> { v: impl Into>, ) -> crate::Result { let fieldname = CString::new(fieldname).expect("CString::new failed"); - let fieldname = fieldname.as_ptr() as *const i8; + let fieldname = fieldname.as_ptr(); self.op_core.check_error(unsafe { bind_ceed::CeedOperatorSetField( self.op_core.ptr, @@ -818,14 +824,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -860,7 +866,7 @@ impl<'a> Operator<'a> { &mut num_inputs, &mut inputs_ptr, std::ptr::null_mut() as *mut bind_ceed::CeedInt, - std::ptr::null_mut() as *mut *mut bind_ceed::CeedOperatorField, + std::ptr::null_mut(), ) })?; // Convert raw C pointers to fixed length slice @@ -888,14 +894,14 @@ 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")?; /// /// // Operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -928,7 +934,7 @@ impl<'a> Operator<'a> { bind_ceed::CeedOperatorGetFields( self.op_core.ptr, std::ptr::null_mut() as *mut bind_ceed::CeedInt, - std::ptr::null_mut() as *mut *mut bind_ceed::CeedOperatorField, + std::ptr::null_mut(), &mut num_outputs, &mut outputs_ptr, ) @@ -958,7 +964,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; @@ -1001,7 +1007,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")?; @@ -1038,7 +1044,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")?; @@ -1085,7 +1091,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; @@ -1192,7 +1198,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; @@ -1304,7 +1310,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; @@ -1443,7 +1449,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; @@ -1575,7 +1581,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; @@ -1734,7 +1740,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; @@ -1892,7 +1898,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(); @@ -1924,7 +1930,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; @@ -2082,7 +2088,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(); @@ -2127,13 +2133,13 @@ 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(); /// /// // Sub operator field arguments /// let ne = 3; - /// let q = 4 as usize; + /// let q = 4_usize; /// let mut ind: Vec = vec![0; 2 * ne]; /// for i in 0..ne { /// ind[2 * i + 0] = i as i32; @@ -2184,7 +2190,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; @@ -2281,7 +2287,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; @@ -2377,7 +2383,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()?; @@ -2403,7 +2409,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 f5b746eefd..a876c71c0e 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; @@ -108,7 +108,7 @@ impl<'a> QFunctionField<'a> { unsafe { bind_ceed::CeedQFunctionFieldGetEvalMode(self.ptr, &mut mode); } - crate::EvalMode::from_u32(mode as u32) + crate::EvalMode::from_u32(mode) } } @@ -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| { @@ -467,7 +467,7 @@ impl<'a> QFunctionCore<'a> { }) } - 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(); @@ -477,20 +477,17 @@ impl<'a> QFunctionCore<'a> { &mut num_inputs, &mut inputs_ptr, std::ptr::null_mut() as *mut bind_ceed::CeedInt, - std::ptr::null_mut() as *mut *mut bind_ceed::CeedQFunctionField, + std::ptr::null_mut(), ) })?; // 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(); @@ -498,17 +495,14 @@ impl<'a> QFunctionCore<'a> { bind_ceed::CeedQFunctionGetFields( self.ptr, std::ptr::null_mut() as *mut bind_ceed::CeedInt, - std::ptr::null_mut() as *mut *mut bind_ceed::CeedQFunctionField, + std::ptr::null_mut(), &mut num_outputs, &mut outputs_ptr, ) })?; // 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) } @@ -658,7 +652,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| { @@ -726,7 +720,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| { @@ -776,7 +770,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| { @@ -818,7 +812,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| { @@ -842,14 +836,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| { @@ -872,7 +866,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() } } @@ -903,7 +897,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; @@ -976,7 +970,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() } @@ -995,7 +989,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 3394ecd870..6134e40c52 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()); @@ -166,7 +166,7 @@ impl<'a> VectorSliceWrapper<'a> { ) })?; Ok(Self { - vector: unsafe { crate::Vector::from_raw(vec.ptr_copy_mut()?)? }, + vector: unsafe { Vector::from_raw(vec.ptr_copy_mut()?)? }, _slice: slice, }) } @@ -272,7 +272,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.])?; @@ -286,7 +286,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 { self.check_error(unsafe { bind_ceed::CeedVectorCopy(vec_source.ptr, self.ptr) }) } @@ -300,7 +300,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(()) /// # } @@ -418,7 +418,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)?; @@ -453,7 +453,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)?; @@ -495,7 +495,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 @@ -505,7 +505,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; @@ -577,7 +577,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.])?; @@ -608,7 +608,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.])?; @@ -634,7 +634,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.])?; @@ -648,7 +648,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 { self.check_error(unsafe { bind_ceed::CeedVectorAXPY(self.ptr, alpha, x.ptr) })?; Ok(self) } @@ -662,7 +662,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.])?; @@ -680,7 +680,7 @@ impl<'a> Vector<'a> { mut self, alpha: crate::Scalar, beta: crate::Scalar, - x: &crate::Vector, + x: &Vector, ) -> crate::Result { self.check_error(unsafe { bind_ceed::CeedVectorAXPBY(self.ptr, alpha, beta, x.ptr) })?; Ok(self) @@ -694,7 +694,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.])?; @@ -709,7 +709,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 { self.check_error(unsafe { bind_ceed::CeedVectorPointwiseMult(self.ptr, x.ptr, y.ptr) })?; Ok(self) } @@ -721,7 +721,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.])?; @@ -735,7 +735,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 { self.check_error(unsafe { bind_ceed::CeedVectorPointwiseMult(self.ptr, self.ptr, x.ptr) })?; Ok(self) } @@ -743,7 +743,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.])?; @@ -787,10 +787,7 @@ impl<'a> VectorView<'a> { &mut array, ) })?; - Ok(Self { - vec: vec, - array: array, - }) + Ok(Self { vec, array }) } } @@ -839,10 +836,7 @@ impl<'a> VectorViewMut<'a> { &mut ptr, ) })?; - Ok(Self { - vec: vec, - array: ptr, - }) + Ok(Self { vec, array: ptr }) } }