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

Tpetra: fix lac/vector_reinit_02 #16597

Merged
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
7 changes: 7 additions & 0 deletions include/deal.II/lac/trilinos_tpetra_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ namespace LinearAlgebra
const MPI_Comm communicator,
const bool vector_writable = false);

/**
* Release all memory and return to a state just like after having called
* the default constructor.
*/
void
clear();

/**
* Reinit functionality. This function destroys the old vector content
* and generates a new one based on the input partitioning. The flag
Expand Down
13 changes: 13 additions & 0 deletions include/deal.II/lac/trilinos_tpetra_vector.templates.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ namespace LinearAlgebra



template <typename Number, typename MemorySpace>
void
Vector<Number, MemorySpace>::clear()
{
vector = Utilities::Trilinos::internal::make_rcp<VectorType>(
Utilities::Trilinos::internal::make_rcp<MapType>(
0, 0, Utilities::Trilinos::tpetra_comm_self()));
has_ghost = false;
compressed = true;
}



template <typename Number, typename MemorySpace>
void
Vector<Number, MemorySpace>::reinit(const IndexSet &parallel_partitioner,
Expand Down
9 changes: 9 additions & 0 deletions tests/lac/vector_reinit_02.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ do_test()
v1.reinit(set, communicator);
deallog << "reinit: " << v1.size() << ' ';

v1.clear();
#ifdef DEAL_II_WITH_MPI
MPI_Comm_free(&communicator);
#endif
Expand All @@ -56,6 +57,8 @@ do_test()
v1.reinit(v2);
deallog << v1.size() << std::endl;

v1.clear();
v2.clear();
#ifdef DEAL_II_WITH_MPI
MPI_Comm_free(&communicator);
#endif
Expand All @@ -70,6 +73,8 @@ do_test()
v1 = v2;
deallog << v1.size() << std::endl;

v1.clear();
v2.clear();
#ifdef DEAL_II_WITH_MPI
MPI_Comm_free(&communicator);
#endif
Expand All @@ -84,6 +89,8 @@ do_test()
v3->reinit(v1);
deallog << "reinit pool " << v1.size() << ' ' << v3->size() << ' ';

v1.clear();
v3->clear();
#ifdef DEAL_II_WITH_MPI
MPI_Comm_free(&communicator);
#endif
Expand All @@ -98,6 +105,8 @@ do_test()
v3->reinit(v1);
deallog << "reinit pool " << v3->size() << std::endl;

v1.clear();
v3->clear();
#ifdef DEAL_II_WITH_MPI
MPI_Comm_free(&communicator);
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

DEAL::reinit: 5 5 5
DEAL::assign 5 5
DEAL::reinit pool 5 5 reinit pool 5
DEAL::reinit: 5 5 5
DEAL::assign 5 5
DEAL::reinit pool 5 5 reinit pool 5
DEAL::reinit: 5 5 5
DEAL::assign 5 5
DEAL::reinit pool 5 5 reinit pool 5
DEAL::reinit: 5 5 5
DEAL::assign 5 5
DEAL::reinit pool 5 5 reinit pool 5