Struct libceed::qfunction::QFunction[][src]

pub struct QFunction<'a> { /* fields omitted */ }

Implementations

impl<'a> QFunction<'a>[src]

pub fn create(
    ceed: &'a Ceed,
    vlength: usize,
    user_f: Box<QFunctionUserClosure>
) -> Result<Self, CeedError>
[src]

pub fn apply(
    &self,
    Q: usize,
    u: &[Vector<'_>],
    v: &[Vector<'_>]
) -> Result<i32, CeedError>
[src]

Apply the action of a QFunction

  • Q - The number of quadrature points
  • input - Array of input Vectors
  • output - Array of output Vectors
let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
    // Iterate over quadrature points
    v.iter_mut()
        .zip(u.iter().zip(weights.iter()))
        .for_each(|(v, (u, w))| *v = u * w);

    // Return clean error code
    0
};

let qf = ceed
    .q_function_interior(1, Box::new(user_f))
    .unwrap()
    .input("u", 1, EvalMode::Interp)
    .unwrap()
    .input("weights", 1, EvalMode::Weight)
    .unwrap()
    .output("v", 1, EvalMode::Interp)
    .unwrap();

const Q: usize = 8;
let mut w = [0.; Q];
let mut u = [0.; Q];
let mut v = [0.; Q];

for i in 0..Q {
    let x = 2. * (i as f64) / ((Q as f64) - 1.) - 1.;
    u[i] = 2. + 3. * x + 5. * x * x;
    w[i] = 1. - x * x;
    v[i] = u[i] * w[i];
}

let uu = ceed.vector_from_slice(&u).unwrap();
let ww = ceed.vector_from_slice(&w).unwrap();
let mut vv = ceed.vector(Q).unwrap();
vv.set_value(0.0);
{
    let input = vec![uu, ww];
    let mut output = vec![vv];
    qf.apply(Q, &input, &output).unwrap();
    vv = output.remove(0);
}

vv.view()
    .iter()
    .zip(v.iter())
    .for_each(|(computed, actual)| {
        assert_eq!(
            *computed, *actual,
            "Incorrect value in QFunction application"
        );
    });

pub fn input(
    self,
    fieldname: &str,
    size: usize,
    emode: EvalMode
) -> Result<Self, CeedError>
[src]

Add a QFunction input

  • fieldname - Name of QFunction field
  • size - Size of QFunction field, (ncomp * dim) for Grad or (ncomp * 1) for None, Interp, and Weight
  • emode - EvalMode::None to use values directly, EvalMode::Interp to use interpolated values, EvalMode::Grad to use gradients, EvalMode::Weight to use quadrature weights
let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
    // Iterate over quadrature points
    v.iter_mut()
        .zip(u.iter().zip(weights.iter()))
        .for_each(|(v, (u, w))| *v = u * w);

    // Return clean error code
    0
};

let mut qf = ceed.q_function_interior(1, Box::new(user_f)).unwrap();

qf = qf.input("u", 1, EvalMode::Interp).unwrap();
qf = qf.input("weights", 1, EvalMode::Weight).unwrap();

pub fn output(
    self,
    fieldname: &str,
    size: usize,
    emode: EvalMode
) -> Result<Self, CeedError>
[src]

Add a QFunction output

  • fieldname - Name of QFunction field
  • size - Size of QFunction field, (ncomp * dim) for Grad or (ncomp * 1) for None and Interp
  • emode - EvalMode::None to use values directly, EvalMode::Interp to use interpolated values, EvalMode::Grad to use gradients
let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
    // Iterate over quadrature points
    v.iter_mut()
        .zip(u.iter().zip(weights.iter()))
        .for_each(|(v, (u, w))| *v = u * w);

    // Return clean error code
    0
};

let mut qf = ceed.q_function_interior(1, Box::new(user_f)).unwrap();

qf.output("v", 1, EvalMode::Interp).unwrap();

Trait Implementations

impl<'a> Display for QFunction<'a>[src]

View a QFunction

let mut user_f = |[u, weights, ..]: QFunctionInputs, [v, ..]: QFunctionOutputs| {
    // Iterate over quadrature points
    v.iter_mut()
        .zip(u.iter().zip(weights.iter()))
        .for_each(|(v, (u, w))| *v = u * w);

    // Return clean error code
    0
};

let qf = ceed
    .q_function_interior(1, Box::new(user_f))
    .unwrap()
    .input("u", 1, EvalMode::Interp)
    .unwrap()
    .input("weights", 1, EvalMode::Weight)
    .unwrap()
    .output("v", 1, EvalMode::Interp)
    .unwrap();

println!("{}", qf);

impl<'a> Drop for QFunction<'a>[src]

impl<'a> From<&'a QFunction<'_>> for QFunctionOpt<'a>[src]

Construct a QFunctionOpt reference from a QFunction reference

Auto Trait Implementations

impl<'a> !RefUnwindSafe for QFunction<'a>

impl<'a> !Send for QFunction<'a>

impl<'a> !Sync for QFunction<'a>

impl<'a> Unpin for QFunction<'a>

impl<'a> !UnwindSafe for QFunction<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.