-----------------------------------------------------------------------------
| 185 | } |
| 186 | //----------------------------------------------------------------------------- |
| 187 | void SparsityPattern::insert_diagonal(std::span<const std::int32_t> rows) |
| 188 | { |
| 189 | if (!_offsets.empty()) |
| 190 | { |
| 191 | throw std::runtime_error( |
| 192 | "Cannot insert into sparsity pattern. It has already been finalized"); |
| 193 | } |
| 194 | |
| 195 | assert(_index_maps[0]); |
| 196 | const std::int32_t max_row |
| 197 | = _index_maps[0]->size_local() + _index_maps[0]->num_ghosts() - 1; |
| 198 | |
| 199 | for (std::int32_t row : rows) |
| 200 | { |
| 201 | if (row > max_row or row < 0) |
| 202 | { |
| 203 | throw std::runtime_error( |
| 204 | "Cannot insert rows that do not exist in the IndexMap."); |
| 205 | } |
| 206 | |
| 207 | _row_cache[row].push_back(row); |
| 208 | } |
| 209 | } |
| 210 | //----------------------------------------------------------------------------- |
| 211 | std::shared_ptr<const common::IndexMap> |
| 212 | SparsityPattern::index_map(int dim) const |