WIP Polymorphic sparse scheme to solve following use case (#46) #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Let us consider a Finite-Element or Finite-Volume code for which we have to solve a linear system using different libraries (Hypre, Petsc, Trilinos, Mumps, PastiX, ...). We would like to avoid conversions between different formats of sparse matrix. As the linear solver drives the choice of the sparse matrix format, we would like that the matrix the FE code has to fill has directly the format the linear solver requires. The choice of the solver is done at runtime, so it means that the underlying sparse scheme of the matrix should be instanciated at runtime. It implies that the sparse array or sparse tensor is a wrapper around a polymorphic sparse scheme. This latter is a bridge over an abstract scheme that uses type erasure to handle the different format implementations.
The following piece of code tries to illustrate which problem we try to solve. Let us say that we have wrapped several linear solvers into a minimal common API, namely MyLinearSolver. According to the choice of the linear solver, we want the Finite Volume solver to fill the sparse matrix
A
in the format that the linear solver requires. This choice is done after, for instance reading options in a file. It is thus at runtime that everything should work.