Skip to content

Commit

Permalink
Only initialize with ghost elements if partitioner provides ghost ind…
Browse files Browse the repository at this point in the history
…ices.
  • Loading branch information
marcfehling committed Dec 10, 2022
1 parent 0d962c8 commit 1143a22
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 44 deletions.
12 changes: 0 additions & 12 deletions include/deal.II/lac/la_parallel_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -405,18 +405,6 @@ namespace LinearAlgebra
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const MPI_Comm &comm_sm = MPI_COMM_SELF);

/**
* This function exists purely for reasons of compatibility with the
* PETScWrappers::MPI::Vector and TrilinosWrappers::MPI::Vector classes.
*
* It calls the function above, and ignores the parameter @p make_ghosted.
*/
void
reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const bool make_ghosted,
const MPI_Comm &comm_sm = MPI_COMM_SELF);

/**
* Initialize vector with @p local_size locally-owned and @p ghost_size
* ghost degrees of freedoms.
Expand Down
12 changes: 0 additions & 12 deletions include/deal.II/lac/la_parallel_vector.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,18 +671,6 @@ namespace LinearAlgebra



template <typename Number, typename MemorySpaceType>
void
Vector<Number, MemorySpaceType>::reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner_in,
const bool /*make_ghosted*/,
const MPI_Comm &comm_sm)
{
this->reinit(partitioner_in, comm_sm);
}



template <typename Number, typename MemorySpaceType>
Vector<Number, MemorySpaceType>::Vector()
: partitioner(std::make_shared<Utilities::MPI::Partitioner>())
Expand Down
7 changes: 3 additions & 4 deletions include/deal.II/lac/petsc_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,12 @@ namespace PETScWrappers
* Initialize the vector given to the parallel partitioning described in
* @p partitioner.
*
* You can decide whether your vector will contain ghost elements with
* @p make_ghosted.
* It will contain ghost elements only if the @p partitioner provides
* ghost indices.
*/
void
reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const bool make_ghosted = true);
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner);

/**
* Return a reference to the MPI communicator object in use with this
Expand Down
5 changes: 2 additions & 3 deletions include/deal.II/lac/trilinos_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,16 +605,15 @@ namespace TrilinosWrappers
* Initialize the vector given to the parallel partitioning described in
* @p partitioner using the function above.
*
* You can decide whether your vector will contain ghost elements with
* @p make_ghosted.
* It will contain ghost elements only if the @p partitioner provides
* ghost indices.
*
* The parameter @p vector_writable only has effect on ghosted vectors
* and is ignored for non-ghosted vectors.
*/
void
reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const bool make_ghosted = true,
const bool vector_writable = false);

/**
Expand Down
9 changes: 2 additions & 7 deletions source/lac/petsc_parallel_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,10 @@ namespace PETScWrappers

void
Vector::reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const bool make_ghosted)
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner)
{
if (make_ghosted)
if (partitioner->ghost_indices_initialized())
{
Assert(partitioner->ghost_indices_initialized(),
ExcMessage("You asked to create a ghosted vector, but the "
"partitioner does not provide ghost indices."));

this->reinit(partitioner->locally_owned_range(),
partitioner->ghost_indices(),
partitioner->get_mpi_communicator());
Expand Down
7 changes: 1 addition & 6 deletions source/lac/trilinos_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,10 @@ namespace TrilinosWrappers
void
Vector::reinit(
const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
const bool make_ghosted,
const bool vector_writable)
{
if (make_ghosted)
if (partitioner->ghost_indices_initialized())
{
Assert(partitioner->ghost_indices_initialized(),
ExcMessage("You asked to create a ghosted vector, but the "
"partitioner does not provide ghost indices."));

this->reinit(partitioner->locally_owned_range(),
partitioner->ghost_indices(),
partitioner->get_mpi_communicator(),
Expand Down

0 comments on commit 1143a22

Please sign in to comment.