* The partitioner includes a mechanism for converting global to local and
* local to global indices. Internally, this class stores vector elements
* using the convention as follows: The local range is associated with
- * local indices [0,@p local_size), and ghost indices are stored
- * consecutively in [@p local_size, @p local_size + @p n_ghost_indices).
- * The ghost indices are sorted according to their global index.
+ * local indices [0, locally_owned_size()), and ghost indices are stored
+ * consecutively in [locally_owned_size(), locally_owned_size() +
+ * n_ghost_indices()). The ghost indices are sorted according to their
+ * global index.
*
*
* <h4>Parallel data exchange</h4>
size() const;
/**
- * Return the local size, i.e. local_range().second minus
- * local_range().first.
+ * Return the number of locally owned indices,
+ * i.e., local_range().second minus local_range().first.
+ *
+ * @deprecated Use the more clearly named function locally_owned_size()
+ * instead.
*/
+ DEAL_II_DEPRECATED
unsigned int
local_size() const;
+ /**
+ * Return the number of locally owned indices,
+ * i.e., local_range().second minus local_range().first.
+ */
+ unsigned int
+ locally_owned_size() const;
+
/**
* Return an IndexSet representation of the local range. This class
* only supports contiguous local ranges, so the IndexSet actually only
* the given global index is neither locally owned nor a ghost, an
* exception is thrown.
*
- * Note that the returned local index for locally owned indices
- * will be between 0 and
- * `local_size()-1`, and the local index for ghosts is between
- * `local_size()` and `local_size()+n_ghost_indices()-1`.
+ * Note that the returned local index for locally owned indices will be
+ * between 0 and locally_owned_size() - 1, and the local index for
+ * ghosts is between locally_owned_size() and locally_owned_size() +
+ * n_ghost_indices() - 1.
*/
unsigned int
global_to_local(const types::global_dof_index global_index) const;
* Return the global index corresponding to the given local index.
*
* Note that the local index for locally owned indices must be between 0
- * and `local_size()-1`, and the local index for ghosts must be between
- * `local_size()` and `local_size()+n_ghost_indices()-1`.
+ * and locally_owned_size() - 1, and the local index for ghosts must be
+ * between locally_owned_size() and locally_owned_size() +
+ * n_ghost_indices() - 1.
*/
types::global_dof_index
local_to_global(const unsigned int local_index) const;
inline unsigned int
Partitioner::local_size() const
+ {
+ return locally_owned_size();
+ }
+
+
+
+ inline unsigned int
+ Partitioner::locally_owned_size() const
{
types::global_dof_index size =
local_range_data.second - local_range_data.first;
if (in_local_range(global_index))
return static_cast<unsigned int>(global_index - local_range_data.first);
else if (is_ghost_entry(global_index))
- return (local_size() +
+ return (locally_owned_size() +
static_cast<unsigned int>(
ghost_indices_data.index_within_set(global_index)));
else
inline types::global_dof_index
Partitioner::local_to_global(const unsigned int local_index) const
{
- AssertIndexRange(local_index, local_size() + n_ghost_indices_data);
- if (local_index < local_size())
+ AssertIndexRange(local_index,
+ locally_owned_size() + n_ghost_indices_data);
+ if (local_index < locally_owned_size())
return local_range_data.first + types::global_dof_index(local_index);
else
- return ghost_indices_data.nth_index_in_set(local_index - local_size());
+ return ghost_indices_data.nth_index_in_set(local_index -
+ locally_owned_size());
}
{
partitioner = v.partitioner;
const size_type new_allocated_size =
- partitioner->local_size() + partitioner->n_ghost_indices();
+ partitioner->locally_owned_size() + partitioner->n_ghost_indices();
resize_val(new_allocated_size, this->comm_sm);
}
// set vector size and allocate memory
const size_type new_allocated_size =
- partitioner->local_size() + partitioner->n_ghost_indices();
+ partitioner->locally_onwed_size() + partitioner->n_ghost_indices();
resize_val(new_allocated_size, comm_sm);
// initialize to zero
{
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::copy(
- thread_loop_partitioner, partitioner->local_size(), v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ v.data,
+ data);
}
}
thread_loop_partitioner = c.thread_loop_partitioner;
- const size_type this_size = partitioner->local_size();
+ const size_type this_size = partitioner->locally_owned_size();
if (this_size > 0)
{
dealii::internal::VectorOperations::
Vector<Number, MemorySpaceType>::copy_locally_owned_data_from(
const Vector<Number2, MemorySpaceType> &src)
{
- AssertDimension(partitioner->local_size(), src.partitioner->local_size());
- if (partitioner->local_size() > 0)
+ AssertDimension(partitioner->locally_owned_size(),
+ src.partitioner->locally_owned_size());
+ if (partitioner->locally_owned_size() > 0)
{
dealii::internal::VectorOperations::
functions<Number, Number2, MemorySpaceType>::copy(
thread_loop_partitioner,
- partitioner->local_size(),
+ partitioner->locally_owned_size(),
src.data,
data);
}
Vector<Number, MemorySpaceType>::zero_out_ghost_values() const
{
if (data.values != nullptr)
- std::fill_n(data.values.get() + partitioner->local_size(),
+ std::fill_n(data.values.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices(),
Number());
#ifdef DEAL_II_COMPILER_CUDA_AWARE
if (data.values_dev != nullptr)
{
const cudaError_t cuda_error_code =
- cudaMemset(data.values_dev.get() + partitioner->local_size(),
+ cudaMemset(data.values_dev.get() +
+ partitioner->locally_owned_size(),
0,
partitioner->n_ghost_indices() * sizeof(Number));
AssertCuda(cuda_error_code);
operation,
communication_channel,
ArrayView<Number, MemorySpace::CUDA>(
- data.values_dev.get() + partitioner->local_size(),
+ data.values_dev.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
ArrayView<Number, MemorySpace::CUDA>(
import_data.values_dev.get(), partitioner->n_import_indices()),
operation,
communication_channel,
ArrayView<Number, MemorySpace::Host>(
- data.values.get() + partitioner->local_size(),
+ data.values.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
ArrayView<Number, MemorySpace::Host>(
import_data.values.get(), partitioner->n_import_indices()),
operation,
ArrayView<const Number, MemorySpace::CUDA>(
import_data.values_dev.get(), partitioner->n_import_indices()),
- ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get(),
- partitioner->local_size()),
ArrayView<Number, MemorySpace::CUDA>(
- data.values_dev.get() + partitioner->local_size(),
+ data.values_dev.get(), partitioner->locally_owned_size()),
+ ArrayView<Number, MemorySpace::CUDA>(
+ data.values_dev.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
compress_requests);
}
operation,
ArrayView<const Number, MemorySpace::Host>(
import_data.values.get(), partitioner->n_import_indices()),
- ArrayView<Number, MemorySpace::Host>(data.values.get(),
- partitioner->local_size()),
ArrayView<Number, MemorySpace::Host>(
- data.values.get() + partitioner->local_size(),
+ data.values.get(), partitioner->locally_owned_size()),
+ ArrayView<Number, MemorySpace::Host>(
+ data.values.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
compress_requests);
}
defined(DEAL_II_MPI_WITH_CUDA_SUPPORT))
partitioner->export_to_ghosted_array_start<Number, MemorySpace::Host>(
communication_channel,
- ArrayView<const Number, MemorySpace::Host>(data.values.get(),
- partitioner->local_size()),
+ ArrayView<const Number, MemorySpace::Host>(
+ data.values.get(), partitioner->locally_owned_size()),
ArrayView<Number, MemorySpace::Host>(import_data.values.get(),
partitioner->n_import_indices()),
- ArrayView<Number, MemorySpace::Host>(data.values.get() +
- partitioner->local_size(),
- partitioner->n_ghost_indices()),
+ ArrayView<Number, MemorySpace::Host>(
+ data.values.get() + partitioner->locally_owned_size(),
+ partitioner->n_ghost_indices()),
update_ghost_values_requests);
# else
partitioner->export_to_ghosted_array_start<Number, MemorySpace::CUDA>(
communication_channel,
- ArrayView<const Number, MemorySpace::CUDA>(data.values_dev.get(),
- partitioner->local_size()),
+ ArrayView<const Number, MemorySpace::CUDA>(
+ data.values_dev.get(), partitioner->locally_owned_size()),
ArrayView<Number, MemorySpace::CUDA>(import_data.values_dev.get(),
partitioner->n_import_indices()),
- ArrayView<Number, MemorySpace::CUDA>(data.values_dev.get() +
- partitioner->local_size(),
- partitioner->n_ghost_indices()),
+ ArrayView<Number, MemorySpace::CUDA>(
+ data.values_dev.get() + partitioner->locally_owned_size(),
+ partitioner->n_ghost_indices()),
update_ghost_values_requests);
# endif
defined(DEAL_II_MPI_WITH_CUDA_SUPPORT))
partitioner->export_to_ghosted_array_finish(
ArrayView<Number, MemorySpace::Host>(
- data.values.get() + partitioner->local_size(),
+ data.values.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
update_ghost_values_requests);
# else
partitioner->export_to_ghosted_array_finish(
ArrayView<Number, MemorySpace::CUDA>(
- data.values_dev.get() + partitioner->local_size(),
+ data.values_dev.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices()),
update_ghost_values_requests);
# endif
if (std::is_same<MemorySpaceType, MemorySpace::CUDA>::value)
{
cudaError_t cuda_error_code =
- cudaMemcpy(data.values_dev.get() + partitioner->local_size(),
- data.values.get() + partitioner->local_size(),
+ cudaMemcpy(data.values_dev.get() +
+ partitioner->locally_owned_size(),
+ data.values.get() + partitioner->locally_owned_size(),
partitioner->n_ghost_indices() * sizeof(Number),
cudaMemcpyHostToDevice);
AssertCuda(cuda_error_code);
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::add_vector(
- thread_loop_partitioner, partitioner->local_size(), v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ v.data,
+ data);
if (vector_is_ghosted)
update_ghost_values();
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::subtract_vector(
- thread_loop_partitioner, partitioner->local_size(), v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ v.data,
+ data);
if (vector_is_ghosted)
update_ghost_values();
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::add_factor(
- thread_loop_partitioner, partitioner->local_size(), a, data);
+ thread_loop_partitioner, partitioner->locally_owned_size(), a, data);
if (vector_is_ghosted)
update_ghost_values();
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::add_av(
- thread_loop_partitioner, partitioner->local_size(), a, v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ a,
+ v.data,
+ data);
}
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::add_avpbw(
thread_loop_partitioner,
- partitioner->local_size(),
+ partitioner->locally_owned_size(),
a,
b,
v.data,
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::sadd_xv(
- thread_loop_partitioner, partitioner->local_size(), x, v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ x,
+ v.data,
+ data);
if (vector_is_ghosted)
update_ghost_values();
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::sadd_xav(
thread_loop_partitioner,
- partitioner->local_size(),
+ partitioner->locally_owned_size(),
x,
a,
v.data,
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::multiply_factor(
- thread_loop_partitioner, partitioner->local_size(), factor, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ factor,
+ data);
if (vector_is_ghosted)
update_ghost_values();
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::equ_au(
- thread_loop_partitioner, partitioner->local_size(), a, v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ a,
+ v.data,
+ data);
if (vector_is_ghosted)
if (PointerComparison::equal(this, &v))
return norm_sqr_local();
- AssertDimension(partitioner->local_size(), v.partitioner->local_size());
+ AssertDimension(partitioner->locally_owned_size(),
+ v.partitioner->locally_owned_size());
return dealii::internal::VectorOperations::
functions<Number, Number2, MemorySpaceType>::dot(
- thread_loop_partitioner, partitioner->local_size(), v.data, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ v.data,
+ data);
}
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::norm_2(
- thread_loop_partitioner, partitioner->local_size(), sum, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ sum,
+ data);
AssertIsFinite(sum);
{
Assert(size() != 0, ExcEmptyObject());
- if (partitioner->local_size() == 0)
+ if (partitioner->locally_owned_size() == 0)
return Number();
Number sum = ::dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::mean_value(
- thread_loop_partitioner, partitioner->local_size(), data);
+ thread_loop_partitioner, partitioner->locally_owned_size(), data);
- return sum / real_type(partitioner->local_size());
+ return sum / real_type(partitioner->locally_owned_size());
}
{
Number local_result = mean_value_local();
if (partitioner->n_mpi_processes() > 1)
- return Utilities::MPI::sum(local_result * static_cast<real_type>(
- partitioner->local_size()),
+ return Utilities::MPI::sum(local_result *
+ static_cast<real_type>(
+ partitioner->locally_owned_size()),
partitioner->get_mpi_communicator()) /
static_cast<real_type>(partitioner->size());
else
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::norm_1(
- thread_loop_partitioner, partitioner->local_size(), sum, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ sum,
+ data);
return sum;
}
dealii::internal::VectorOperations::
functions<Number, Number, MemorySpaceType>::norm_p(
- thread_loop_partitioner, partitioner->local_size(), sum, p, data);
+ thread_loop_partitioner,
+ partitioner->locally_owned_size(),
+ sum,
+ p,
+ data);
return std::pow(sum, 1. / p);
}
{
real_type max = 0.;
- const size_type local_size = partitioner->local_size();
+ const size_type local_size = partitioner->locally_owned_size();
internal::la_parallel_vector_templates_functions<
Number,
MemorySpaceType>::linfty_norm_local(data, local_size, max);
const Vector<Number, MemorySpaceType> &v,
const Vector<Number, MemorySpaceType> &w)
{
- const size_type vec_size = partitioner->local_size();
+ const size_type vec_size = partitioner->locally_owned_size();
AssertDimension(vec_size, v.local_size());
AssertDimension(vec_size, w.local_size());
<< "), global size: " << partitioner->size() << std::endl
<< "Vector data:" << std::endl;
if (across)
- for (size_type i = 0; i < partitioner->local_size(); ++i)
+ for (size_type i = 0; i < partitioner->locally_owned_size(); ++i)
out << stored_elements[i] << ' ';
else
- for (size_type i = 0; i < partitioner->local_size(); ++i)
+ for (size_type i = 0; i < partitioner->locally_owned_size(); ++i)
out << stored_elements[i] << std::endl;
out << std::endl;
if (across)
for (size_type i = 0; i < partitioner->n_ghost_indices(); ++i)
out << '(' << partitioner->ghost_indices().nth_index_in_set(i)
- << '/' << stored_elements[partitioner->local_size() + i]
+ << '/'
+ << stored_elements[partitioner->locally_owned_size() + i]
<< ") ";
else
for (size_type i = 0; i < partitioner->n_ghost_indices(); ++i)
out << '(' << partitioner->ghost_indices().nth_index_in_set(i)
- << '/' << stored_elements[partitioner->local_size() + i]
+ << '/'
+ << stored_elements[partitioner->locally_owned_size() + i]
<< ")" << std::endl;
out << std::endl;
}
part.export_to_ghosted_array_start(
component_in_block_vector * 2 + channel_shift,
- ArrayView<const Number>(vec.begin(), part.local_size()),
+ ArrayView<const Number>(vec.begin(), part.locally_owned_size()),
vec.shared_vector_data(),
ArrayView<Number>(const_cast<Number *>(vec.begin()) +
- part.local_size(),
+ part.locally_owned_size(),
matrix_free.get_dof_info(mf_component)
.vector_partitioner->n_ghost_indices()),
ArrayView<Number>(tmp_data[component_in_block_vector]->begin(),
part.n_import_sm_procs() != 0)
{
part.export_to_ghosted_array_finish(
- ArrayView<const Number>(vec.begin(), part.local_size()),
+ ArrayView<const Number>(vec.begin(), part.locally_owned_size()),
vec.shared_vector_data(),
ArrayView<Number>(const_cast<Number *>(vec.begin()) +
- part.local_size(),
+ part.locally_owned_size(),
matrix_free.get_dof_info(mf_component)
.vector_partitioner->n_ghost_indices()),
this->requests[component_in_block_vector]);
part.import_from_ghosted_array_start(
dealii::VectorOperation::add,
- component_in_block_vector * 2 + channel_shift,
- ArrayView<Number>(vec.begin(), part.local_size()),
- vec.shared_vector_data(),
- ArrayView<Number>(vec.begin() + part.local_size(),
- matrix_free.get_dof_info(mf_component)
- .vector_partitioner->n_ghost_indices()),
+ component_in_block_vector + channel_shift,
+ ArrayView<Number>(vec.begin() +
+ vec.get_partitioner()->locally_owned_size(),
+ vec.get_partitioner()->n_ghost_indices()),
ArrayView<Number>(tmp_data[component_in_block_vector]->begin(),
part.n_import_indices()),
this->requests[component_in_block_vector]);
{
part.import_from_ghosted_array_finish(
VectorOperation::add,
- ArrayView<Number>(vec.begin(), part.local_size()),
+ ArrayView<Number>(vec.begin(), part.locally_owned_size()),
vec.shared_vector_data(),
- ArrayView<Number>(vec.begin() + part.local_size(),
+ ArrayView<Number>(vec.begin() + part.locally_owned_size(),
matrix_free.get_dof_info(mf_component)
.vector_partitioner->n_ghost_indices()),
ArrayView<const Number>(
if (part.n_ghost_indices() > 0)
{
- part.reset_ghost_values(ArrayView<Number>(
- const_cast<LinearAlgebra::distributed::Vector<Number> &>(vec)
- .begin() +
- part.local_size(),
- matrix_free.get_dof_info(mf_component)
- .vector_partitioner->n_ghost_indices()));
+ for (std::vector<std::pair<unsigned int, unsigned int>>::
+ const_iterator my_ghosts =
+ part.ghost_indices_within_larger_ghost_set().begin();
+ my_ghosts !=
+ part.ghost_indices_within_larger_ghost_set().end();
+ ++my_ghosts)
+ for (unsigned int j = my_ghosts->first; j < my_ghosts->second;
+ j++)
+ {
+ const_cast<LinearAlgebra::distributed::Vector<Number> &>(
+ vec)
+ .local_element(j + part.locally_owned_size()) = 0.;
+ }
}
# endif
// Case with threaded loop -> currently no overlap implemented
dealii::parallel::apply_to_subranges(
0U,
- dof_info.vector_partitioner->local_size(),
+ dof_info.vector_partitioner->locally_owned_size(),
operation_before_loop,
internal::VectorImplementation::minimum_parallel_grain_size);
}
// Case with threaded loop -> currently no overlap implemented
dealii::parallel::apply_to_subranges(
0U,
- dof_info.vector_partitioner->local_size(),
+ dof_info.vector_partitioner->locally_owned_size(),
operation_after_loop,
internal::VectorImplementation::minimum_parallel_grain_size);
}