Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix AffineConstraints::copy_from #16039

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/deal.II/lac/affine_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -2590,6 +2590,9 @@ AffineConstraints<number>::copy_from(
lines_cache = other.lines_cache;
local_lines = other.local_lines;
sorted = other.sorted;

locally_owned_dofs = other.locally_owned_dofs;
needed_elements_for_distribute = other.needed_elements_for_distribute;
}


Expand Down
72 changes: 72 additions & 0 deletions tests/mpi/constraints_crash_02.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// ---------------------------------------------------------------------
//
// Copyright (C) 2013 - 2018 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE.md at
// the top level directory of deal.II.
//
// ---------------------------------------------------------------------



// AffineConstraints<double>::distribute() crashes because copy_from() is
// incomplete:

/**
An error occurred in line <2679> of file
</ssd/deal-git1/include/deal.II/lac/affine_constraints.templates.h> in function
void dealii::AffineConstraints<number>::distribute(VectorType&) const [with
VectorType = dealii::LinearAlgebra::distributed::Vector<double>; number =
double] The violated condition was: needed_elements_for_distribute != IndexSet()
*/

#include <deal.II/dofs/dof_tools.h>

#include <deal.II/lac/la_parallel_block_vector.h>
#include <deal.II/lac/la_parallel_vector.h>

#include "../tests.h"



void
test()
{
unsigned int myid = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
unsigned int numproc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);

IndexSet owned(numproc);
owned.add_range(myid, myid + 1);
IndexSet relevant = complete_index_set(numproc);


AffineConstraints<double> cm(owned, relevant);
cm.add_line(0);
cm.close();

AffineConstraints<double> cm2;
cm2.copy_from(cm);

LinearAlgebra::distributed::Vector<double> x(owned, relevant, MPI_COMM_WORLD);

cm.distribute(x); // this works
cm2.distribute(x); // this used to fail
deallog << "OK" << std::endl;
}


int
main(int argc, char *argv[])
{
Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
MPILogInitAll log;

test();
return 0;
}
5 changes: 5 additions & 0 deletions tests/mpi/constraints_crash_02.mpirun=2.output
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

DEAL:0::OK

DEAL:1::OK