Skip to main content

math_audio_bem/core/solver/
mod.rs

1//! Linear solvers for BEM
2//!
3//! This module provides various solvers for BEM systems, re-exporting
4//! functionality from `math-solvers`.
5//!
6//! - [`direct`] - Direct LU factorization
7//! - `cgs` - Conjugate Gradient Squared
8//! - `bicgstab` - BiCGSTAB
9//! - `gmres` - GMRES (recommended for large BEM problems)
10//! - [`fmm_interface`] - Interface to use FMM operators with iterative solvers
11//! - `preconditioner` - Preconditioners (ILU, AMG, etc.)
12//! - [`batched_blas`] - Batched BLAS operations (native only)
13
14#[cfg(feature = "native")]
15pub mod batched_blas;
16pub mod fmm_interface;
17
18// Re-export core solver functionality from math-solvers
19pub use math_audio_solvers::direct;
20// Modules are private in math-solvers, so we can't re-export them directly.
21// We access their contents via the iterative module or specific re-exports.
22
23pub use math_audio_solvers::traits::{LinearOperator, Preconditioner};
24
25// Core operator types from fmm_interface
26pub use fmm_interface::{CsrOperator, DenseOperator, DiagonalPreconditioner, MlfmmOperator};
27
28#[cfg(any(feature = "native", feature = "wasm"))]
29pub use fmm_interface::SlfmmOperator;
30
31// Helper functions for solving BEM systems
32pub use fmm_interface::{
33    gmres_solve_tbem_with_ilu, gmres_solve_with_ilu, gmres_solve_with_ilu_operator, solve_bicgstab,
34    solve_cgs, solve_gmres, solve_tbem_with_ilu, solve_with_ilu, solve_with_ilu_operator,
35};
36
37// Hierarchical FMM preconditioner
38#[cfg(any(feature = "native", feature = "wasm"))]
39pub use fmm_interface::{
40    HierarchicalFmmPreconditioner, SparseNearfieldIlu, gmres_solve_fmm_hierarchical,
41    gmres_solve_with_hierarchical_precond,
42};
43
44// Batched BLAS solvers
45#[cfg(feature = "native")]
46pub use fmm_interface::{gmres_solve_fmm_batched, gmres_solve_fmm_batched_with_ilu};
47
48// Adaptive mesh utilities
49pub use fmm_interface::{
50    AdaptiveMeshConfig, estimate_element_count, mesh_resolution_for_frequency_range,
51    recommended_mesh_resolution,
52};
53
54// Re-export specific configuration types for convenience
55pub use math_audio_solvers::iterative::{BiCgstabConfig, BiCgstabSolution};
56pub use math_audio_solvers::iterative::{CgsConfig, CgsSolution};
57pub use math_audio_solvers::iterative::{GmresConfig, GmresSolution};
58pub use math_audio_solvers::preconditioners::IluPreconditioner;
59pub use math_audio_solvers::preconditioners::{AmgConfig, AmgPreconditioner};
60
61// Batched BLAS operations (native only)
62#[cfg(feature = "native")]
63pub use batched_blas::{
64    SlfmmMatvecWorkspace, batched_d_matrix_apply, batched_near_field_apply, batched_s_matrix_apply,
65    batched_t_matrix_apply, create_batched_matvec, slfmm_matvec_batched,
66};