|
|
| PetscStencil ()=default |
| | Default constructor. Creates an empty stencil.
|
|
| ~PetscStencil ()=default |
| | Destructor.
|
|
void | clear () |
| | Remove all entries from the stencil.
|
| int | size () const noexcept |
| | Get the number of entries in the stencil.
|
| PetscInt | row (const int a_entry) const noexcept |
| | Get the PETSc row of a stencil entry.
|
| PetscScalar | weight (const int a_entry) const noexcept |
| | Get the weight of a stencil entry.
|
| void | add (const PetscInt &a_row, const PetscScalar &a_weight) noexcept |
| | Append an entry to this stencil.
|
| PetscStencil & | operator+= (const PetscStencil &a_otherStencil) noexcept |
| | Append all entries of another stencil to this stencil.
|
| void | compress () noexcept |
| | Sort the entries by row and merge entries with the same row by summing their weights.
|
| PetscStencil & | operator*= (const PetscScalar &a_scalingFactor) noexcept |
| | Scale all weights in this stencil.
|
A linear stencil over global PETSc rows, i.e. a list of (row, weight) pairs.
This plays the role that VoFStencil plays for Chombo data, but each entry is a global PETSc row rather than a VolIndex. A VoFStencil entry is only meaningful together with the level and grid patch it was built on, whereas a PetscStencil entry can be passed directly to MatSetValues.
Entries are appended by add() and operator+= without looking for an existing entry with the same row, so a row can appear more than once until compress() is called. compress() sorts the entries by row and merges duplicates, which makes the rows unique and ascending. Duplicates are summed in the order they were added, so the result is the same as merging on every add, bit for bit. Call compress() before passing the entries to MatSetValues: duplicate rows would be summed with ADD_VALUES but would overwrite each other with INSERT_VALUES. Building a stencil of N entries this way costs O(N log N), compared with O(N^2) for merging on every add; at a hundred entries the difference is roughly a factor of three to five.