From: bangerth Date: Wed, 30 Jun 2010 11:53:57 +0000 (+0000) Subject: Merge patches 21397, 21496, 21409 from mainline. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=894ec9e470fae897eac7809d036a95823fa437b7;p=dealii-svn.git Merge patches 21397, 21496, 21409 from mainline. git-svn-id: https://svn.dealii.org/branches/releases/Branch-6-3@21411 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 25736ff7ee..985d008e36 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -57,6 +57,20 @@ inconvenience this causes. + +

base

+ +
    +
  1. +

    + Fixed: deal.II release 6.3.0 did not compile with Trilinos versions 9.x and + 10.0. This is now fixed. +
    + (Martin Kronbichler, WB 2010/06/28) +

    +
+ +

deal.II

diff --git a/deal.II/lac/include/lac/trilinos_precondition.h b/deal.II/lac/include/lac/trilinos_precondition.h index 430203128a..b359254261 100644 --- a/deal.II/lac/include/lac/trilinos_precondition.h +++ b/deal.II/lac/include/lac/trilinos_precondition.h @@ -30,7 +30,6 @@ # endif # include -# include # include # include # include @@ -103,6 +102,13 @@ namespace TrilinosWrappers */ ~PreconditionBase (); + /** + * Destroys the preconditioner, leaving + * an object like just after having + * called the constructor. + */ + void clear (); + /** * Apply the preconditioner. */ @@ -139,7 +145,7 @@ namespace TrilinosWrappers * is used when applying the * preconditioner. */ - Teuchos::RCP preconditioner; + std_cxx1x::shared_ptr preconditioner; /** * Internal communication @@ -250,14 +256,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -386,14 +384,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -522,14 +512,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -699,14 +681,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -875,14 +849,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -1057,14 +1023,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -1124,14 +1082,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -1241,14 +1191,6 @@ namespace TrilinosWrappers */ void initialize (const SparseMatrix &matrix, const AdditionalData &additional_data = AdditionalData()); - - private: - /** - * This is a pointer to the - * Ifpack data contained in - * this preconditioner. - */ - Teuchos::RCP ifpack; }; @@ -1494,6 +1436,13 @@ namespace TrilinosWrappers */ void reinit (); + /** + * Destroys the preconditioner, leaving + * an object like just after having + * called the constructor. + */ + void clear (); + /** * Prints an estimate of the memory * consumption of this class. @@ -1501,18 +1450,11 @@ namespace TrilinosWrappers unsigned int memory_consumption () const; private: - - /** - * A pointer to the preconditioner - * object. - */ - Teuchos::RCP multilevel_operator; - /** * A copy of the deal.II matrix into * Trilinos format. */ - std_cxx1x::shared_ptr Matrix; + std_cxx1x::shared_ptr trilinos_matrix; }; diff --git a/deal.II/lac/source/trilinos_precondition.cc b/deal.II/lac/source/trilinos_precondition.cc index d654172101..34190d979a 100644 --- a/deal.II/lac/source/trilinos_precondition.cc +++ b/deal.II/lac/source/trilinos_precondition.cc @@ -55,8 +55,17 @@ namespace TrilinosWrappers PreconditionBase::~PreconditionBase() + {} + + + + void PreconditionBase::clear () { - preconditioner.release(); + preconditioner.reset(); +#ifdef DEAL_II_COMPILER_SUPPORTS_MPI + communicator = MPI_COMM_SELF; +#endif + vector_distributor.reset(); } @@ -77,16 +86,17 @@ namespace TrilinosWrappers PreconditionJacobi::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("point relaxation", - const_cast(&matrix.trilinos_matrix()), - 0)); + // release memory before reallocation + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("point relaxation", + const_cast(&matrix.trilinos_matrix()), + 0)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -105,8 +115,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -129,16 +137,16 @@ namespace TrilinosWrappers PreconditionSSOR::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("point relaxation", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("point relaxation", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -158,8 +166,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -182,16 +188,16 @@ namespace TrilinosWrappers PreconditionSOR::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("point relaxation", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("point relaxation", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -211,8 +217,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -237,16 +241,16 @@ namespace TrilinosWrappers PreconditionIC::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("IC", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("IC", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -264,8 +268,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -290,16 +292,16 @@ namespace TrilinosWrappers PreconditionILU::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("ILU", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("ILU", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -317,8 +319,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -345,16 +345,16 @@ namespace TrilinosWrappers PreconditionILUT::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); - - ifpack = Teuchos::rcp (Ifpack().Create - ("ILUT", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("ILUT", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -373,8 +373,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -393,15 +391,16 @@ namespace TrilinosWrappers PreconditionBlockwiseDirect::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); + preconditioner.reset (); + preconditioner.reset (Ifpack().Create + ("Amesos", + const_cast(&matrix.trilinos_matrix()), + additional_data.overlap)); - ifpack = Teuchos::rcp (Ifpack().Create - ("Amesos", - const_cast(&matrix.trilinos_matrix()), - additional_data.overlap)); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Preconditioner * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -416,8 +415,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -446,12 +443,13 @@ namespace TrilinosWrappers PreconditionChebyshev::initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.release(); - ifpack.release(); + preconditioner.reset (); + preconditioner.reset (new Ifpack_Chebyshev (&matrix.trilinos_matrix())); - ifpack = Teuchos::rcp (new Ifpack_Chebyshev (&matrix.trilinos_matrix())); - Assert (ifpack.get() != 0, ExcMessage ("Trilinos could not create this " - "preconditioner")); + Ifpack_Chebyshev * ifpack = static_cast + (preconditioner.get()); + Assert (ifpack != 0, ExcMessage ("Trilinos could not create this " + "preconditioner")); int ierr; @@ -477,8 +475,6 @@ namespace TrilinosWrappers ierr = ifpack->Compute(); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); - - preconditioner = Teuchos::rcp (ifpack.get(), false); } @@ -513,9 +509,6 @@ namespace TrilinosWrappers PreconditionAMG:: initialize (const SparseMatrix &matrix, const AdditionalData &additional_data) { - preconditioner.reset (); - multilevel_operator.reset (); - const unsigned int n_rows = matrix.m(); // Build the AMG preconditioner. @@ -609,8 +602,8 @@ namespace TrilinosWrappers for (unsigned int row=0; row(additional_data.constant_modes[d][global_row_id])); + distributed_constant_modes[d][row] = + additional_data.constant_modes[d][global_row_id]; } parameter_list.set("null space: type", "pre-computed"); @@ -623,7 +616,13 @@ namespace TrilinosWrappers initialize (matrix, parameter_list); if (additional_data.output_details) - multilevel_operator->PrintUnused(0); + { + ML_Epetra::MultiLevelPreconditioner * multilevel_operator = + dynamic_cast (preconditioner.get()); + Assert (multilevel_operator != 0, + ExcMessage ("Preconditioner setup failed.")); + multilevel_operator->PrintUnused(0); + } } @@ -632,9 +631,9 @@ namespace TrilinosWrappers PreconditionAMG::initialize (const SparseMatrix &matrix, const Teuchos::ParameterList &ml_parameters) { - multilevel_operator.reset (new ML_Epetra::MultiLevelPreconditioner - (matrix.trilinos_matrix(), ml_parameters)); - preconditioner.reset (multilevel_operator.get(), false); + preconditioner.reset (); + preconditioner.reset (new ML_Epetra::MultiLevelPreconditioner + (matrix.trilinos_matrix(), ml_parameters)); } @@ -648,7 +647,6 @@ namespace TrilinosWrappers const ::dealii::SparsityPattern *use_this_sparsity) { preconditioner.reset(); - multilevel_operator.reset (); const unsigned int n_rows = deal_ii_sparse_matrix.m(); // Init Epetra Matrix using an @@ -657,32 +655,43 @@ namespace TrilinosWrappers // elements. vector_distributor.reset (new Epetra_Map(n_rows, 0, communicator)); - if (Matrix.get() == 0) - Matrix.reset (new SparseMatrix()); + if (trilinos_matrix.get() == 0) + trilinos_matrix.reset (new SparseMatrix()); - Matrix->reinit (*vector_distributor, *vector_distributor, - deal_ii_sparse_matrix, drop_tolerance, true, - use_this_sparsity); + trilinos_matrix->reinit (*vector_distributor, *vector_distributor, + deal_ii_sparse_matrix, drop_tolerance, true, + use_this_sparsity); - initialize (*Matrix, additional_data); + initialize (*trilinos_matrix, additional_data); } void PreconditionAMG::reinit () { + ML_Epetra::MultiLevelPreconditioner * multilevel_operator = + dynamic_cast (preconditioner.get()); multilevel_operator->ReComputePreconditioner(); } + + void PreconditionAMG::clear () + { + PreconditionBase::clear(); + trilinos_matrix.reset(); + } + + + unsigned int PreconditionAMG::memory_consumption() const { unsigned int memory = sizeof(this); // todo: find a way to read out ML's data // sizes - if (Matrix.get() != 0) - memory += Matrix->memory_consumption(); + if (trilinos_matrix.get() != 0) + memory += trilinos_matrix->memory_consumption(); return memory; }