fdrmrc / Polydeal

C++ implementation of Polygonal Discontinuous Galerkin method within the deal.II Finite Element library.
https://fdrmrc.github.io/Polydeal/
Other
0 stars 0 forks source link

Add basic interface to create level matrices out of matrix-free operators #109

Closed fdrmrc closed 3 months ago

fdrmrc commented 7 months ago

Depends on #107, commits from c1bff53 on are relevant.

Adds a preliminary interface to create level matrices from matrix-free operators evaluation. The interface does not depend on AgglomerationHandler, though it can be used externally to distribute DoFs on agglomerated levels.

This class takes just a matrix-free operator and a sequence of two-level-type transfers (Trilinos matrices):

    MatrixFreeProjector(
      const MatrixFreeOperators::
        Base<dim, LinearAlgebra::distributed::Vector<Number>> &mf_operator,
      const std::vector<TrilinosWrappers::SparseMatrix *>      transfers);

and internally stores LinearOperators which define the action of Galerkin projections on levels.


Tested locally, I plan to add a unit test for this soon I've added a test for this with $3$ MPI ranks and both structured and unstructured meshes.

Given the Laplace operator evaluation on the fine level, a coarser level is generated using the R-tree on each partition and the projection matrix $P$ is built. Then, the scalar product induced by the weak form is computed for $A$ and $\tilde{A}=P^T A P$, .i.e. $$x^T A x$$ or $$x^T \tilde{A} x$$ where $x$ is the interpolant of the following functions on the fine or coarse space, respectively:

Since we know the gradients of such functions, we can check the correctness of the scalar product.

Here's part of the output, where different grid types and functions are checked.

Running with 3 MPI ranks.
Grid type: Structured square
Total number of available levels: 5
Total fine agglomerates: 66
Distributed DoFs
Injection matrix has size: (16384,264)
Scalar product induced by fine operator: 0
Scalar product induced by agglomerated operator: 3.62691e-30

Running with 3 MPI ranks.
Grid type: Unstructured square
Total number of available levels: 6
Total fine agglomerates: 93
Distributed DoFs
Injection matrix has size: (93184,372)
Scalar product induced by fine operator: 0
Scalar product induced by agglomerated operator: 3.12216e-29

Running with 3 MPI ranks.
Grid type: Structured square
Total number of available levels: 5
Total fine agglomerates: 66
Distributed DoFs
Injection matrix has size: (16384,264)
Scalar product induced by fine operator: 1
Scalar product induced by agglomerated operator: 1

Running with 3 MPI ranks.
Grid type: Unstructured square
Total number of available levels: 6
Total fine agglomerates: 93
Distributed DoFs
Injection matrix has size: (93184,372)
Scalar product induced by fine operator: 1
Scalar product induced by agglomerated operator: 1

@luca-heltai Are there similar sanity checks for such matrices that could be done?