Struct libceed::qfunction::QFunction [−][src]
Implementations
impl<'a> QFunction<'a>
[src]
pub fn create(
ceed: &'a Ceed,
vlength: usize,
user_f: Box<QFunctionUserClosure>
) -> Result<Self, CeedError>
[src]
ceed: &'a Ceed,
vlength: usize,
user_f: Box<QFunctionUserClosure>
) -> Result<Self, CeedError>
pub fn apply(
&self,
Q: usize,
u: &[Vector<'_>],
v: &[Vector<'_>]
) -> Result<i32, CeedError>
[src]
&self,
Q: usize,
u: &[Vector<'_>],
v: &[Vector<'_>]
) -> Result<i32, CeedError>
Apply the action of a QFunction
Q
- The number of quadrature pointsinput
- Array of input Vectorsoutput
- 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]
self,
fieldname: &str,
size: usize,
emode: EvalMode
) -> Result<Self, CeedError>
Add a QFunction input
fieldname
- Name of QFunction fieldsize
- Size of QFunction field,(ncomp * dim)
forGrad
or(ncomp * 1)
forNone
,Interp
, andWeight
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]
self,
fieldname: &str,
size: usize,
emode: EvalMode
) -> Result<Self, CeedError>
Add a QFunction output
fieldname
- Name of QFunction fieldsize
- Size of QFunction field,(ncomp * dim)
forGrad
or(ncomp * 1)
forNone
andInterp
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,