19 #ifndef LIBMESH_SPARSITY_PATTERN_H
20 #define LIBMESH_SPARSITY_PATTERN_H
23 #include "libmesh/elem_range.h"
24 #include "libmesh/threads_allocators.h"
25 #include "libmesh/parallel_object.h"
29 #include <unordered_set>
49 namespace SparsityPattern
51 typedef std::vector<dof_id_type, Threads::scalable_allocator<dof_id_type>>
Row;
52 class Graph :
public std::vector<Row> {};
65 template<
typename B
idirectionalIterator>
66 static void sort_row (
const BidirectionalIterator begin,
67 BidirectionalIterator middle,
68 const BidirectionalIterator end);
85 std::vector<dof_id_type> & n_nz,
86 std::vector<dof_id_type> & n_oz) = 0;
106 const CouplingMatrix * dof_coupling_in,
107 const std::set<GhostingFunctor *> & coupling_functors_in,
108 const bool implicit_neighbor_dofs_in,
109 const bool need_full_sparsity_pattern_in,
110 const bool calculate_constrained_in =
false);
132 void operator()(
const ConstElemRange & range);
185 std::vector<dof_id_type> &
n_nz,
186 std::vector<dof_id_type> &
n_oz,
220 void handle_vi_vj(
const std::vector<dof_id_type> & element_dofs_i,
221 const std::vector<dof_id_type> & element_dofs_j);
224 std::vector<dof_id_type> & dofs_vi,
227 #ifndef LIBMESH_ENABLE_DEPRECATED
246 template<
typename B
idirectionalIterator>
249 BidirectionalIterator middle,
250 const BidirectionalIterator end)
254 libmesh_assert(std::is_sorted(begin, middle));
255 libmesh_assert(std::is_sorted(middle, end));
257 libmesh_assert(std::unique(begin, middle) == middle);
258 libmesh_assert(std::unique(middle, end) == end);
260 std::inplace_merge(begin, middle, end);
264 libmesh_assert (std::is_sorted(begin,end));
268 libmesh_assert (std::unique (begin, end) == end);
273 #endif // LIBMESH_SPARSITY_PATTERN_H
SparsityPattern::Graph sparsity_pattern
const SparsityPattern::Graph & get_sparsity_pattern() const
Rows of sparse matrix indices, indexed by the offset from the first DoF on this processor.
This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the...
const std::set< GhostingFunctor * > & coupling_functors
void apply_extra_sparsity_function(void(*func)(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context), void *context)
Let a user-provided function modify our sparsity structure.
const bool calculate_constrained
const bool implicit_neighbor_dofs
const bool need_full_sparsity_pattern
void parallel_sync()
Send sparsity pattern data relevant to other processors to those processors, and receive and incorpor...
std::unordered_set< dof_id_type > hashed_dof_sets
Build(const DofMap &dof_map_in, const CouplingMatrix *dof_coupling_in, const std::set< GhostingFunctor * > &coupling_functors_in, const bool implicit_neighbor_dofs_in, const bool need_full_sparsity_pattern_in, const bool calculate_constrained_in=false)
const std::vector< dof_id_type > & get_n_oz() const
The number of off-processor nonzeros in my portion of the global matrix.
This class handles the numbering of degrees of freedom on a mesh.
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
void join(const Build &other)
Combine the sparsity pattern in other with this object's sparsity pattern.
const CouplingMatrix * dof_coupling
void sorted_connected_dofs(const Elem *elem, std::vector< dof_id_type > &dofs_vi, unsigned int vi)
const std::vector< dof_id_type > & get_n_nz() const
The number of on-processor nonzeros in my portion of the global matrix.
std::vector< dof_id_type > n_nz
const SparsityPattern::NonlocalGraph & get_nonlocal_pattern() const
Rows of sparse matrix indices, mapped from global DoF number, which belong on other processors...
void apply_extra_sparsity_object(SparsityPattern::AugmentSparsityPattern &asp)
Let a user-provided AugmentSparsityPattern subclass modify our sparsity structure.
SparsityPattern::NonlocalGraph nonlocal_pattern
void clear_full_sparsity()
Clear the "full" details of our sparsity structure, leaving only the counts of non-zero entries...
void handle_vi_vj(const std::vector< dof_id_type > &element_dofs_i, const std::vector< dof_id_type > &element_dofs_j)
void operator()(const ConstElemRange &range)
Add entries from a range of elements to this object's sparsity pattern.
virtual void augment_sparsity_pattern(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz)=0
User-defined function to augment the sparsity pattern.
virtual ~AugmentSparsityPattern()=default
Abstract base class to be used to add user-defined implicit degree of freedom couplings.
Build & operator=(const Build &)=delete
static void sort_row(const BidirectionalIterator begin, BidirectionalIterator middle, const BidirectionalIterator end)
Splices the two sorted ranges [begin,middle) and [middle,end) into one sorted range [begin...
std::vector< dof_id_type > n_oz