math-fem
Multigrid Finite Element Method (FEM) solver for the Helmholtz equation, optimized for acoustics.
Installation
Add to your Cargo.toml:
[]
= { = "0.3" }
Features
- 2D and 3D meshes: Triangles, quadrilaterals, tetrahedra, hexahedra
- Lagrange elements: P1, P2, P3 polynomial basis functions
- Boundary conditions: Dirichlet, Neumann, Robin (impedance/absorption), PML
- Optimized Assembly:
HelmholtzAssemblerfor efficient frequency sweeps without CSR topology reconstruction - Multigrid solver: V-cycle, W-cycle with geometric coarsening
- Parallel processing: Rayon-based parallel matrix and RHS assembly
- Room Acoustics Simulator: CLI tool for frequency-domain room simulation
Usage
use ;
use HelmholtzAssembler;
use Complex64;
// Create a 3D mesh for a room
let mesh = box_mesh_tetrahedra;
// Create an efficient assembler
let assembler = new;
// Assemble system for a specific frequency (wavenumber k)
let k = new; // k = omega/c + i*damping
let system_matrix = assembler.assemble;
Binaries
roomsim-fem
A high-performance room acoustics simulator. It supports:
- Rectangular and L-shaped geometries
- Configurable wall absorption and impedance
- Directional sound sources with crossovers
- Hierarchical warm-starting for fast frequency sweeps
Documentation: Room Simulator Guide | JSON Schema
Modules
mesh
Mesh generators for common domains:
use *;
// 3D box mesh with tetrahedra
let box_tet = box_mesh_tetrahedra;
basis
Lagrange polynomial basis functions (P1, P2, P3).
boundary
Boundary condition handling including Robin (Impedance) conditions for acoustics.
assembly
High-performance matrix assembly:
- Stiffness & Mass: Stored as
f64for memory efficiency. - HelmholtzAssembler: Pre-assembles sparsity patterns for lightning-fast frequency updates.
- Boundary Mass: Efficiently integrates terms over boundary surfaces.
multigrid
Geometric multigrid solver for large systems.
Element Types
| Element | Dimension | Nodes (P1) | Nodes (P2) |
|---|---|---|---|
| Triangle | 2D | 3 | 6 |
| Quadrilateral | 2D | 4 | 9 |
| Tetrahedron | 3D | 4 | 10 |
| Hexahedron | 3D | 8 | 27 |
Feature Flags
native(default) - Enables rayon parallelism and hardware-specific BLASparallel- Enables rayon for parallel assemblycli- Enables CLI dependencies forroomsim-fem
Dependencies
math-solvers- Iterative solvers (GMRES, AMG, Schwarz)math-xem-common- Shared room acoustics types and configurationsndarray- N-dimensional arrays for numerical computingnum-complex- Complex number support for Helmholtz systems