From c1d57d69d1f592e8aa7448bec8d5ecec7aa86b2a Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 10 May 2004 16:08:11 +0000 Subject: [PATCH] Remove Matrix::reinit(). Remove two other deprecated reinit() functions. git-svn-id: https://svn.dealii.org/trunk@9224 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/c-4-0.html | 28 +++++++++++- deal.II/examples/step-12/step-12.cc | 2 +- deal.II/lac/include/lac/block_sparse_matrix.h | 21 ++------- .../lac/block_sparse_matrix.templates.h | 4 +- deal.II/lac/include/lac/petsc_matrix_base.h | 2 +- .../lac/petsc_parallel_sparse_matrix.h | 2 +- deal.II/lac/include/lac/petsc_sparse_matrix.h | 20 --------- .../lac/include/lac/sparse_decomposition.h | 8 ---- .../lac/sparse_decomposition.templates.h | 17 +------ deal.II/lac/include/lac/sparse_matrix.h | 27 ++---------- .../lac/include/lac/sparse_matrix.templates.h | 44 ++++++++++--------- deal.II/lac/include/lac/sparse_mic.h | 10 +---- .../lac/include/lac/sparse_mic.templates.h | 27 +----------- deal.II/lac/source/petsc_matrix_base.cc | 2 +- 14 files changed, 67 insertions(+), 147 deletions(-) diff --git a/deal.II/doc/news/c-4-0.html b/deal.II/doc/news/c-4-0.html index 893986159c..cf5fce0dfa 100644 --- a/deal.II/doc/news/c-4-0.html +++ b/deal.II/doc/news/c-4-0.html @@ -32,7 +32,25 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

