From 7aca36a14e9fae1c280c197234ad8ecf9b329b4b Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 27 Jul 2009 08:42:11 +0000 Subject: [PATCH] Fix the MPI problem in ConstraintMatrix reported by Michael Rapson in the mailing list: Use a pointer to a Trilinos vector instead of a vector object directly. git-svn-id: https://svn.dealii.org/trunk@19117 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/constraint_matrix.h | 2 +- deal.II/lac/source/constraint_matrix.cc | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/deal.II/lac/include/lac/constraint_matrix.h b/deal.II/lac/include/lac/constraint_matrix.h index 64113296a6..f99bd67173 100644 --- a/deal.II/lac/include/lac/constraint_matrix.h +++ b/deal.II/lac/include/lac/constraint_matrix.h @@ -1521,7 +1521,7 @@ class ConstraintMatrix : public Subscriptor * This vector is used to import data * within the distribute function. */ - mutable TrilinosWrappers::MPI::Vector vec_distribute; + mutable std::auto_ptr vec_distribute; #endif }; diff --git a/deal.II/lac/source/constraint_matrix.cc b/deal.II/lac/source/constraint_matrix.cc index 2762c836df..5bd0c374fe 100644 --- a/deal.II/lac/source/constraint_matrix.cc +++ b/deal.II/lac/source/constraint_matrix.cc @@ -744,7 +744,7 @@ void ConstraintMatrix::clear () #ifdef DEAL_II_USE_TRILINOS { // reset distribute vector - vec_distribute.clear(); + vec_distribute.reset(); } #endif @@ -1889,7 +1889,7 @@ ConstraintMatrix::distribute (TrilinosWrappers::MPI::Vector &vec) const // constraints indicate. Do this only at // the first call and provide the class // with a vector for further use. - if (vec_distribute.size()!=vec.size()) + if (&*vec_distribute!=0 || vec_distribute->size()!=vec.size()) { std::vector my_indices(vec.local_size()); unsigned int index2 = 0; @@ -1917,10 +1917,11 @@ ConstraintMatrix::distribute (TrilinosWrappers::MPI::Vector &vec) const my_indices.resize(index2); Epetra_Map map_exchange = Epetra_Map(-1,index2,(int*)&my_indices[0],0,vec.trilinos_vector().Comm()); - vec_distribute.reinit(map_exchange); + vec_distribute = std::auto_ptr + (new TrilinosWrappers::MPI::Vector(map_exchange)); } // here we import the data - vec_distribute.reinit(vec,false,true); + vec_distribute->reinit(vec,false,true); next_constraint = std::lower_bound (lines.begin(),lines.end(),index_comparison); @@ -1932,7 +1933,7 @@ ConstraintMatrix::distribute (TrilinosWrappers::MPI::Vector &vec) const // different contributions double new_value = next_constraint->inhomogeneity; for (unsigned int i=0; ientries.size(); ++i) - new_value += (vec_distribute(next_constraint->entries[i].first) * + new_value += ((*vec_distribute)(next_constraint->entries[i].first) * next_constraint->entries[i].second); vec(next_constraint->line) = new_value; } -- 2.39.5