From: Wolfgang Bangerth Date: Mon, 10 Aug 1998 14:23:49 +0000 (+0000) Subject: Refine an assertion a bit, since it killed my program unnecessarily. X-Git-Tag: v8.0.0~22773 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=adaa468a0fff6cab30086ce7ccc73da4bb309b7b;p=dealii.git Refine an assertion a bit, since it killed my program unnecessarily. git-svn-id: https://svn.dealii.org/trunk@481 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 91b7f988f1..eda20bdb1d 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -257,6 +257,34 @@ void MatrixCreator::create_boundary_mass_matrix (const DoFHandler & cell->face(face)->get_dof_indices (dofs_on_face_vector); set dofs_on_face (dofs_on_face_vector.begin(), dofs_on_face_vector.end()); +#ifdef DEBUG + // in debug mode: compute an element + // in the matrix which is + // guaranteed to belong to a boundary + // dof. We do this to check that the + // entries in the cell matrix are + // guaranteed to be zero if the + // respective dof is not on the + // boundary. Since because of + // round-off, the actual + // value of the matrix entry may be + // only close to zero, we assert that + // it is small relative to an element + // which is guaranteed to be nonzero. + // (absolute smallness does not + // suffice since the size of the + // domain scales in here) + // + // for this purpose we seek the + // diagonal of the matrix, where there + // must be an element belonging to + // the boundary. we take the maximum + // diagonal entry. + double max_diag_entry = 0; + for (unsigned int i=0; i max_diag_entry) + max_diag_entry = fabs(cell_matrix(i,i)); +#endif for (unsigned int i=0; i::create_boundary_mass_matrix (const DoFHandler & cell_matrix(i,j)); else { - Assert (fabs(cell_matrix(i,j)) <= 1e-10, + // compare here for relative + // smallness + Assert (fabs(cell_matrix(i,j)) <= 1e-10 * max_diag_entry, ExcInternalError ()); }; @@ -276,7 +306,9 @@ void MatrixCreator::create_boundary_mass_matrix (const DoFHandler & rhs_vector(dof_to_boundary_mapping[dofs[j]]) += cell_vector(j); else { - Assert (fabs(cell_vector(j)) <= 1e-10, + // compare here for relative + // smallness + Assert (fabs(cell_vector(j)) <= 1e-10 * max_diag_entry, ExcInternalError()); }; };