Incompatibilities

    -
  1. Changed: All the vector and block vector classes had a member +

  2. Removed: All the matrix classes have functions reinit that are used to resize the + matrix. However, the sparse matrix classes had an equally named + function without arguments that basically left the size of the matrix + unchanged but set all elements of the matrix to zero. It could also be + abused to notify the matrix that the sparsity pattern on which it is + built has changed, an inherently risky procedure. The no-argument code + reinit function has therefore been removed to + avoid confusion with the reinit functions + that take arguments. Instead, a set_zero + function has been introduced that simply sets all elements of the + matrix to zero. If you want to notify a sparse matrix that its sparsity + pattern has changed, use the reinit(SparsityPattern) function. +
    + (WB 2004/05/10) +

    + +
  3. Removed: All the vector and block vector classes had a member function clear which simply resets all values of the vector to zero. It did not change the size of the vector, though. This was confusing, since the standard C++ container classes @@ -50,6 +68,14 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK (WB 2004/05/10)

    +
  4. Removed: The SparseLUDecomposition::reinit and SparseMIC::reinit functions without + argument had been deprecated before, and have now been removed. +
    + (WB 2004/05/10) +

    +
  5. Changed: the template parameter of MGTransferPrebuilt is now the complete vector type, not just the value type of the vector. This allows to operate diff --git a/deal.II/examples/step-12/step-12.cc b/deal.II/examples/step-12/step-12.cc index 8ef66c88b7..40b388d51e 100644 --- a/deal.II/examples/step-12/step-12.cc +++ b/deal.II/examples/step-12/step-12.cc @@ -1624,7 +1624,7 @@ void DGMethod::run () // reinit the system matrix, the // right hand side vector and // the Timer object. - system_matrix.reinit(); + system_matrix.set_zero(); right_hand_side = 0; assemble_timer.reset(); diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h index 5e86624ae0..3f477e99b2 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.h @@ -339,24 +339,11 @@ class BlockSparseMatrix : public Subscriptor operator = (const BlockSparseMatrix &); /** - * Reinitialize the object but - * keep to the sparsity pattern - * previously used. This may be - * necessary if you reinitialized - * the sparsity structure and - * want to update the size of the - * matrix. It only calls - * SparseMatrix::reinit() on the - * sub-matrices. The size of this - * matrix is unchanged. - * - * If the sparsity pattern has - * not changed, then the effect - * of this function is simply to - * reset all matrix entries to - * zero. + * Set all elements of the matrix to + * zero, but keep the sparsity pattern + * previously used. */ - virtual void reinit (); + void set_zero (); /** * Reinitialize the sparse matrix diff --git a/deal.II/lac/include/lac/block_sparse_matrix.templates.h b/deal.II/lac/include/lac/block_sparse_matrix.templates.h index 144445c123..73b80067ac 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.templates.h @@ -80,11 +80,11 @@ operator = (const BlockSparseMatrix &m) template void -BlockSparseMatrix::reinit () +BlockSparseMatrix::set_zero () { for (unsigned int r=0; ri,j) diff --git a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h index 297d16a857..e7335ce7f7 100644 --- a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h @@ -129,7 +129,7 @@ namespace PETScWrappers * function simply calls the respective * function of the base class. */ - void reinit (); + void set_zero (); /** * Throw away the present matrix and diff --git a/deal.II/lac/include/lac/petsc_sparse_matrix.h b/deal.II/lac/include/lac/petsc_sparse_matrix.h index 83c8c87442..17a5a21b7c 100644 --- a/deal.II/lac/include/lac/petsc_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_sparse_matrix.h @@ -109,14 +109,6 @@ namespace PETScWrappers const std::vector &row_lengths, const bool is_symmetric = false); - /** - * Set all matrix entries to zero, but - * retain the sparsity pattern. This - * function simply calls the respective - * function of the base class. - */ - void reinit (); - /** * Throw away the present matrix and * generate one that has the same @@ -165,18 +157,6 @@ namespace PETScWrappers const std::vector &row_lengths, const bool is_symmetric = false); }; - - -/// @if NoDoc -// -------- template and inline functions ---------- - - inline - void - SparseMatrix::reinit () - { - MatrixBase::reinit (); - } -///@endif } #endif // DEAL_II_USE_PETSC diff --git a/deal.II/lac/include/lac/sparse_decomposition.h b/deal.II/lac/include/lac/sparse_decomposition.h index 70b9074bcb..6dd9dc9e27 100644 --- a/deal.II/lac/include/lac/sparse_decomposition.h +++ b/deal.II/lac/include/lac/sparse_decomposition.h @@ -283,14 +283,6 @@ class SparseLUDecomposition : protected SparseMatrix, void initialize (const SparseMatrix &matrix, const AdditionalData parameters); - /** - * This method is deprecated, - * and left for backward - * compability. It will be removed - * in later versions. - */ - void reinit (); - /** * This method is deprecated, * and left for backward diff --git a/deal.II/lac/include/lac/sparse_decomposition.templates.h b/deal.II/lac/include/lac/sparse_decomposition.templates.h index 9989f977f3..589c4b51ac 100644 --- a/deal.II/lac/include/lac/sparse_decomposition.templates.h +++ b/deal.II/lac/include/lac/sparse_decomposition.templates.h @@ -1,5 +1,5 @@ //--------------------- sparse_decomposition.templates.h ---------------- -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 // by the deal.II authors and Stephen "Cheffo" Kolaroff // // This file is subject to QPL and may not be distributed @@ -133,21 +133,6 @@ decompose (const SparseMatrix &matrix, -template -void -SparseLUDecomposition::reinit () -{ - decomposed = false; - if (true) - { - std::vector tmp; - tmp.swap (prebuilt_lower_bound); - }; - SparseMatrix::reinit (); -} - - - template void SparseLUDecomposition::reinit (const SparsityPattern& sparsity) { diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index 8c971a37b1..4c0f979b5a 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -492,31 +492,10 @@ class SparseMatrix : public virtual Subscriptor SparseMatrix& operator = (const SparseMatrix &); /** - * Reinitialize the object but - * keep to the sparsity pattern - * previously used. This may be - * necessary if the sparsity - * structure has changed and you - * want to update the size of the - * matrix. - * - * Note that memory is only - * reallocated if the new size - * exceeds the old size. If that - * is not the case, the allocated - * memory is not reduced. However, - * if the sparsity structure is - * empty (i.e. the dimensions are - * zero), then all memory is - * freed. - * - * If the sparsity pattern has - * not changed, then the effect - * of this function is simply to - * reset all matrix entries to - * zero. + * Set all elements to zero, but keep to + * the sparsity pattern of the matrix. */ - virtual void reinit (); + virtual void set_zero (); /** * Reinitialize the sparse matrix diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h index e24791371e..16203a8cf9 100644 --- a/deal.II/lac/include/lac/sparse_matrix.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix.templates.h @@ -80,11 +80,11 @@ SparseMatrix::operator = (const SparseMatrix &m) template SparseMatrix::SparseMatrix (const SparsityPattern &c) : - cols(&c), + cols(0), val(0), max_len(0) { - reinit(); + reinit (c); } @@ -102,43 +102,47 @@ SparseMatrix::~SparseMatrix () template void -SparseMatrix::reinit () +SparseMatrix::set_zero () { Assert (cols != 0, ExcMatrixNotInitialized()); Assert (cols->compressed || cols->empty(), ExcNotCompressed()); - if (cols->empty()) + if (val) + std::fill_n (&val[0], cols->n_nonzero_elements(), 0); +} + + + +template +void +SparseMatrix::reinit (const SparsityPattern &sparsity) +{ + cols = &sparsity; + + if (cols->empty()) { - if (val) delete[] val; + if (val != 0) + delete[] val; val = 0; max_len = 0; return; - }; + } const unsigned int N = cols->n_nonzero_elements(); if (N > max_len || max_len == 0) { - if (val) delete[] val; + if (val != 0) + delete[] val; val = new number[N]; max_len = N; - }; + } - if (val) + if (val != 0) std::fill_n (&val[0], N, 0); } -template -void -SparseMatrix::reinit (const SparsityPattern &sparsity) -{ - cols = &sparsity; - reinit (); -} - - - template void SparseMatrix::clear () @@ -246,7 +250,7 @@ void SparseMatrix::copy_from (const FullMatrix &matrix) { // first delete previous content - reinit (); + set_zero (); // then copy old matrix for (unsigned int row=0; row typename SparseLUDecomposition::AdditionalData AdditionalData; - /** - * This method is deprecated, and - * left for backward - * compability. It will be - * removed in later versions. - */ - void reinit (); - /** * This method is deprecated, and * left for backward diff --git a/deal.II/lac/include/lac/sparse_mic.templates.h b/deal.II/lac/include/lac/sparse_mic.templates.h index a370fa91ba..f51f45300e 100644 --- a/deal.II/lac/include/lac/sparse_mic.templates.h +++ b/deal.II/lac/include/lac/sparse_mic.templates.h @@ -1,5 +1,5 @@ //---------------------------- sparse_mic.templates.h --------------------------- -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 // by the deal.II authors and Stephen "Cheffo" Kolaroff // // This file is subject to QPL and may not be distributed @@ -80,31 +80,6 @@ void SparseMIC::initialize (const SparseMatrix &matrix, -template -void -SparseMIC::reinit () -{ - if (true) - { - std::vector tmp; - tmp.swap (diag); - }; - if (true) - { - std::vector tmp; - tmp.swap (inv_diag); - }; - if (true) - { - std::vector tmp; - tmp.swap (inner_sums); - }; - - SparseLUDecomposition::reinit (); -} - - - template void SparseMIC::reinit (const SparsityPattern& sparsity) { diff --git a/deal.II/lac/source/petsc_matrix_base.cc b/deal.II/lac/source/petsc_matrix_base.cc index 1f0f0fdffd..82cf58217f 100644 --- a/deal.II/lac/source/petsc_matrix_base.cc +++ b/deal.II/lac/source/petsc_matrix_base.cc @@ -133,7 +133,7 @@ namespace PETScWrappers void - MatrixBase::reinit () + MatrixBase::set_zero () { const int ierr = MatZeroEntries (matrix); AssertThrow (ierr == 0, ExcPETScError(ierr)); -- 2.39.5