* indirect addressing into a larger set of ghost indices. This setup is
* useful if a distributed vector is based on that larger ghost index
* set but only a tighter subset should be communicated according to
- * @p larger_ghost_index_set.
+ * @p ghost_indices.
*/
void set_ghost_indices (const IndexSet &ghost_indices,
const IndexSet &larger_ghost_index_set = IndexSet());
* i.e., the entries that a remote processor sent to the calling
* process. Its size must either be n_ghost_indices() or equal the
* number of ghost indices in the larger index set that was given as
- * second argument to set_ghost_indices().
+ * second argument to set_ghost_indices(). In case only selected indices
+ * are sent, no guarantee is made regarding the entries that do not get
+ * set. Some of them might be used to organize the transfer and later
+ * reset to zero, so make sure you do not use them in computations.
*
* @param requests The list of MPI requests for the ongoing non-blocking
* communication that will be finalized in the
<< "Global index " << arg1
<< " neither owned nor ghost on proc " << arg2 << ".");
+ /**
+ * Exception
+ */
+ DeclException3 (ExcGhostIndexArrayHasWrongSize,
+ unsigned int,
+ unsigned int,
+ unsigned int,
+ << "The size of the ghost index array (" << arg1
+ << ") must either equal the number of ghost in the "
+ << "partitioner (" << arg2
+ << ") or be equal in size to a more comprehensive index"
+ << "set which contains " << arg3
+ << " elements for this partitioner.");
+
private:
/**
* The global size of the vector over all processors
AssertDimension(temporary_storage.size(), n_import_indices());
Assert(ghost_array.size() == n_ghost_indices() ||
ghost_array.size() == n_ghost_indices_in_larger_set,
- ExcMessage(std::string("The size of the ghost index array (")
- +
- std::to_string(ghost_array.size())
- +
- ") must either equal the number of ghost in the "
- "partitioner ("
- +
- std::to_string(n_ghost_indices())
- +
- ") or be equal in size to a more comprehensive index"
- "set which contains "
- +
- std::to_string(n_ghost_indices_in_larger_set)
- +
- " elements for this partitioner."));
+ ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+ n_ghost_indices_in_larger_set));
const unsigned int n_import_targets = import_targets_data.size();
const unsigned int n_ghost_targets = ghost_targets_data.size();
// as a ghost array pointer, put the data at the end of the given ghost
// array in case we want to fill only a subset of the ghosts so that we
- // can get move data to the right position in a forward loop in the
- // _finish function.
+ // can move data to the right position in a forward loop in the _finish
+ // function.
AssertIndexRange(n_ghost_indices(), n_ghost_indices_in_larger_set+1);
- Number *ghost_array_ptr = ghost_array.begin()+
- n_ghost_indices_in_larger_set-
- n_ghost_indices();
+ const bool use_larger_set = (n_ghost_indices_in_larger_set > n_ghost_indices() &&
+ ghost_array.size() == n_ghost_indices_in_larger_set);
+ Number *ghost_array_ptr = use_larger_set ?
+ ghost_array.begin()+
+ n_ghost_indices_in_larger_set-n_ghost_indices()
+ : ghost_array.begin();
for (unsigned int i=0; i<n_ghost_targets; i++)
{
{
Assert(ghost_array.size() == n_ghost_indices() ||
ghost_array.size() == n_ghost_indices_in_larger_set,
- ExcMessage(std::string("The size of the ghost index array (")
- +
- std::to_string(ghost_array.size())
- +
- ") must either equal the number of ghost in the "
- "partitioner ("
- +
- std::to_string(n_ghost_indices())
- +
- ") or be equal in size to a more comprehensive index"
- "set which contains "
- +
- std::to_string(n_ghost_indices_in_larger_set)
- +
- " elements for this partitioner."));
+ ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+ n_ghost_indices_in_larger_set));
// wait for both sends and receives to complete, even though only
// receives are really necessary. this gives (much) better performance
ghost_array[offset] = Number();
}
else
- Assert(offset == my_ghosts->first, ExcInternalError());
+ {
+ AssertDimension(offset, my_ghosts->first);
+ break;
+ }
}
}
AssertDimension(temporary_storage.size(), n_import_indices());
Assert(ghost_array.size() == n_ghost_indices() ||
ghost_array.size() == n_ghost_indices_in_larger_set,
- ExcMessage(std::string("The size of the ghost index array (")
- +
- std::to_string(ghost_array.size())
- +
- ") must either equal the number of ghost in the "
- "partitioner ("
- +
- std::to_string(n_ghost_indices())
- +
- ") or be equal in size to a more comprehensive index"
- "set which contains "
- +
- std::to_string(n_ghost_indices_in_larger_set)
- +
- " elements for this partitioner."));
+ ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+ n_ghost_indices_in_larger_set));
(void)vector_operation;
AssertDimension(temporary_storage.size(), n_import_indices());
Assert(ghost_array.size() == n_ghost_indices() ||
ghost_array.size() == n_ghost_indices_in_larger_set,
- ExcMessage(std::string("The size of the ghost index array (")
- +
- std::to_string(ghost_array.size())
- +
- ") must either equal the number of ghost in the "
- "partitioner ("
- +
- std::to_string(n_ghost_indices())
- +
- ") or be equal in size to a more comprehensive index"
- "set which contains "
- +
- std::to_string(n_ghost_indices_in_larger_set)
- +
- " elements for this partitioner."));
+ ExcGhostIndexArrayHasWrongSize(ghost_array.size(), n_ghost_indices(),
+ n_ghost_indices_in_larger_set));
// in optimized mode, no communication was started, so leave the
// function directly (and only clear ghosts)