23 #ifndef __SPARSITY_PATTERN_H 24 #define __SPARSITY_PATTERN_H 28 #include <unordered_map> 32 #include <dolfin/common/ArrayView.h> 33 #include <dolfin/common/MPI.h> 34 #include <dolfin/common/Set.h> 35 #include <dolfin/common/types.h> 56 enum class Type {sorted, unsorted};
63 std::vector<std::shared_ptr<const IndexMap>> index_maps,
64 std::size_t primary_dim);
67 void init(std::vector<std::shared_ptr<const IndexMap>> index_maps);
92 std::size_t
rank()
const;
97 {
return _primary_dim; }
100 std::pair<std::size_t, std::size_t>
local_range(std::size_t dim)
const;
127 {
return _mpi_comm.comm(); }
130 std::string
str(
bool verbose)
const;
154 void info_statistics()
const;
158 const std::size_t _primary_dim;
164 std::vector<std::shared_ptr<const IndexMap>> _index_maps;
167 std::vector<set_type> diagonal;
168 std::vector<set_type> off_diagonal;
178 std::vector<std::size_t> non_local;
void init(std::vector< std::shared_ptr< const IndexMap >> index_maps)
Initialize sparsity pattern for a generic tensor.
Definition: SparsityPattern.cpp:49
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: SparsityPattern.cpp:485
SparsityPattern(MPI_Comm comm, std::size_t primary_dim)
Create empty sparsity pattern.
Definition: SparsityPattern.cpp:35
Definition: SparsityPattern.h:45
Type
Whether SparsityPattern is sorted.
Definition: SparsityPattern.h:56
Definition: IndexMap.h:35
std::vector< std::vector< std::size_t > > diagonal_pattern(Type type) const
Definition: SparsityPattern.cpp:512
void num_local_nonzeros(std::vector< std::size_t > &num_nonzeros) const
Definition: SparsityPattern.cpp:355
void num_nonzeros_diagonal(std::vector< std::size_t > &num_nonzeros) const
Definition: SparsityPattern.cpp:305
std::pair< std::size_t, std::size_t > local_range(std::size_t dim) const
Return local range for dimension dim.
Definition: SparsityPattern.cpp:277
std::vector< std::vector< std::size_t > > off_diagonal_pattern(Type type) const
Definition: SparsityPattern.cpp:545
void apply()
Finalize sparsity pattern.
Definition: SparsityPattern.cpp:368
Definition: ArrayView.h:31
MPI_Comm mpi_comm() const
Return MPI communicator.
Definition: SparsityPattern.h:126
void insert_local(const std::vector< ArrayView< const dolfin::la_index >> &entries)
Insert non-zero entries using local (process-wise) indices.
Definition: SparsityPattern.cpp:130
void num_nonzeros_off_diagonal(std::vector< std::size_t > &num_nonzeros) const
Definition: SparsityPattern.cpp:327
PetscInt la_index
Index type for compatibility with linear algebra backend(s)
Definition: types.h:32
void insert_global(dolfin::la_index i, dolfin::la_index j)
Insert a global entry - will be fixed by apply()
Definition: SparsityPattern.cpp:99
std::size_t primary_dim() const
Definition: SparsityPattern.h:96
std::size_t rank() const
Return rank.
Definition: SparsityPattern.cpp:271
void insert_local_global(const std::vector< ArrayView< const dolfin::la_index >> &entries)
Definition: SparsityPattern.cpp:149
void insert_full_rows_local(const std::vector< std::size_t > &rows)
Definition: SparsityPattern.cpp:258
std::size_t num_nonzeros() const
Return number of local nonzeros.
Definition: SparsityPattern.cpp:283