MCPcopy Create free account
hub / github.com/FEniCS/dolfinx / insert_diagonal

Method insert_diagonal

cpp/dolfinx/la/SparsityPattern.cpp:187–209  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

185}
186//-----------------------------------------------------------------------------
187void 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//-----------------------------------------------------------------------------
211std::shared_ptr<const common::IndexMap>
212SparsityPattern::index_map(int dim) const

Callers 5

test_add_diagonalFunction · 0.95
_Function · 0.80
_assemble_matrix_csrFunction · 0.80
laFunction · 0.80

Calls 2

size_localMethod · 0.80
num_ghostsMethod · 0.80

Tested by 2

test_add_diagonalFunction · 0.76