qfunction.rs (ce18bed930e8f3bfebcf709a18844aba97fe4630) qfunction.rs (a71fcd9fac4e7a8dfa69a197fd7b41b8f31fd6a3)
1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8//! A Ceed QFunction represents the spatial terms of the point-wise functions

--- 554 unchanged lines hidden (view full) ---

563 })
564 .zip(outputs_array.iter_mut())
565 .for_each(|(x, a)| *a = x);
566
567 // User closure
568 (trampoline_data.get_unchecked_mut().user_f)(inputs_array, outputs_array)
569}
570
1// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3//
4// SPDX-License-Identifier: BSD-2-Clause
5//
6// This file is part of CEED: http://github.com/ceed
7
8//! A Ceed QFunction represents the spatial terms of the point-wise functions

--- 554 unchanged lines hidden (view full) ---

563 })
564 .zip(outputs_array.iter_mut())
565 .for_each(|(x, a)| *a = x);
566
567 // User closure
568 (trampoline_data.get_unchecked_mut().user_f)(inputs_array, outputs_array)
569}
570
571unsafe extern "C" fn destroy_trampoline(ctx: *mut ::std::os::raw::c_void) -> ::std::os::raw::c_int {
572 let trampoline_data: Pin<&mut QFunctionTrampolineData> = std::mem::transmute(ctx);
573 drop(trampoline_data);
574 0 // Clean error code
575}
576
571// -----------------------------------------------------------------------------
572// QFunction
573// -----------------------------------------------------------------------------
574impl<'a> QFunction<'a> {
575 // Constructor
576 pub fn create(
577 ceed: &crate::Ceed,
578 vlength: usize,

--- 39 unchanged lines hidden (view full) ---

618 qf_ctx_ptr,
619 crate::MemType::Host as bind_ceed::CeedMemType,
620 crate::CopyMode::UsePointer as bind_ceed::CeedCopyMode,
621 std::mem::size_of::<QFunctionTrampolineData>() as u64,
622 std::mem::transmute(trampoline_data.as_ref()),
623 )
624 };
625 ceed.check_error(ierr)?;
577// -----------------------------------------------------------------------------
578// QFunction
579// -----------------------------------------------------------------------------
580impl<'a> QFunction<'a> {
581 // Constructor
582 pub fn create(
583 ceed: &crate::Ceed,
584 vlength: usize,

--- 39 unchanged lines hidden (view full) ---

624 qf_ctx_ptr,
625 crate::MemType::Host as bind_ceed::CeedMemType,
626 crate::CopyMode::UsePointer as bind_ceed::CeedCopyMode,
627 std::mem::size_of::<QFunctionTrampolineData>() as u64,
628 std::mem::transmute(trampoline_data.as_ref()),
629 )
630 };
631 ceed.check_error(ierr)?;
632 ierr = unsafe {
633 bind_ceed::CeedQFunctionContextSetDataDestroy(
634 qf_ctx_ptr,
635 crate::MemType::Host as bind_ceed::CeedMemType,
636 Some(destroy_trampoline),
637 )
638 };
639 ceed.check_error(ierr)?;
626 ierr = unsafe { bind_ceed::CeedQFunctionSetContext(ptr, qf_ctx_ptr) };
627 ceed.check_error(ierr)?;
628 Ok(Self {
629 qf_core: QFunctionCore {
630 ptr,
631 _lifeline: PhantomData,
632 },
633 qf_ctx_ptr,

--- 357 unchanged lines hidden ---
640 ierr = unsafe { bind_ceed::CeedQFunctionSetContext(ptr, qf_ctx_ptr) };
641 ceed.check_error(ierr)?;
642 Ok(Self {
643 qf_core: QFunctionCore {
644 ptr,
645 _lifeline: PhantomData,
646 },
647 qf_ctx_ptr,

--- 357 unchanged lines hidden ---