Skip to main content

Module gpu

Module gpu 

Source
Expand description

GPU-accelerated kernels for physics simulations.

When compiled with the gpu feature, this module exposes dispatchers that attempt to offload finite-element stress assembly, the Navier-Stokes pressure-Poisson solve, and heat-diffusion stencil updates onto a GPU compute backend supplied by scirs2_core. When the gpu feature is disabled (the default), every dispatcher returns GpuError::BackendUnavailable immediately so callers can fall back to the existing CPU paths without conditional compilation at the call site.

This mirrors the SAMM W3-S12 GPU pattern: feature-gated, default off, pure-Rust default surface, opt-in C/Fortran via the gpu feature.

§Layout

§Feature gate

Enable via Cargo.toml:

[dependencies]
oxirs-physics = { version = "*", features = ["gpu"] }

§Example

use oxirs_physics::gpu::{GpuElementDescriptor, GpuError, StressAssemblyDispatcher};

let dispatcher = StressAssemblyDispatcher::new();
let elements = vec![GpuElementDescriptor::default(); 8];
let result = dispatcher.dispatch_stiffness_assembly(&elements);
// Without `gpu` feature: Err(GpuError::BackendUnavailable)

Re-exports§

pub use heat_kernel::HeatKernelDispatcher;
pub use navier_stokes_kernel::NavierStokesKernelDispatcher;
pub use stress_assembly::FemElementKind;
pub use stress_assembly::GpuElementContribution;
pub use stress_assembly::GpuElementDescriptor;
pub use stress_assembly::StressAssemblyDispatcher;

Modules§

heat_kernel
GPU-accelerated heat-diffusion stencil dispatcher.
navier_stokes_kernel
GPU-accelerated Navier-Stokes pressure-Poisson dispatcher.
stress_assembly
GPU-accelerated FEM stress assembly dispatcher.

Enums§

GpuError
Errors that can arise when using a GPU dispatch path.

Functions§

backend_available
Whether the underlying compute backend is available at runtime.

Type Aliases§

GpuResult
Result type for GPU dispatch operations.