|
hp-FEM
Adaptive hp-FEM suite for nano-optics
|
Classes | |
| struct | ComplexEigenResult |
Result of complex_eigenpairs_near: eigenvalues ordered by distance to the shift. More... | |
| class | DeviceArnoldi |
| class | DeviceMatrix |
| class | DeviceStepper |
| struct | EigenOptions |
| struct | EigenResult |
| class | LinearSolver |
| Factorise once, solve for many right-hand sides. More... | |
| struct | MemoryEstimate |
| class | ReducedBasis |
Enumerations | |
| enum class | DirectSolverBackend { kAuto , kSparseLu , kMumps , kCudss } |
| Direct solver backends. More... | |
| enum class | Symmetry { kGeneral , kComplexSymmetric , kDetect } |
|
strong |
Direct solver backends.
| Enumerator | |
|---|---|
| kAuto | cuDSS for systems of at least |
| kSparseLu | Eigen SparseLU, always available. |
| kMumps | MUMPS (multifrontal, zmumps), needs |
| kCudss | NVIDIA cuDSS on the GPU, needs |
|
strong |
Structure of the system matrix that a backend may exploit. The caller guarantees it: a complex-symmetric matrix (A = Aᵀ, not Hermitian — the curl–curl operators with symmetric material tensors, PML and Dirichlet elimination, also after static condensation and hanging-node constraints; not with Bloch phases) lets cuDSS and MUMPS factorise one triangle (LDLᵀ, about half the work and memory). SparseLU ignores it.
| Real hpfem::solvers::asymmetry | ( | const SparseMatrix & | matrix | ) |
Largest |a_ij − a_ji| relative to the largest |a_ij| (0 for a symmetric matrix); one pass over the nonzeros with a binary search of the mirrored entry per row, no copy.
|
noexcept |
True if the backend can be used in this build (kAuto always).
| std::vector< DirectSolverBackend > hpfem::solvers::available_backends | ( | ) |
All backends usable in this build.
| std::string hpfem::solvers::backend_name | ( | DirectSolverBackend | backend | ) |
| ComplexEigenResult hpfem::solvers::complex_eigenpairs_near | ( | const SparseMatrix & | a, |
| const SparseMatrix & | b, | ||
| Complex | sigma, | ||
| const EigenOptions & | options = {}, |
||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto |
||
| ) |
Eigenpairs of the complex pencil \( A x = \lambda B x \) closest to a complex shift σ: shift-invert Arnoldi on \( (A - \sigma B)^{-1} B \) with a direct factorisation (backend), modified Gram–Schmidt, explicit restarts from the wanted Ritz vectors and the relative residual \( |h_{m+1,m}\,y_m| / | heta| \) as convergence test. Lossy media, PML and complex frequencies are allowed: this is the solver of the resonance (quasi-normal mode) problems. Both matrices are scaled to O(1) internally. options.shift is ignored (σ is the argument). Eigenvectors are B-independent unit 2-norm vectors.
| InvalidArgument | for mismatched matrices, Error if the factorisation fails or no eigenvalue converges within max_iterations restarts. |
| ComplexEigenResult hpfem::solvers::complex_eigenpairs_near_gauged | ( | const SparseMatrix & | a, |
| const SparseMatrix & | b, | ||
| const SparseMatrix & | gradient, | ||
| Complex | sigma, | ||
| const EigenOptions & | options = {}, |
||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto |
||
| ) |
As complex_eigenpairs_near with the gradient kernel removed: every Arnoldi vector is projected B-orthogonally onto the complement of range(G), \( P = I - G (G^H B G)^{-1} G^H B \), so the eigenvalues at zero of a curl–curl pencil (gradients of the H1 space, possibly Bloch-reduced) never appear. For Bloch-periodic band structures with complex Hermitian matrices (physics::BandStructure).
| Error | if \( G^H B G \) is singular. |
| std::string hpfem::solvers::cudss_status | ( | ) |
Why the cuDSS backend is (un)available in this process: library path, versions and device if usable, otherwise the loading error. Never throws.
| Symmetry hpfem::solvers::detect_symmetry | ( | const SparseMatrix & | matrix, |
| Real | tolerance = 1e-12 |
||
| ) |
kComplexSymmetric if asymmetry(matrix) <= tolerance, otherwise kGeneral: what the problem classes pass to the direct solvers, so that symmetric curl–curl systems take the LDLᵀ paths and systems with Bloch phases or non-symmetric material tensors do not. Costs one pass over the nonzeros (O(nnz log n), far below a factorisation).
| MemoryEstimate hpfem::solvers::estimate_memory | ( | const fespace::NedelecDofMap< Dim > & | dofs, |
| DirectSolverBackend | backend = DirectSolverBackend::kAuto, |
||
| bool | condensed = true, |
||
| const fespace::DofMap< Dim > * | longitudinal = nullptr |
||
| ) |
Estimate for the system of a Nédélec map (the in-plane Maxwell operator), optionally with an H1 map coupled block-wise (the conical solver, longitudinal), on the backend; condensed drops the cell-interior DoFs as Scattering does by default (not available with a longitudinal map). The matrix nonzeros are \( r_{d,p}\sum_K n_K^2 \) with the overlap ratio r of the H(curl) pattern, the factor entries \( c\,N\log_2N \) (2D) and \( c\,N^{4/3} \) (3D) for the nested-dissection backends and \( c_p N^{1.25} \) (2D), \( c_p N^{1.63} \) (3D) for SparseLU with COLAMD.
| InvalidArgument | if condensed is combined with a longitudinal map or the maps live on different meshes. |
| MemoryEstimate hpfem::solvers::estimate_memory | ( | const mesh::Mesh< Dim > & | mesh, |
| int | order, | ||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto, |
||
| bool | conical = false |
||
| ) |
The same for a uniform order on the mesh: the in-plane solver (condensed) or, with conical, the conical solver (Nédélec + H1, not condensed).
| InvalidArgument | for order < 1. |
| bool hpfem::solvers::exploit_symmetry | ( | Symmetry | symmetry, |
| const SparseMatrix & | matrix, | ||
| const char * | backend | ||
| ) |
Backend helper: whether a factorisation with the given request takes the symmetric path (kDetect measures the matrix and logs the result at debug level; kComplexSymmetric is verified in Debug builds, kGeneral is never checked).
| InvalidArgument | in Debug builds if kComplexSymmetric was requested for a non-symmetric matrix. |
| std::string hpfem::solvers::format_bytes | ( | std::size_t | bytes | ) |
Human-readable byte count, "1.2 GB" / "230 MB" / "12 kB".
| EigenResult hpfem::solvers::gauged_curl_curl_eigenpairs | ( | const SparseMatrix & | stiffness, |
| const SparseMatrix & | mass, | ||
| const SparseMatrix & | gradient, | ||
| std::span< const Index > | free_nedelec, | ||
| std::span< const Index > | free_h1, | ||
| const EigenOptions & | options = {}, |
||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto |
||
| ) |
Smallest eigenpairs of \( S x = \lambda M x \) on the free DoFs, with the gradient kernel removed: every Lanczos vector is projected M-orthogonally onto the complement of range(G) ( \( P = I - G (G^T M G)^{-1} G^T M \)), so the zero eigenvalues of the curl operator never appear and the returned values are the physical resonances. Shift-invert Lanczos (Spectra) with a direct factorisation of \( S - \sigma M \): backend kAuto and kSparseLu keep Eigen's real SparseLU (real arithmetic, half the memory), kMumps / kCudss factorise the complexified shifted matrix with that backend (one factorisation, one solve per Lanczos step; the gauge matrix \( G^T M G \) stays with SparseLU).
S, M, G are the full matrices (Nédélec × Nédélec, Nédélec × H1); free_nedelec and free_h1 list the unconstrained DoFs (PEC removes the tangential DoFs of the Nédélec space and the corresponding H1 boundary DoFs). Lossless media only: the imaginary parts of S and M must vanish.
| InvalidArgument | for complex matrices, Error if the iteration fails to converge. |
| EigenResult hpfem::solvers::generalized_eigenpairs_near | ( | const SparseMatrix & | a, |
| const SparseMatrix & | b, | ||
| Real | sigma, | ||
| const EigenOptions & | options = {}, |
||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto |
||
| ) |
Eigenpairs of \( A x = \lambda B x \) closest to σ for real sparse A and B, where B may be indefinite and A singular (waveguide mode pencils): Arnoldi (Spectra) on the real nonsymmetric operator \( (A - \sigma B)^{-1} B \) with a direct factorisation (backend as in gauged_curl_curl_eigenpairs: kAuto keeps the real SparseLU), eigenvalues \( \lambda = \sigma + 1/\nu \). Results are real (imaginary parts of the Ritz values must be negligible, otherwise Error); eigenvectors have unit 2-norm and the size of A. options.shift is ignored (σ is the argument).
| InvalidArgument | for complex or mismatched matrices, Error on non-convergence. |
| Index hpfem::solvers::gpu_min_unknowns | ( | ) |
Size from which kAuto prefers cuDSS: the CMake cache variable HPFEM_GPU_MIN_UNKNOWNS (default 10000, where the GPU factorisation draws level with sequential MUMPS on the RTX 3090, ADR-0008), overridden at run time by the environment variable of the same name; 0 means always cuDSS, a negative value never. Read on every call.
| std::unique_ptr< LinearSolver > hpfem::solvers::make_cudss | ( | Symmetry | symmetry = Symmetry::kGeneral | ) |
NVIDIA cuDSS (LU on the GPU, factors stay on the device): the backend for many solves of one factorisation (time stepping, Arnoldi, sweeps). The solver lives in the separately built hpfem_gpu library (gpu/README.md), found through HPFEM_GPU_DLL. With kComplexSymmetric only the upper triangle goes to the device (cuDSS LDLᵀ).
| Error | if the library was not compiled with HPFEM_ENABLE_CUDA, the hpfem_gpu library cannot be loaded or no CUDA device is present. |
| std::unique_ptr< LinearSolver > hpfem::solvers::make_direct_solver | ( | DirectSolverBackend | backend = DirectSolverBackend::kAuto, |
| Symmetry | symmetry = Symmetry::kGeneral |
||
| ) |
The requested backend; kAuto returns a solver that picks the backend in factorize (name() reports "auto" before and "auto: <backend>" after the choice). The GPU library is only loaded when cuDSS is actually chosen.
| Error | if the backend is not available. |
| std::unique_ptr< LinearSolver > hpfem::solvers::make_mumps | ( | Symmetry | symmetry = Symmetry::kGeneral | ) |
MUMPS multifrontal LU (sequential build, complex double, automatic ordering; SYM = 2 LDLᵀ on the upper triangle for kComplexSymmetric); the backend of choice for 3D and for many right-hand sides.
| Error | if the library was not compiled in. |
| std::unique_ptr< LinearSolver > hpfem::solvers::make_sparse_lu | ( | Symmetry | symmetry = Symmetry::kGeneral | ) |
Eigen's supernodal sparse LU with COLAMD ordering; general (non-symmetric) complex matrices, O(fill) memory. Adequate up to a few 10^5 unknowns in 2D.
| Vector hpfem::solvers::solve_direct | ( | const SparseMatrix & | matrix, |
| const Vector & | rhs, | ||
| DirectSolverBackend | backend = DirectSolverBackend::kAuto, |
||
| Symmetry | symmetry = Symmetry::kGeneral |
||
| ) |
Factorise and solve in one go.
| SparseMatrix hpfem::solvers::upper_triangle | ( | const SparseMatrix & | matrix | ) |
Upper triangle (column ≥ row) of a square matrix, compressed; the input of the LDLᵀ paths.