hp-FEM
Adaptive hp-FEM suite for nano-optics
Loading...
Searching...
No Matches
Public Member Functions | List of all members
hpfem::solvers::LinearSolver Class Referenceabstract

Factorise once, solve for many right-hand sides. More...

#include <linear_solver.hpp>

Public Member Functions

 LinearSolver ()=default
 
 LinearSolver (const LinearSolver &)=delete
 
LinearSolver & operator= (const LinearSolver &)=delete
 
 LinearSolver (LinearSolver &&)=delete
 
LinearSolver & operator= (LinearSolver &&)=delete
 
virtual ~LinearSolver ()=default
 
virtual void factorize (const SparseMatrix &matrix)=0
 
virtual void refactorize (const SparseMatrix &matrix)
 
virtual Vector solve (const Vector &rhs) const =0
 
virtual Matrix solve_many (const Matrix &rhs) const
 
virtual Vector solve_transposed (const Vector &rhs) const
 
virtual Matrix solve_transposed_many (const Matrix &rhs) const
 
virtual Index size () const noexcept=0
 
virtual std::string name () const =0
 
virtual std::string details () const
 
virtual Index factor_entries () const noexcept
 
virtual const LinearSolver * backend () const noexcept
 

Detailed Description

Factorise once, solve for many right-hand sides.

Constructor & Destructor Documentation

◆ LinearSolver() [1/3]

hpfem::solvers::LinearSolver::LinearSolver ( )
default

◆ LinearSolver() [2/3]

hpfem::solvers::LinearSolver::LinearSolver ( const LinearSolver &  )
delete

◆ LinearSolver() [3/3]

hpfem::solvers::LinearSolver::LinearSolver ( LinearSolver &&  )
delete

◆ ~LinearSolver()

virtual hpfem::solvers::LinearSolver::~LinearSolver ( )
virtualdefault

Member Function Documentation

◆ backend()

virtual const LinearSolver * hpfem::solvers::LinearSolver::backend ( ) const
inlinevirtualnoexcept

The solver doing the work: the object itself, or for kAuto the backend it chose in factorize (null before). Lets GPU-side algorithms recognise the cuDSS backend.

◆ details()

virtual std::string hpfem::solvers::LinearSolver::details ( ) const
inlinevirtual

Backend-specific facts about the current factorisation for logs and benchmarks (entries in the factors, memory, mode); empty before factorize or if the backend has nothing to say.

◆ factor_entries()

virtual Index hpfem::solvers::LinearSolver::factor_entries ( ) const
inlinevirtualnoexcept

Entries of the factors of the current factorisation (L + U, or L of an LDLᵀ path), the quantity estimate_memory predicts; -1 before factorize or if the backend does not report it.

◆ factorize()

virtual void hpfem::solvers::LinearSolver::factorize ( const SparseMatrix &  matrix)
pure virtual
Exceptions
Errorif the matrix is singular or the factorisation fails.

◆ name()

virtual std::string hpfem::solvers::LinearSolver::name ( ) const
pure virtual

◆ operator=() [1/2]

LinearSolver & hpfem::solvers::LinearSolver::operator= ( const LinearSolver &  )
delete

◆ operator=() [2/2]

LinearSolver & hpfem::solvers::LinearSolver::operator= ( LinearSolver &&  )
delete

◆ refactorize()

virtual void hpfem::solvers::LinearSolver::refactorize ( const SparseMatrix &  matrix)
inlinevirtual

Factorises another matrix with the sparsity pattern of the last one, reusing the symbolic analysis (ordering, elimination tree): MUMPS runs its numerical phase only, SparseLU keeps its column permutation; cuDSS factorises anew. Falls back to factorize when nothing was factorised yet or the pattern differs (same result, no reuse). Sweeps that change values but not structure — frequency, materials, Bloch phases — call this per point (physics::ConicalSweep).

◆ size()

virtual Index hpfem::solvers::LinearSolver::size ( ) const
pure virtualnoexcept

◆ solve()

virtual Vector hpfem::solvers::LinearSolver::solve ( const Vector &  rhs) const
pure virtual
Exceptions
Errorif factorize has not succeeded or the size does not match.

◆ solve_many()

virtual Matrix hpfem::solvers::LinearSolver::solve_many ( const Matrix &  rhs) const
virtual

Several right-hand sides at once (one per column); backends with a native multi-rhs solve override this, the default solves column by column.

Exceptions
Errorif factorize has not succeeded or the row count does not match.

◆ solve_transposed()

virtual Vector hpfem::solvers::LinearSolver::solve_transposed ( const Vector &  rhs) const
virtual

Solves with the transposed matrix, \( A^\top x = b \) (transposed, not conjugated), on the current factorisation: the adjoint systems of the sensitivities (ADR-0012). A complex-symmetric factorisation (the LDLᵀ paths) solves with A itself; SparseLU and MUMPS use their factors transposed; cuDSS factorises Aᵀ on the first call after a (re)factorisation of a general matrix and keeps it (twice the device memory).

Exceptions
Errorif factorize has not succeeded or the backend has no transposed solve, InvalidArgument if the size does not match.

◆ solve_transposed_many()

virtual Matrix hpfem::solvers::LinearSolver::solve_transposed_many ( const Matrix &  rhs) const
virtual

Several right-hand sides of the transposed system at once (one per column); the default solves column by column.

Exceptions
Errorif factorize has not succeeded, InvalidArgument if the row count does not match.

The documentation for this class was generated from the following file: