/**
* 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 ();
/**
* 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 ();
// $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
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
values[k] = val;
else
{
- values[k].clear ();
+ values[k] = 0;
values[k](this->selected) = val;
}
}
{
typename std::vector<boost::shared_ptr<Object> >::iterator v;
for (v = objects.begin(); v != objects.end(); ++v)
- (*v)->clear();
+ **v = 0;
}
Vector<number> tmp1(dofs_per_cell);
Vector<number> tmp2(dofs_per_cell);
- interpolated_values.clear ();
+ interpolated_values = 0;
// later on we will have to
// push the values interpolated
const unsigned int local_parameter_dof
= coarse_fe.system_to_component_index(local_dof).second;
- global_parameter_representation.clear ();
+ global_parameter_representation = 0;
// distribute the representation of
// @p{local_parameter_dof} on the
// $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
std::vector<unsigned int> index_multiplicity(dof2.n_dofs(),0);
std::vector<unsigned int> dofs (dofs_per_cell2);
- u2.clear ();
+ u2 = 0;
for (; cell1!=endc1, cell2!=endc2; ++cell1, ++cell2)
{
else
// fill with zeroes.
for (unsigned int s=0; s<n_solution_vectors; ++s)
- grad_neighbor[s].clear ();
+ grad_neighbor[s] = 0;
// if there is a
// coefficient, then
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 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
fe_values.reinit (cell);
cell_matrix.clear ();
- local_rhs.clear ();
+ local_rhs = 0;
cell->get_dof_indices (dof_indices);
rhs.value_list (fe_values.get_quadrature_points(), rhs_values);
boundary_functions.end())
{
cell_matrix.clear ();
- cell_vector.clear ();
+ cell_vector = 0;
fe_values.reinit (cell, face);
fe_values.reinit (cell);
cell_matrix.clear ();
- local_rhs.clear ();
+ local_rhs = 0;
cell->get_dof_indices (dof_indices);
rhs.value_list (fe_values.get_quadrature_points(), rhs_values);
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 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
ExcComponentMismatch());
Assert (rhs_vector.size() == dof_handler.n_dofs(),
ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs()));
- rhs_vector.clear();
+ rhs_vector = 0;
UpdateFlags update_flags = UpdateFlags(update_values |
update_q_points |
const std::vector<double> &weights = fe_values.get_JxW_values ();
rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values);
- cell_vector.clear();
+ cell_vector = 0;
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<dofs_per_cell; ++i)
cell_vector(i) += rhs_values[point] *
const std::vector<double> &weights = fe_values.get_JxW_values ();
rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values);
- cell_vector.clear();
+ cell_vector = 0;
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
ExcComponentMismatch());
Assert (rhs_vector.size() == dof_handler.n_dofs(),
ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs()));
- rhs_vector.clear();
+
+ rhs_vector = 0;
UpdateFlags update_flags = UpdateFlags(update_values |
update_q_points |
const std::vector<double> &weights = fe_values.get_JxW_values ();
rhs_function.value_list (fe_values.get_quadrature_points(), rhs_values);
- cell_vector.clear();
+ cell_vector = 0;
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<dofs_per_cell; ++i)
cell_vector(i) += rhs_values[point] *
const std::vector<double> &weights = fe_values.get_JxW_values ();
rhs_function.vector_value_list (fe_values.get_quadrature_points(), rhs_values);
- cell_vector.clear();
+ cell_vector = 0;
for (unsigned int point=0; point<n_q_points; ++point)
for (unsigned int i=0; i<dofs_per_cell; ++i)
{
<h3 style="color:red">Incompatibilities</h3>
<ol>
+ <li> <p> Changed: All the vector and block vector classes had a member
+ function <code class="member">clear</code> which simply reset 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
+ implement the semantics that the <code class="member">clear</code>
+ functions delete all entries of the containers, i.e. resize it to zero,
+ and we implemented similar semantics also for the <code
+ class="class">SparseMatrix</code><code class="class">DoFHandler</code>,
+ <code class="class">ConstraintMatrix</code> and various other
+ classes. To avoid this confusion in the future, the <code
+ class="member">clear</code> function has been dropped from the
+ interface of the vector classes. To set all elements of a vector to
+ zero without changing its size, the recommended way is to use the more
+ obvious notation <code class="member">v=0</code>. <br> (WB 2004/05/10)
+ </p>
+
<li> <p> Changed: the template parameter of <code
- class="class">MGTransferPrebuilt</code> is now the complete vector
- type, not just the value type of the vector. This allows to operate
- on <code class="class">Vector</code> as well as on <code
- class="class">BlockVector</code>. Unfortunately, the untested class
- <code class="class">MGTransferBlock</code> underwent some more
- changes without testing, such that it should be used with high
- caution.
- <br>
- (GK 2004/04/01)
- </p>
+ class="class">MGTransferPrebuilt</code> is now the complete vector
+ type, not just the value type of the vector. This allows to operate
+ on <code class="class">Vector</code> as well as on <code
+ class="class">BlockVector</code>. Unfortunately, the untested class
+ <code class="class">MGTransferBlock</code> underwent some more
+ changes without testing, such that it should be used with high
+ caution.
+ <br>
+ (GK 2004/04/01)
+ </p>
<li> <p> Changed: The <code class="class">FiniteElement</code> classes had a
function <code class="member">restrict</code> that returns the
/* $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 */
// ``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
for (;cell!=endc; ++cell)
{
u_v_matrix.clear ();
- cell_vector.clear ();
+ cell_vector = 0;
fe_v.reinit (cell);
// 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,
/* $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 */
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);
endc = this->dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
cell->get_dof_indices (local_dof_indices);
for (unsigned int i=0; i<dofs_per_cell; ++i)
rhs(local_dof_indices[i]) += cell_rhs(i);
- };
+ }
}
// 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
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// As before, we want the
// FEValues object to compute
if (cell->subdomain_id() == this_mpi_process)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
/* $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 */
// 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
/* $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 */
{
fe_values.reinit (cell);
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// Now we have to assemble the
// local matrix and right hand
/* $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 */
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// As before, we want the
// FEValues object to compute
/* $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 */
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
/* $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 */
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
for (; cell!=endc; ++cell)
{
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
fe_values.reinit (cell);
/* $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 */
// First clear old contents of
// the cell contributions...
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
// ... then initialize
// the ``FEValues'' object...
void reinit (const BlockVector<Number2> &V,
const bool fast=false);
- /**
- * Set all entries to zero. Equivalent to
- * <tt>v=0</tt>, but more obvious and
- * faster. Note that this function does
- * not change the size of the vector,
- * unlike the STL's
- * <tt>vector<>::clear</tt> function.
- */
- void clear ();
-
/**
* Update internal structures
* after resizing
-template <typename Number>
-void BlockVector<Number>::clear ()
-{
- for (unsigned int i=0;i<num_blocks;++i)
- {
- components[i].clear();
- }
-}
-
-
template <typename Number>
bool
BlockVector<Number>::all_zero () const
*/
void compress ();
- /**
- * Set all entries to zero. Equivalent
- * to <tt>v = 0</tt>, but more obvious and
- * faster. Note that this function
- * does not change the size of the
- * vector, unlike the STL's
- * <tt>vector<>::clear</tt> function.
- */
- void clear ();
-
/**
* Set all components of the vector to
* the given number @p s.
Assert (&src != &dst, ExcSourceEqualsDestination());
- dst.clear ();
+ dst = 0;
for (unsigned int i=0;i<m();i++)
{
// $Id$
// Version: $Name$
//
-// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors
+// Copyright (C) 1998, 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
const Vector<number2> &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);
void SparseBlockVanka<number>::vmult (Vector<number2> &dst,
const Vector<number2> &src) const
{
- dst.clear ();
+ dst = 0;
// if no blocking is required, pass
// down to the underlying class
*/
void compress () const;
- /**
- * Set all entries to zero. Equivalent to
- * <tt>v = 0</tt>, but more obvious and
- * faster. Note that this function does
- * not change the size of the vector,
- * unlike the STL's <tt>vector<>::clear</tt>
- * function.
- */
- void clear ();
-
/**
* Change the dimension of the vector to
* @p N. The reserved memory for this
};
dim = n;
if (fast == false)
- clear ();
-}
-
-
-
-template <typename Number>
-inline
-void Vector<Number>::clear ()
-{
- if (dim>0)
- std::fill (begin(), end(), 0.);
+ *this = 0;
}
- void
- VectorBase::clear ()
- {
- const PetscScalar zero = 0;
- const int ierr = VecSet (&zero, vector);
- AssertThrow (ierr == 0, ExcPETScError(ierr));
- }
-
-
-
VectorBase &
VectorBase::operator = (const PetscScalar s)
{
Assert (values.size() == dim+1,
ExcDimensionMismatch (values.size(), dim+1));
- values.clear ();
+ values = 0;
values(dim) = 1.;
}
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_vector.clear ();
+ local_vector = 0;
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
local_vector(i) = (i+1.)*(local_dofs[i]+1.);
//---------------------------- petsc_24.cc ---------------------------
-// check PETScWrappers::Vector::clear()
+// this test used to check for PETScWrappers::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 <lac/petsc_vector.h>
// 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());
//---------------------------- vector_24.cc ---------------------------
-// check Vector<double>::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 <lac/vector.h>
// 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());
fe_values.reinit (cell);
cell_matrix.clear ();
- cell_rhs.clear ();
+ cell_rhs = 0;
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (unsigned int j=0; j<dofs_per_cell; ++j)
bool testcase_succeeded = true;
for (unsigned int vertex=0; vertex<4; ++vertex)
{
- val.clear ();
+ val = 0;
val(vertex) = 1;
std::vector<Tensor<1,2> > grads(4);
for (unsigned int vertex=0; vertex<4; ++vertex)
{
- val.clear ();
+ val = 0;
val(vertex) = 1;
std::vector<Tensor<2,2> > derivs(4);
{
const typename DoFHandler<dim>::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())
{
{
const typename DoFHandler<dim>::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())
{