Skip to content

Draft: Add support for partial matrix patterns to ISTLMatrixBackend and global assembler

This adds support for assembling into matrices with 'partial' pattern, i.e. matrices, whose pattern do not contain entries for all pairs of basis functions that share an element. To this end it introduces the following:

  • Add ISTLMatrixBackend::addToEntry(row,col,value).
    This method adds a value to an entry. In contrast to matrixBackend(row,col) += value, the new matrixBackend.addToEntry(row,col,value) can ignore nonexisting entries to support e.g. DiagonalMatrix.
  • Use backend.addToEntry(row, col, value) instead of backend(row, col) += value in global assembler.
  • Test partial pattern with local DiagonalMatrix and ScaledIdentityMatrix by assembling a mass matrix.

This is currently marked WIP, because:

  • I'm not fully convinced by the way this is implemented in the backend. While the current solution works, it is a little hard to understand.
  • The behavior and difference of operator()(row, col), operator()(row, col) const, and addToEntry(row,col,value) should be documented carefully.
  • This only partially solves #25. While it allows to use the global operator assembler with partial pattern, this does not happen with optimal efficiency, because the global assembler still tries to write all entries (but non-existing ones are ignored by the backend).
  • This needs proper testing.

An extension to at least technically allow (semi) optimal efficiency would be to let the backend fully handle the distribution of the local matrix. Then one would use something like backend.accumulateEntries(rowIndices, colIndices, localMatrix) in the global assembler. The default implementation could do what is proposed in the present MR. But one could then provide a custom backend that only touches the needed entries. However, this custom backend would not just be a specialization for the matrix type but also rely on some knowledge of the used index scheme.

Merge request reports

Loading