Classes | |
| struct | Range |
Public Member Functions | |
| IndexSet () | |
| IndexSet (const unsigned int size) | |
| void | set_size (const unsigned int size) |
| unsigned int | size () const |
| void | add_range (const unsigned int begin, const unsigned int end) |
| void | add_index (const unsigned int index) |
| template<typename ForwardIterator > | |
| void | add_indices (const ForwardIterator &begin, const ForwardIterator &end) |
| void | add_indices (const IndexSet &other) |
| bool | is_element (const unsigned int index) const |
| bool | is_contiguous () const |
| unsigned int | n_elements () const |
| unsigned int | nth_index_in_set (const unsigned int local_index) const |
| unsigned int | index_within_set (const unsigned int global_index) const |
| unsigned int | n_intervals () const |
| void | compress () const |
| bool | operator== (const IndexSet &is) const |
| bool | operator!= (const IndexSet &is) const |
| IndexSet | operator& (const IndexSet &is) const |
| IndexSet | get_view (const unsigned int begin, const unsigned int end) const |
| void | subtract_set (const IndexSet &other) |
| void | fill_index_vector (std::vector< unsigned int > &indices) const |
| template<class STREAM > | |
| void | print (STREAM &out) const |
| void | write (std::ostream &out) const |
| void | read (std::istream &in) |
| void | block_write (std::ostream &out) const |
| void | block_read (std::istream &in) |
| Epetra_Map | make_trilinos_map (const MPI_Comm &communicator=MPI_COMM_WORLD, const bool overlapping=false) const |
| std::size_t | memory_consumption () const |
| template<class Archive > | |
| void | serialize (Archive &ar, const unsigned int version) |
Static Public Member Functions | |
| ::ExceptionBase & | ExcIndexNotPresent (int arg1) throw (errortext << "The global index " << arg1 << " is not an element of this set." ) |
Private Member Functions | |
| void | do_compress () const |
Private Attributes | |
| std::vector< Range > | ranges |
| bool | is_compressed |
| unsigned int | index_space_size |
| unsigned int | largest_range |
A class that represents a subset of indices among a larger set. For example, it can be used to denote the set of degrees of freedom within the range
that belongs to a particular subdomain, or those among all degrees of freedom that are stored on a particular processor in a distributed parallel computation.
This class can represent a collection of half-open ranges of indices as well as individual elements. For practical purposes it also stores the overall range these indices can assume. In other words, you need to specify the size of the index space
of which objects of this class are a subset.
The data structures used in this class along with a rationale can be found in the Distributed Computing paper.
Definition at line 54 of file index_set.h.
| IndexSet::IndexSet | ( | ) | [inline] |
Default constructor.
Definition at line 552 of file index_set.h.
| IndexSet::IndexSet | ( | const unsigned int | size ) | [inline] |
Constructor that also sets the overall size of the index range.
Definition at line 562 of file index_set.h.
| void IndexSet::set_size | ( | const unsigned int | size ) | [inline] |
Set the maximal size of the indices upon which this object operates.
This function can only be called if the index set does not yet contain any elements.
Definition at line 573 of file index_set.h.
References Assert, StandardExceptions::ExcMessage(), index_space_size, is_compressed, and ranges.
| unsigned int IndexSet::size | ( | ) | const [inline] |
Return the size of the index space of which this index set is a subset of.
Note that the result is not equal to the number of indices within this set. The latter information is returned by n_elements().
Definition at line 586 of file index_set.h.
References index_space_size.
Referenced by CompressedSimpleSparsityPattern::add(), CompressedSimpleSparsityPattern::add_entries(), ConstraintMatrix::calculate_line_index(), ConstraintMatrix::can_store_line(), CompressedSimpleSparsityPattern::column_number(), index_within_set(), is_element(), operator!=(), operator==(), CompressedSimpleSparsityPattern::row_begin(), CompressedSimpleSparsityPattern::row_end(), and CompressedSimpleSparsityPattern::row_length().
Add the half-open range
to the set of indices represented by this class.
Definition at line 607 of file index_set.h.
References Assert, StandardExceptions::ExcIndexRange(), index_space_size, is_compressed, Utilities::lower_bound(), and ranges.
Referenced by add_indices().
| void IndexSet::add_index | ( | const unsigned int | index ) | [inline] |
Add an individual index to the set of indices.
Definition at line 641 of file index_set.h.
References Assert, StandardExceptions::ExcIndexRange(), index_space_size, is_compressed, Utilities::lower_bound(), and ranges.
| void IndexSet::add_indices | ( | const ForwardIterator & | begin, |
| const ForwardIterator & | end | ||
| ) | [inline] |
Add a whole set of indices described by dereferencing every element of the the iterator range [begin,end).
Definition at line 664 of file index_set.h.
References add_range().
| void IndexSet::add_indices | ( | const IndexSet & | other ) | [inline] |
Add the given IndexSet other to the current one, constructing the union of *this and other.
Definition at line 692 of file index_set.h.
References add_range(), compress(), and ranges.
Return whether the specified index is an element of the index set.
Definition at line 711 of file index_set.h.
References Assert, compress(), StandardExceptions::ExcInternalError(), largest_range, ranges, and size().
Referenced by CompressedSimpleSparsityPattern::add(), CompressedSimpleSparsityPattern::add_entries(), ConstraintMatrix::calculate_line_index(), ConstraintMatrix::can_store_line(), CompressedSimpleSparsityPattern::column_number(), index_within_set(), and CompressedSimpleSparsityPattern::row_length().
| bool IndexSet::is_contiguous | ( | ) | const [inline] |
Return whether the index set stored by this object defines a contiguous range. This is true also if no indices are stored at all.
Definition at line 780 of file index_set.h.
References compress(), and ranges.
| unsigned int IndexSet::n_elements | ( | ) | const [inline] |
Return the number of elements stored in this index set.
Definition at line 790 of file index_set.h.
References Assert, IndexSet::Range::begin, compress(), IndexSet::Range::end, StandardExceptions::ExcInternalError(), IndexSet::Range::nth_index_in_set, and ranges.
Referenced by nth_index_in_set().
Return the global index of the local index with number local_index stored in this index set. local_index obviously needs to be less than n_elements().
Definition at line 819 of file index_set.h.
References Assert, StandardExceptions::ExcIndexRange(), StandardExceptions::ExcInternalError(), StandardExceptions::ExcMessage(), numbers::invalid_unsigned_int, is_compressed, largest_range, Utilities::lower_bound(), n_elements(), IndexSet::Range::nth_index_compare(), IndexSet::Range::nth_index_in_set, and ranges.
Return the how-manyth element of this set (counted in ascending order) global_index is. global_index needs to be less than the size(). This function throws an exception if the index global_index is not actually a member of this index set, i.e. if is_element(global_index) is false.
Definition at line 870 of file index_set.h.
References Assert, IndexSet::Range::end_compare(), ExcIndexNotPresent(), StandardExceptions::ExcIndexRange(), StandardExceptions::ExcInternalError(), StandardExceptions::ExcMessage(), is_compressed, is_element(), largest_range, Utilities::lower_bound(), ranges, and size().
Referenced by CompressedSimpleSparsityPattern::add(), CompressedSimpleSparsityPattern::add_entries(), ConstraintMatrix::calculate_line_index(), CompressedSimpleSparsityPattern::column_number(), CompressedSimpleSparsityPattern::row_begin(), CompressedSimpleSparsityPattern::row_end(), and CompressedSimpleSparsityPattern::row_length().
| unsigned int IndexSet::n_intervals | ( | ) | const |
Each index set can be represented as the union of a number of contiguous intervals of indices, where if necessary intervals may only consist of individual elements to represent isolated members of the index set.
This function returns the minimal number of such intervals that are needed to represent the index set under consideration.
| void IndexSet::compress | ( | ) | const [inline] |
Compress the internal representation by merging individual elements with contiguous ranges, etc. This function does not have any external effect.
Definition at line 595 of file index_set.h.
References do_compress(), and is_compressed.
Referenced by add_indices(), is_contiguous(), is_element(), n_elements(), operator!=(), operator==(), and print().
Comparison for equality of index sets. This operation is only allowed if the size of the two sets is the same (though of course they do not have to have the same number of indices).
Definition at line 913 of file index_set.h.
References Assert, compress(), StandardExceptions::ExcDimensionMismatch(), ranges, and size().
Comparison for inequality of index sets. This operation is only allowed if the size of the two sets is the same (though of course they do not have to have the same number of indices).
Definition at line 928 of file index_set.h.
References Assert, compress(), StandardExceptions::ExcDimensionMismatch(), ranges, and size().
Return the intersection of the current index set and the argument given, i.e. a set of indices that are elements of both index sets. The two index sets must have the same size (though of course they do not have to have the same number of indices).
This command takes an interval [begin, end) and returns the intersection of the current index set with the interval, shifted to the range [0, end-begin).
| void IndexSet::subtract_set | ( | const IndexSet & | other ) |
Removes all elements contained in other from this set. In other words, if
is the current object and
the argument, then we compute
.
| void IndexSet::fill_index_vector | ( | std::vector< unsigned int > & | indices ) | const |
Fills the given vector with all indices contained in this IndexSet.
| void IndexSet::print | ( | STREAM & | out ) | const [inline] |
Outputs a text representation of this IndexSet to the given stream. Used for testing.
Definition at line 942 of file index_set.h.
References compress(), and ranges.
| void IndexSet::write | ( | std::ostream & | out ) | const |
| void IndexSet::read | ( | std::istream & | in ) |
| void IndexSet::block_write | ( | std::ostream & | out ) | const |
Writes the IndexSet into a binary, compact representation, that can be read in again using the block_read() function.
| void IndexSet::block_read | ( | std::istream & | in ) |
Constructs the IndexSet from a binary representation given by the stream
| in | written by the write_block() function. |
| Epetra_Map IndexSet::make_trilinos_map | ( | const MPI_Comm & | communicator = MPI_COMM_WORLD, |
| const bool | overlapping = false |
||
| ) | const |
Given an MPI communicator, create a Trilinos map object that represents a distribution of vector elements or matrix rows in which we will locally store those elements or rows for which we store the index in the current index set, and all the other elements/rows elsewhere on one of the other MPI processes.
The last argument only plays a role if the communicator is a parallel one, distributing computations across multiple processors. In that case, if the last argument is false, then it is assumed that the index sets this function is called on on all processors are mutually exclusive but together enumerate each index exactly once. In other words, if you call this function on two processors, then the index sets this function is called with must together have all possible indices from zero to size()-1, and no index must appear in both index sets. This corresponds, for example, to the case where we want to split the elements of vectors into unique subsets to be stored on different processors -- no element should be owned by more than one processor, but each element must be owned by one.
On the other hand, if the second argument is true, then the index sets can be overlapping, though they still need to contain each index exactly once on all processors taken together. This is a useful operation if we want to create vectors that not only contain the locally owned indices, but for example also the elements that correspond to degrees of freedom located on ghost cells.
| std::size_t IndexSet::memory_consumption | ( | ) | const |
Determine an estimate for the memory consumption (in bytes) of this object.
| ::ExceptionBase& IndexSet::ExcIndexNotPresent | ( | int | arg1 ) | throw (errortext << "The global index " << arg1 << " is not an element of this set." ) [static] |
Referenced by index_within_set().
| void IndexSet::serialize | ( | Archive & | ar, |
| const unsigned int | version | ||
| ) | [inline] |
Write or read the data of this object to or from a stream for the purpose of serialization
Definition at line 975 of file index_set.h.
References index_space_size, is_compressed, largest_range, and ranges.
| void IndexSet::do_compress | ( | ) | const [private] |
Actually perform the compress() operation.
Referenced by compress().
std::vector<Range> IndexSet::ranges [mutable, private] |
A set of contiguous ranges of indices that make up (part of) this index set. This variable is always kept sorted.
The variable is marked "mutable" so that it can be changed by compress(), though this of course doesn't change anything about the external representation of this index set.
Definition at line 482 of file index_set.h.
Referenced by add_index(), add_indices(), add_range(), index_within_set(), is_contiguous(), is_element(), n_elements(), nth_index_in_set(), operator!=(), operator==(), print(), serialize(), and set_size().
bool IndexSet::is_compressed [mutable, private] |
True if compress() has been called after the last change in the set of indices.
The variable is marked "mutable" so that it can be changed by compress(), though this of course doesn't change anything about the external representation of this index set.
Definition at line 497 of file index_set.h.
Referenced by add_index(), add_range(), compress(), index_within_set(), nth_index_in_set(), serialize(), and set_size().
unsigned int IndexSet::index_space_size [private] |
The overall size of the index range. Elements of this index set have to have a smaller number than this value.
Definition at line 505 of file index_set.h.
Referenced by add_index(), add_range(), serialize(), set_size(), and size().
unsigned int IndexSet::largest_range [mutable, private] |
This integer caches the index of the largest range in ranges. This gives O(1) access to the range with most elements, while general access costs O(log(n_ranges)). The largest range is needed for the methods is_element(), index_within_set(), nth_index_in_set. In many applications, the largest range contains most elements (the locally owned range), whereas there are only a few other elements (ghosts).
Definition at line 522 of file index_set.h.
Referenced by index_within_set(), is_element(), nth_index_in_set(), and serialize().
documentation generated on Fri Feb 3 2012 06:04:09 by
doxygen
1.7.2