From: wolf
Date: Mon, 10 May 2004 15:32:53 +0000 (+0000)
Subject: Purge the Vector::clear function.
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=084e643cce72d5ed96bc83a8164abeea4038f319;p=dealii-svn.git
Purge the Vector::clear function.
git-svn-id: https://svn.dealii.org/trunk@9221 0785d39b-7218-0410-832d-ea1e28bc413d
---
diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h
index 752c7a1ba5..be4266a21b 100644
--- a/deal.II/base/include/base/tensor.h
+++ b/deal.II/base/include/base/tensor.h
@@ -168,6 +168,21 @@ class Tensor
/**
* Reset all values to zero.
+ *
+ * Note that this is partly inconsistent
+ * with the semantics of the @p clear()
+ * member functions of the STL and of
+ * several other classes within deal.II
+ * which not only reset the values of
+ * stored elements to zero, but release
+ * all memory and return the object into
+ * a virginial state. However, since the
+ * size of objects of the present type is
+ * determined by its template parameters,
+ * resizing is not an option, and indeed
+ * the state where all elements have a
+ * zero value is the state right after
+ * construction of such an object.
*/
void clear ();
diff --git a/deal.II/base/include/base/tensor_base.h b/deal.II/base/include/base/tensor_base.h
index 336848bf12..ddb91e092b 100644
--- a/deal.II/base/include/base/tensor_base.h
+++ b/deal.II/base/include/base/tensor_base.h
@@ -212,6 +212,21 @@ class Tensor<1,dim>
/**
* Reset all values to zero.
+ *
+ * Note that this is partly inconsistent
+ * with the semantics of the @p clear()
+ * member functions of the STL and of
+ * several other classes within deal.II
+ * which not only reset the values of
+ * stored elements to zero, but release
+ * all memory and return the object into
+ * a virginial state. However, since the
+ * size of objects of the present type is
+ * determined by its template parameters,
+ * resizing is not an option, and indeed
+ * the state where all elements have a
+ * zero value is the state right after
+ * construction of such an object.
*/
void clear ();
diff --git a/deal.II/base/source/function_lib_cutoff.cc b/deal.II/base/source/function_lib_cutoff.cc
index 8010871e32..18023aa2af 100644
--- a/deal.II/base/source/function_lib_cutoff.cc
+++ b/deal.II/base/source/function_lib_cutoff.cc
@@ -2,7 +2,7 @@
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal authors
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal authors
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
@@ -120,7 +120,7 @@ namespace Functions
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
@@ -194,7 +194,7 @@ namespace Functions
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
@@ -287,7 +287,7 @@ namespace Functions
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
diff --git a/deal.II/deal.II/include/multigrid/mg_level_object.h b/deal.II/deal.II/include/multigrid/mg_level_object.h
index f0a8423395..4b643df2d3 100644
--- a/deal.II/deal.II/include/multigrid/mg_level_object.h
+++ b/deal.II/deal.II/include/multigrid/mg_level_object.h
@@ -169,7 +169,7 @@ MGLevelObject
Changed: The FiniteElement classes had a
function restrict that returns the
diff --git a/deal.II/examples/step-12/step-12.cc b/deal.II/examples/step-12/step-12.cc
index 7d7733f9b3..8ef66c88b7 100644
--- a/deal.II/examples/step-12/step-12.cc
+++ b/deal.II/examples/step-12/step-12.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -837,7 +837,7 @@ void DGMethod::assemble_system1 ()
// ``cell_vector'' to zero,
// before assembling the cell terms.
u_v_matrix.clear ();
- cell_vector.clear ();
+ cell_vector = 0;
// Now we reinit the ``FEValues''
// object for the current cell
@@ -1271,7 +1271,7 @@ void DGMethod::assemble_system2 ()
for (;cell!=endc; ++cell)
{
u_v_matrix.clear ();
- cell_vector.clear ();
+ cell_vector = 0;
fe_v.reinit (cell);
@@ -1625,7 +1625,7 @@ void DGMethod::run ()
// right hand side vector and
// the Timer object.
system_matrix.reinit();
- right_hand_side.clear();
+ right_hand_side = 0;
assemble_timer.reset();
// We start the Timer,
diff --git a/deal.II/examples/step-13/step-13.cc b/deal.II/examples/step-13/step-13.cc
index acab8e761b..4d1c8cc4ca 100644
--- a/deal.II/examples/step-13/step-13.cc
+++ b/deal.II/examples/step-13/step-13.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -1623,7 +1623,7 @@ namespace LaplaceSolver
endc = this->dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
rhs_function->value_list (fe_values.get_quadrature_points(),
rhs_values);
diff --git a/deal.II/examples/step-14/step-14.cc b/deal.II/examples/step-14/step-14.cc
index c14b1cb7d6..d4cbff01d5 100644
--- a/deal.II/examples/step-14/step-14.cc
+++ b/deal.II/examples/step-14/step-14.cc
@@ -971,7 +971,7 @@ namespace LaplaceSolver
endc = this->dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
@@ -987,7 +987,7 @@ namespace LaplaceSolver
cell->get_dof_indices (local_dof_indices);
for (unsigned int i=0; i::assemble_step ()
// the local matrix and right hand side
// contributions for this cell:
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// Then initialize the values and
// gradients of the shape functions at
diff --git a/deal.II/examples/step-16/step-16.cc b/deal.II/examples/step-16/step-16.cc
index 9a359625c8..db9efb2377 100644
--- a/deal.II/examples/step-16/step-16.cc
+++ b/deal.II/examples/step-16/step-16.cc
@@ -215,7 +215,7 @@ void LaplaceProblem::assemble_system ()
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// As before, we want the
// FEValues object to compute
diff --git a/deal.II/examples/step-17/step-17.cc b/deal.II/examples/step-17/step-17.cc
index ff1573209a..4eee20ff95 100644
--- a/deal.II/examples/step-17/step-17.cc
+++ b/deal.II/examples/step-17/step-17.cc
@@ -565,7 +565,7 @@ void ElasticProblem::assemble_system ()
if (cell->subdomain_id() == this_mpi_process)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
diff --git a/deal.II/examples/step-3/step-3.cc b/deal.II/examples/step-3/step-3.cc
index 29c647ed82..0e6152cbde 100644
--- a/deal.II/examples/step-3/step-3.cc
+++ b/deal.II/examples/step-3/step-3.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -482,7 +482,7 @@ void LaplaceProblem::assemble_system ()
// right hand side to zero,
// before we fill them.
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// Assemble the matrix: For the
// Laplace problem, the matrix
diff --git a/deal.II/examples/step-4/step-4.cc b/deal.II/examples/step-4/step-4.cc
index 242bc84b12..4f9458703f 100644
--- a/deal.II/examples/step-4/step-4.cc
+++ b/deal.II/examples/step-4/step-4.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -407,7 +407,7 @@ void LaplaceProblem::assemble_system ()
{
fe_values.reinit (cell);
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// Now we have to assemble the
// local matrix and right hand
diff --git a/deal.II/examples/step-5/step-5.cc b/deal.II/examples/step-5/step-5.cc
index 1ac610a46b..f83be3f327 100644
--- a/deal.II/examples/step-5/step-5.cc
+++ b/deal.II/examples/step-5/step-5.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 1999, 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -429,7 +429,7 @@ void LaplaceProblem::assemble_system ()
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// As before, we want the
// FEValues object to compute
diff --git a/deal.II/examples/step-6/step-6.cc b/deal.II/examples/step-6/step-6.cc
index 4cfcba56c3..35f1494a30 100644
--- a/deal.II/examples/step-6/step-6.cc
+++ b/deal.II/examples/step-6/step-6.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -510,7 +510,7 @@ void LaplaceProblem::assemble_system ()
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
diff --git a/deal.II/examples/step-7/step-7.cc b/deal.II/examples/step-7/step-7.cc
index 34174a25fb..c577f0b0a8 100644
--- a/deal.II/examples/step-7/step-7.cc
+++ b/deal.II/examples/step-7/step-7.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -879,7 +879,7 @@ void LaplaceProblem::assemble_system ()
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
diff --git a/deal.II/examples/step-8/step-8.cc b/deal.II/examples/step-8/step-8.cc
index 3cb570bff5..4746120737 100644
--- a/deal.II/examples/step-8/step-8.cc
+++ b/deal.II/examples/step-8/step-8.cc
@@ -518,7 +518,7 @@ void ElasticProblem::assemble_system ()
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
diff --git a/deal.II/examples/step-9/step-9.cc b/deal.II/examples/step-9/step-9.cc
index 32da47f75f..c48a953381 100644
--- a/deal.II/examples/step-9/step-9.cc
+++ b/deal.II/examples/step-9/step-9.cc
@@ -4,7 +4,7 @@
/* $Id$ */
/* Version: $Name$ */
/* */
-/* Copyright (C) 2000, 2001, 2002, 2003 by the deal.II authors */
+/* Copyright (C) 2000, 2001, 2002, 2003, 2004 by the deal.II authors */
/* */
/* This file is subject to QPL and may not be distributed */
/* without copyright and license information. Please refer */
@@ -1036,7 +1036,7 @@ assemble_system_interval (const typename DoFHandler::active_cell_iterator &
// First clear old contents of
// the cell contributions...
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// ... then initialize
// the ``FEValues'' object...
diff --git a/deal.II/lac/include/lac/block_vector.h b/deal.II/lac/include/lac/block_vector.h
index 0ad1e712ab..557eb0f4a5 100644
--- a/deal.II/lac/include/lac/block_vector.h
+++ b/deal.II/lac/include/lac/block_vector.h
@@ -814,16 +814,6 @@ class BlockVector
void reinit (const BlockVector &V,
const bool fast=false);
- /**
- * Set all entries to zero. Equivalent to
- * v=0, but more obvious and
- * faster. Note that this function does
- * not change the size of the vector,
- * unlike the STL's
- * vector<>::clear function.
- */
- void clear ();
-
/**
* Update internal structures
* after resizing
diff --git a/deal.II/lac/include/lac/block_vector.templates.h b/deal.II/lac/include/lac/block_vector.templates.h
index 1abfbc6f1b..ded153a7e1 100644
--- a/deal.II/lac/include/lac/block_vector.templates.h
+++ b/deal.II/lac/include/lac/block_vector.templates.h
@@ -137,16 +137,6 @@ void BlockVector::swap (BlockVector &v)
-template
-void BlockVector::clear ()
-{
- for (unsigned int i=0;i
bool
BlockVector::all_zero () const
diff --git a/deal.II/lac/include/lac/petsc_vector_base.h b/deal.II/lac/include/lac/petsc_vector_base.h
index cb67fcde13..ab535eac7b 100644
--- a/deal.II/lac/include/lac/petsc_vector_base.h
+++ b/deal.II/lac/include/lac/petsc_vector_base.h
@@ -246,16 +246,6 @@ namespace PETScWrappers
*/
void compress ();
- /**
- * Set all entries to zero. Equivalent
- * to v = 0, but more obvious and
- * faster. Note that this function
- * does not change the size of the
- * vector, unlike the STL's
- * vector<>::clear function.
- */
- void clear ();
-
/**
* Set all components of the vector to
* the given number @p s.
diff --git a/deal.II/lac/include/lac/sparse_matrix.templates.h b/deal.II/lac/include/lac/sparse_matrix.templates.h
index 0a3547f79b..e24791371e 100644
--- a/deal.II/lac/include/lac/sparse_matrix.templates.h
+++ b/deal.II/lac/include/lac/sparse_matrix.templates.h
@@ -388,7 +388,7 @@ SparseMatrix::Tvmult (OutVector& dst,
Assert (&src != &dst, ExcSourceEqualsDestination());
- dst.clear ();
+ dst = 0;
for (unsigned int i=0;i::vmult (Vector &dst,
const Vector &src) const
{
// first set output vector to zero
- dst.clear ();
+ dst = 0;
// then pass on to the function
// that actually does the work
apply_preconditioner (dst, src);
@@ -564,7 +564,7 @@ template
void SparseBlockVanka::vmult (Vector &dst,
const Vector &src) const
{
- dst.clear ();
+ dst = 0;
// if no blocking is required, pass
// down to the underlying class
diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h
index 343809e481..afe374a872 100644
--- a/deal.II/lac/include/lac/vector.h
+++ b/deal.II/lac/include/lac/vector.h
@@ -209,16 +209,6 @@ class Vector
*/
void compress () const;
- /**
- * Set all entries to zero. Equivalent to
- * v = 0, but more obvious and
- * faster. Note that this function does
- * not change the size of the vector,
- * unlike the STL's vector<>::clear
- * function.
- */
- void clear ();
-
/**
* Change the dimension of the vector to
* @p N. The reserved memory for this
@@ -818,17 +808,7 @@ void Vector::reinit (const unsigned int n, const bool fast)
};
dim = n;
if (fast == false)
- clear ();
-}
-
-
-
-template
-inline
-void Vector::clear ()
-{
- if (dim>0)
- std::fill (begin(), end(), 0.);
+ *this = 0;
}
diff --git a/deal.II/lac/source/petsc_vector_base.cc b/deal.II/lac/source/petsc_vector_base.cc
index 54707fdd8c..1ddfb78601 100644
--- a/deal.II/lac/source/petsc_vector_base.cc
+++ b/deal.II/lac/source/petsc_vector_base.cc
@@ -118,16 +118,6 @@ namespace PETScWrappers
- void
- VectorBase::clear ()
- {
- const PetscScalar zero = 0;
- const int ierr = VecSet (&zero, vector);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
- }
-
-
-
VectorBase &
VectorBase::operator = (const PetscScalar s)
{
diff --git a/tests/bits/anna_6.cc b/tests/bits/anna_6.cc
index d733c614a9..6fdfdd4ab5 100644
--- a/tests/bits/anna_6.cc
+++ b/tests/bits/anna_6.cc
@@ -126,7 +126,7 @@ void BoundaryFunction::vector_value (const Point &,
Assert (values.size() == dim+1,
ExcDimensionMismatch (values.size(), dim+1));
- values.clear ();
+ values = 0;
values(dim) = 1.;
}
diff --git a/tests/bits/dof_constraints_02.cc b/tests/bits/dof_constraints_02.cc
index 1eb0bce2d5..e8781a47de 100644
--- a/tests/bits/dof_constraints_02.cc
+++ b/tests/bits/dof_constraints_02.cc
@@ -81,7 +81,7 @@ void test ()
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_vector.clear ();
+ local_vector = 0;
for (unsigned int i=0; i
@@ -32,7 +34,7 @@ void test (PETScWrappers::Vector &v)
// then clear it again and make sure the
// vector is really empty
const unsigned int sz = v.size();
- v.clear ();
+ v = 0;
Assert (v.size() == sz, ExcInternalError());
Assert (v.l2_norm() == 0, ExcInternalError());
diff --git a/tests/bits/vector_24.cc b/tests/bits/vector_24.cc
index 770bff1c50..6a50f5ccb4 100644
--- a/tests/bits/vector_24.cc
+++ b/tests/bits/vector_24.cc
@@ -12,7 +12,9 @@
//---------------------------- vector_24.cc ---------------------------
-// check Vector::clear()
+// this test used to check for Vector::clear(). However, this
+// function has since been removed, so we test for v=0 instead, although that
+// may be covered by one of the other tests
#include "../tests.h"
#include
@@ -32,7 +34,7 @@ void test (Vector &v)
// then clear it again and make sure the
// vector is really empty
const unsigned int sz = v.size();
- v.clear ();
+ v = 0;
Assert (v.size() == sz, ExcInternalError());
Assert (v.l2_norm() == 0, ExcInternalError());
diff --git a/tests/deal.II/block_matrices.cc b/tests/deal.II/block_matrices.cc
index 78df570253..6c133ef607 100644
--- a/tests/deal.II/block_matrices.cc
+++ b/tests/deal.II/block_matrices.cc
@@ -277,7 +277,7 @@ void LaplaceProblem::assemble_system ()
fe_values.reinit (cell);
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
for (unsigned int i=0; i > grads(4);
diff --git a/tests/deal.II/second_derivatives.cc b/tests/deal.II/second_derivatives.cc
index 4b8c452f49..92d0730285 100644
--- a/tests/deal.II/second_derivatives.cc
+++ b/tests/deal.II/second_derivatives.cc
@@ -76,7 +76,7 @@ int main ()
for (unsigned int vertex=0; vertex<4; ++vertex)
{
- val.clear ();
+ val = 0;
val(vertex) = 1;
std::vector > derivs(4);
diff --git a/tests/deal.II/wave-test-3.cc b/tests/deal.II/wave-test-3.cc
index f64dd7910e..b583562704 100644
--- a/tests/deal.II/wave-test-3.cc
+++ b/tests/deal.II/wave-test-3.cc
@@ -5381,8 +5381,8 @@ TimeStep_Dual::collect_from_children (const typename DoFHandler::cell_
{
const typename DoFHandler::cell_iterator old_child = old_cell->child(c);
- child_rhs1.clear ();
- child_rhs2.clear ();
+ child_rhs1 = 0;
+ child_rhs2 = 0;
if (old_child->has_children())
{
@@ -7135,8 +7135,8 @@ FullMatrix cell_matrix (dofs_per_cell, dofs_per_cell);
{
const typename DoFHandler::cell_iterator old_child = old_cell->child(c);
- child_rhs1.clear ();
- child_rhs2.clear ();
+ child_rhs1 = 0;
+ child_rhs2 = 0;
if (old_child->has_children())
{