// couple different bases (or
// multiplicity indices) are really
// zero. then assign entries
- interpolation_matrix.clear ();
+ interpolation_matrix.set_zero ();
for (unsigned int i=0; i<this->dofs_per_cell; ++i)
for (unsigned int j=0; j<source_fe.dofs_per_cell; ++j)
if (this->system_to_base_table[i].first ==
ExcMatrixDimensionMismatch(matrix.m(), matrix.n(),
fe2.dofs_per_cell,
fe1.dofs_per_cell));
- matrix.clear();
+ matrix.set_zero();
unsigned int n1 = fe1.dofs_per_cell;
unsigned int n2 = fe2.dofs_per_cell;
DerivativeDescription::symmetrize (projected_derivative);
// compute Y^-1 g
- typename DerivativeDescription::Derivative derivative;
- Tensor<2,dim> Y_inverse = invert(Y);
+ const Tensor<2,dim> Y_inverse = invert(Y);
+ typename DerivativeDescription::Derivative derivative;
contract (derivative, Y_inverse, projected_derivative);
*derivative_norm_on_this_cell
= DerivativeDescription::derivative_norm (derivative);
- };
+ }
}
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell->get_dof_indices (dof_indices);
if (coefficient != 0)
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
local_rhs = 0;
cell->get_dof_indices (dof_indices);
if (boundary_functions.find(cell->face(face)->boundary_indicator()) !=
boundary_functions.end())
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_vector = 0;
fe_values.reinit (cell, face);
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell->get_dof_indices (dof_indices);
if (coefficient != 0)
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
local_rhs = 0;
cell->get_dof_indices (dof_indices);
// ``u_v_matrix'' and
// ``cell_vector'' to zero,
// before assembling the cell terms.
- u_v_matrix.clear ();
+ u_v_matrix.set_zero ();
cell_vector = 0;
// Now we reinit the ``FEValues''
// and clear the
// ``un_v_matrix'' on each
// face.
- un_v_matrix.clear();
+ un_v_matrix.set_zero();
// Now we distinguish the
// four different cases in
// different
// neighboring
// cells.
- un_v_matrix.clear();
+ un_v_matrix.set_zero();
// As already
// mentioned
endc = dof_handler.end();
for (;cell!=endc; ++cell)
{
- u_v_matrix.clear ();
+ u_v_matrix.set_zero ();
cell_vector = 0;
fe_v.reinit (cell);
ExcInternalError());
Assert (!neighbor_child->has_children(), ExcInternalError());
- un_v_matrix.clear();
- u_vn_matrix.clear();
- un_vn_matrix.clear();
+ un_v_matrix.set_zero();
+ u_vn_matrix.set_zero();
+ un_vn_matrix.set_zero();
fe_v_subface.reinit (cell, face_no, subface_no);
fe_v_face_neighbor.reinit (neighbor_child, neighbor2);
{
const unsigned int neighbor2=cell->neighbor_of_neighbor(face_no);
- un_v_matrix.clear();
- u_vn_matrix.clear();
- un_vn_matrix.clear();
+ un_v_matrix.set_zero();
+ u_vn_matrix.set_zero();
+ un_vn_matrix.set_zero();
fe_v_face.reinit (cell, face_no);
fe_v_face_neighbor.reinit (neighbor, neighbor2);
for (typename DoFHandler<dim>::active_cell_iterator cell=begin_cell;
cell!=end_cell; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
fe_values.reinit (cell);
for (typename DoFHandler<dim>::active_cell_iterator cell=begin_cell;
cell!=end_cell; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
fe_values.reinit (cell);
Assert ((n/2)*2 == n, ExcMessage ("Value of 'n' must be even"));
double p = 1;
for (unsigned int k=0; k<n; k+=2)
- p += (v*v);
+ p *= (v*v);
return p;
}
// First, clear the objects that hold
// the local matrix and right hand side
// contributions for this cell:
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// Then initialize the values and
{
// At the present location, which is
// ``present_solution+alpha*update'',
- // evaluate the energy"
+ // evaluate the energy
tmp = present_solution;
tmp.add (alpha, update);
const double f_a = energy (dof_handler, tmp);
endc = mg_dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// As before, we want the
// Remember the level of the
// current cell.
const unsigned int level = cell->level();
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
// Compute the values specified
// by update flags above.
for (; cell!=endc; ++cell)
if (cell->subdomain_id() == this_mpi_process)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
fe_values.reinit (cell);
// to global matrix and global
// right hand side to zero,
// before we fill them.
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// Assemble the matrix: For the
for (; cell!=endc; ++cell)
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// Now we have to assemble the
endc = dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// As before, we want the
endc = dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
fe_values.reinit (cell);
endc = dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
fe_values.reinit (cell);
endc = dof_handler.end();
for (; cell!=endc; ++cell)
{
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
fe_values.reinit (cell);
{
// First clear old contents of
// the cell contributions...
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
// ... then initialize
bool transpose = false);
/**
- * Delete all entries
+ * Delete all entries, i.e. reset
+ * the matrix to an empty state.
*/
void clear();
* Final iterator of row <tt>r</tt>.
*/
const_iterator end (const unsigned int r) const;
+
+ /**
+ * Set all entries to zero, but
+ * do not change the size of the
+ * matrix.
+ */
+ void set_zero ();
/**
* Scale the entire matrix by a
DeclException0 (ExcSourceEqualsDestination);
friend class Accessor;
+
+ private:
+ void clear ();
};
/*@}*/
template <typename number>
-inline unsigned int
+inline
+unsigned int
FullMatrix<number>::m() const
{
return this->n_rows();
template <typename number>
-inline unsigned int
+inline
+unsigned int
FullMatrix<number>::n() const
{
return this->n_cols();
}
+
+template <typename number>
+void
+FullMatrix<number>::set_zero ()
+{
+ if (this->n_elements() != 0)
+ std::fill_n (this->val, this->n_elements(), number());
+}
+
+
+
template <typename number>
template <typename number2>
inline
Table<2,number>::fill(src);
}
+
+
template <typename number>
template <class MATRIX>
void
// soon as possible
};
- M_cell.clear ();
+ M_cell.set_zero ();
for (unsigned int cell=0; cell<nblocks; ++cell)
{
* to a state just like after
* having called the default
* constructor. It also forgets
- * the sparsity pattern it was
- * previously tied to.
+ * its sparsity pattern.
*/
void clear ();
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_matrix.clear ();
+ local_matrix.set_zero ();
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_matrix.clear ();
+ local_matrix.set_zero ();
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_matrix.clear ();
+ local_matrix.set_zero ();
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_matrix.clear ();
+ local_matrix.set_zero ();
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
cell != dof_handler.end(); ++cell)
{
cell->get_dof_indices (local_dofs);
- local_matrix.clear ();
+ local_matrix.set_zero ();
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int j=0; j<fe.dofs_per_cell; ++j)
local_matrix(i,j) = (i+1.)*(j+1.)*(local_dofs[i]+1.)*(local_dofs[j]+1.);
//---------------------------- petsc_63.cc ---------------------------
-// PETScWrappers::SparseMatrix::reinit () was declared but not defined
+// PETScWrappers::SparseMatrix::set_zero () was declared but not defined
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
Assert (m.m() == 100, ExcInternalError());
Assert (m.n() == 100, ExcInternalError());
- m.reinit ();
+ m.set_zero ();
Assert (m.m() == 100, ExcInternalError());
Assert (m.n() == 100, ExcInternalError());
{
fe_values.reinit (cell);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
cell_rhs = 0;
for (unsigned int i=0; i<dofs_per_cell; ++i)
cell->get_dof_values (*this->u, local_u);
cell->get_dof_values (*this->v, local_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
this->density->value_list (fe_values.get_quadrature_points(),
density_values);
for (unsigned int point=0; point<fe_values.n_quadrature_points; ++point)
total_energy += 1./2. * cell_matrix.matrix_norm_square (local_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
this->stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
for (unsigned int point=0; point<fe_values.n_quadrature_points; ++point)
cell != dof_handler->end(); ++cell)
{
fe_values.reinit (cell);
- cell_mass_matrix.clear ();
- cell_laplace_matrix.clear ();
+ cell_mass_matrix.set_zero ();
+ cell_laplace_matrix.set_zero ();
cell->get_dof_indices (dof_indices_on_cell);
if (!density_constant || !stiffness_constant)
old_cell->get_dof_values (previous_time_level.u, tmp);
cell_matrix.vmult (local_M_u, tmp);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
old_child->get_dof_values (previous_time_level.u, local_old_dof_values_u);
old_child->get_dof_values (previous_time_level.v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> density_values(fe_values.n_quadrature_points);
this->parameters.density->value_list (fe_values.get_quadrature_points(),
density_values);
cell_matrix.vmult (local_M_u, local_old_dof_values_u);
cell_matrix.vmult (local_M_v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
else
{
fe_values.reinit (new_child);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> density_values(fe_values.n_quadrature_points);
this->parameters.density->value_list (fe_values.get_quadrature_points(),
density_values);
cell_matrix.vmult (local_M_u, local_old_dof_values_u);
cell_matrix.vmult (local_M_v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
old_cell->get_dof_values (previous_time_level.v, tmp);
cell_matrix.vmult (local_M_v, tmp);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
old_child->get_dof_values (previous_time_level.u, local_old_dof_values_u);
old_child->get_dof_values (previous_time_level.v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> density_values(fe_values.n_quadrature_points);
this->parameters.density->value_list (fe_values.get_quadrature_points(),
density_values);
cell_matrix.vmult (local_M_u, local_old_dof_values_u);
cell_matrix.vmult (local_M_v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
else
{
fe_values.reinit (new_child);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> density_values(fe_values.n_quadrature_points);
this->parameters.density->value_list (fe_values.get_quadrature_points(),
density_values);
cell_matrix.vmult (local_M_u, local_old_dof_values_u);
cell_matrix.vmult (local_M_v, local_old_dof_values_v);
- cell_matrix.clear ();
+ cell_matrix.set_zero ();
std::vector<double> stiffness_values(fe_values.n_quadrature_points);
this->parameters.stiffness->value_list (fe_values.get_quadrature_points(),
stiffness_values);
for (; cell!=endc; ++cell)
{
- local_matrix.clear ();
+ local_matrix.set_zero ();
fe_values.reinit (cell);
for (unsigned int i=0; i<dofs_per_cell; ++i)
for (; cell!=endc; ++cell)
{
- local_matrix.clear ();
+ local_matrix.set_zero ();
fe_values.reinit (cell);
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int comp_i=0; comp_i<fe.n_components(); ++comp_i)
for (; cell!=endc; ++cell)
{
- local_matrix.clear ();
+ local_matrix.set_zero ();
fe_values.reinit (cell);
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int comp_i=0; comp_i<fe.n_components(); ++comp_i)
for (; cell!=endc; ++cell)
{
- local_matrix.clear ();
+ local_matrix.set_zero ();
fe_values.reinit (cell);
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int comp_i=0; comp_i<fe.n_components(); ++comp_i)
for (; cell!=endc; ++cell)
{
- local_matrix.clear ();
+ local_matrix.set_zero ();
fe_values.reinit (cell);
for (unsigned int i=0; i<fe.dofs_per_cell; ++i)
for (unsigned int comp_i=0; comp_i<fe.n_components(); ++comp_i)
for (unsigned int i=0;i<4;++i)
{
// Setup rotation matrix
- C.clear();
+ C.set_zero();
C.diagadd(1.);
C(i,i) = C(i+1,i+1) = std::cos(i+1.);
C(i+1,i) = std::sin(i+1.);