From: Martin Kronbichler Date: Wed, 11 Aug 2010 13:23:11 +0000 (+0000) Subject: Make sure old structures are cleared before new information is entered. X-Git-Tag: v8.0.0~5740 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a76c7c93789e23c69885189f3f2b53527a0cd2b;p=dealii.git Make sure old structures are cleared before new information is entered. git-svn-id: https://svn.dealii.org/trunk@21642 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/trilinos_sparse_matrix.cc b/deal.II/lac/source/trilinos_sparse_matrix.cc index f2e0f79f6f..7efa621178 100644 --- a/deal.II/lac/source/trilinos_sparse_matrix.cc +++ b/deal.II/lac/source/trilinos_sparse_matrix.cc @@ -323,6 +323,10 @@ namespace TrilinosWrappers else { column_space_map.reset (new Epetra_Map (m.domain_partitioner())); + + // release memory before reallocation + matrix.reset (); + temp_vector.clear (); matrix.reset (new Epetra_FECrsMatrix(*m.matrix)); } @@ -365,6 +369,8 @@ namespace TrilinosWrappers const SparsityType &sparsity_pattern, const bool exchange_data) { + // release memory before reallocation + temp_vector.clear(); matrix.reset(); const unsigned int n_rows = sparsity_pattern.n_rows(); @@ -494,6 +500,8 @@ namespace TrilinosWrappers // sparsity pattern. column_space_map.reset (new Epetra_Map (sparsity_pattern.domain_partitioner())); + temp_vector.clear (); + matrix.reset (); matrix.reset (new Epetra_FECrsMatrix (Copy, sparsity_pattern.trilinos_sparsity_pattern(), false)); compress(); @@ -505,7 +513,8 @@ namespace TrilinosWrappers SparseMatrix::reinit (const SparseMatrix &sparse_matrix) { column_space_map.reset (new Epetra_Map (sparse_matrix.domain_partitioner())); - + temp_vector.clear (); + matrix.reset (); matrix.reset (new Epetra_FECrsMatrix (Copy, sparse_matrix.trilinos_sparsity_pattern(), false)); @@ -664,6 +673,8 @@ namespace TrilinosWrappers const Epetra_CrsGraph *graph = &input_matrix.Graph(); + temp_vector.clear (); + matrix.reset (); matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false)); matrix->FillComplete (*column_space_map, input_matrix.RangeMap(), true); @@ -690,6 +701,7 @@ namespace TrilinosWrappers // empty matrix. column_space_map.reset (new Epetra_Map (0, 0, Utilities::Trilinos::comm_self())); + temp_vector.clear(); matrix.reset (new Epetra_FECrsMatrix(View, *column_space_map, 0)); matrix->FillComplete(); diff --git a/deal.II/lac/source/trilinos_sparsity_pattern.cc b/deal.II/lac/source/trilinos_sparsity_pattern.cc index c0d4222b33..9c7a70ec29 100644 --- a/deal.II/lac/source/trilinos_sparsity_pattern.cc +++ b/deal.II/lac/source/trilinos_sparsity_pattern.cc @@ -189,6 +189,7 @@ namespace TrilinosWrappers const Epetra_Map &input_col_map, const unsigned int n_entries_per_row) { + graph.reset (); column_space_map.reset (new Epetra_Map (input_col_map)); compressed = false; @@ -239,6 +240,8 @@ namespace TrilinosWrappers const Epetra_Map &input_col_map, const std::vector &n_entries_per_row) { + // release memory before reallocation + graph.reset (); Assert (n_entries_per_row.size() == static_cast(input_row_map.NumGlobalElements()), ExcDimensionMismatch (n_entries_per_row.size(), @@ -277,6 +280,8 @@ namespace TrilinosWrappers const SparsityType &sp, const bool exchange_data) { + graph.reset (); + Assert (sp.n_rows() == static_cast(input_row_map.NumGlobalElements()), ExcDimensionMismatch (sp.n_rows(),