21 #ifndef __TENSOR_LAYOUT_H 22 #define __TENSOR_LAYOUT_H 29 #include "dolfin/common/types.h" 30 #include "dolfin/common/MPI.h" 35 class SparsityPattern;
47 enum class Sparsity : bool { SPARSE =
true, DENSE =
false };
50 enum class Ghosts : bool { GHOSTED =
true, UNGHOSTED =
false };
58 std::vector<std::shared_ptr<const IndexMap>> index_maps,
59 std::size_t primary_dim,
64 void init(std::vector<std::shared_ptr<const IndexMap>> index_maps,
68 std::size_t
rank()
const;
72 std::size_t
size(std::size_t i)
const;
75 std::pair<std::size_t, std::size_t>
local_range(std::size_t dim)
const;
79 {
return _sparsity_pattern; }
83 {
return _sparsity_pattern; }
86 std::string
str(
bool verbose)
const;
93 {
return _mpi_comm.comm(); }
96 std::shared_ptr<const IndexMap>
index_map(std::size_t i)
const 98 dolfin_assert(i < _index_maps.size());
99 return _index_maps[i];
114 std::vector<std::shared_ptr<const IndexMap>> _index_maps;
117 std::shared_ptr<SparsityPattern> _sparsity_pattern;
120 Ghosts _ghosted = Ghosts::UNGHOSTED;
Sparsity
Sparse or dense layout.
Definition: TensorLayout.h:47
Common base class for DOLFIN variables.
Definition: Variable.h:35
std::size_t rank() const
Return rank.
Definition: TensorLayout.cpp:64
MPI_Comm mpi_comm() const
Return MPI communicator.
Definition: TensorLayout.h:92
std::pair< std::size_t, std::size_t > local_range(std::size_t dim) const
Return local range for dimension dim.
Definition: TensorLayout.cpp:76
std::shared_ptr< const IndexMap > index_map(std::size_t i) const
Return IndexMap for dimension.
Definition: TensorLayout.h:96
const std::size_t primary_dim
Primary storage dim (e.g., 0=row major, 1=column major)
Definition: TensorLayout.h:89
Ghosts
Ghosted or unghosted layout.
Definition: TensorLayout.h:50
Definition: TensorLayout.h:41
std::shared_ptr< const SparsityPattern > sparsity_pattern() const
Return sparsity pattern (possibly null), const version.
Definition: TensorLayout.h:82
std::shared_ptr< SparsityPattern > sparsity_pattern()
Return sparsity pattern (possibly null)
Definition: TensorLayout.h:78
TensorLayout(MPI_Comm comm, std::size_t primary_dim, Sparsity sparsity_pattern)
Create empty tensor layout.
Definition: TensorLayout.cpp:29
void init(std::vector< std::shared_ptr< const IndexMap >> index_maps, Ghosts ghosted)
Initialize tensor layout.
Definition: TensorLayout.cpp:53
Ghosts is_ghosted() const
Require ghosts.
Definition: TensorLayout.h:103
std::string str(bool verbose) const
Return informal string representation (pretty-print)
Definition: TensorLayout.cpp:83
std::size_t size(std::size_t i) const
Definition: TensorLayout.cpp:69