From: kronbichler Date: Wed, 18 Feb 2009 12:14:56 +0000 (+0000) Subject: When Trilinos matrices are based on the same sparsity pattern, they can share the... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=015488d4861b674bb369977481bd62f3066b991f;p=dealii-svn.git When Trilinos matrices are based on the same sparsity pattern, they can share the SP data if we initialize them correctly. This has been applied to step-31. git-svn-id: https://svn.dealii.org/trunk@18394 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-31/step-31.cc b/deal.II/examples/step-31/step-31.cc index 0d1da76c16..eead40b517 100644 --- a/deal.II/examples/step-31/step-31.cc +++ b/deal.II/examples/step-31/step-31.cc @@ -1272,7 +1272,19 @@ void BoussinesqFlowProblem::setup_dofs () // of the Stokes matrix – except // that it is much easier here since we // do not need to take care of any blocks - // or coupling between components: + // or coupling between components. Note + // how we initialize the three + // temperature matrices: We only use the + // sparsity pattern for reinitialization + // of the first matrix, whereas we use + // the previously generated matrix for + // the two remaining reinits. The reason + // for doing so is that reinitialization + // from an already generated matrix + // allows Trilinos to reuse the sparsity + // pattern instead of generating a new + // one for each copy. This saves both + // some time and memory. { temperature_mass_matrix.clear (); temperature_stiffness_matrix.clear (); @@ -1283,8 +1295,8 @@ void BoussinesqFlowProblem::setup_dofs () temperature_constraints, false); temperature_matrix.reinit (csp); - temperature_mass_matrix.reinit (csp); - temperature_stiffness_matrix.reinit (csp); + temperature_mass_matrix.reinit (temperature_matrix); + temperature_stiffness_matrix.reinit (temperature_matrix); } // Lastly, we set the vectors for the diff --git a/deal.II/lac/include/lac/trilinos_sparse_matrix.h b/deal.II/lac/include/lac/trilinos_sparse_matrix.h index ecd9b56e96..922aa01c29 100755 --- a/deal.II/lac/include/lac/trilinos_sparse_matrix.h +++ b/deal.II/lac/include/lac/trilinos_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2008 by the deal.II authors +// Copyright (C) 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -290,7 +290,7 @@ namespace TrilinosWrappers * * @ingroup TrilinosWrappers * @ingroup Matrix1 - * @author Martin Kronbichler, Wolfgang Bangerth, 2008 + * @author Martin Kronbichler, Wolfgang Bangerth, 2008, 2009 */ class SparseMatrix : public Subscriptor { diff --git a/deal.II/lac/source/trilinos_sparse_matrix.cc b/deal.II/lac/source/trilinos_sparse_matrix.cc index 580bcb552b..74de21cb8e 100755 --- a/deal.II/lac/source/trilinos_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_sparse_matrix.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2008 by the deal.II authors +// Copyright (C) 2008, 2009 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -251,6 +251,7 @@ namespace TrilinosWrappers row_map = m.row_map; col_map = m.col_map; *matrix = *m.matrix; + compress(); return *this; } @@ -563,9 +564,10 @@ namespace TrilinosWrappers row_map = sparse_matrix.row_map; col_map = sparse_matrix.col_map; - matrix = std::auto_ptr(new Epetra_FECrsMatrix( - *sparse_matrix.matrix)); - compressed = true; + matrix = std::auto_ptr + (new Epetra_FECrsMatrix(Copy, sparse_matrix.matrix->Graph(), false)); + + compress(); }