]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make sure old structures are cleared before new information is entered.
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 11 Aug 2010 13:23:11 +0000 (13:23 +0000)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Wed, 11 Aug 2010 13:23:11 +0000 (13:23 +0000)
git-svn-id: https://svn.dealii.org/trunk@21642 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/source/trilinos_sparse_matrix.cc
deal.II/lac/source/trilinos_sparsity_pattern.cc

index f2e0f79f6f886ad8c3565e4503c94e741a803cef..7efa6211781613cc0de63ea5062cf66a280ff5b0 100644 (file)
@@ -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();
index c0d4222b3382a09c65f509e530bfcc6b13861ae7..9c7a70ec290dbf8ba3b0088af7304969a49774de 100644 (file)
@@ -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<unsigned int> &n_entries_per_row)
   {
+                               // release memory before reallocation
+    graph.reset ();
     Assert (n_entries_per_row.size() ==
              static_cast<unsigned int>(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<unsigned int>(input_row_map.NumGlobalElements()),
            ExcDimensionMismatch (sp.n_rows(),

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.