From: Wolfgang Bangerth Date: Fri, 27 Feb 2015 20:37:52 +0000 (-0600) Subject: Remove assertion without argument. X-Git-Tag: v8.3.0-rc1~408^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac41cce810ecad8cf5b9e98edf477c6329a1de79;p=dealii.git Remove assertion without argument. Specifically, replace ExcNumberNotFinite with a way to provide both this number and a (lengthy) explanation of what may possibly have caused this problem. I see my students struggle with this error. --- diff --git a/include/deal.II/base/exceptions.h b/include/deal.II/base/exceptions.h index d27945cd78..1993bb285d 100644 --- a/include/deal.II/base/exceptions.h +++ b/include/deal.II/base/exceptions.h @@ -586,8 +586,40 @@ namespace StandardExceptions * This exception should be used to catch infinite or not a number results * of arithmetic operations that do not result from a division by zero (use * ExcDivideByZero for those). - */ - DeclException0 (ExcNumberNotFinite); + * + * The exception uses std::complex as its argument to ensure that we can + * use it for all scalar arguments (real or complex-valued). + */ + DeclException1 (ExcNumberNotFinite, + std::complex, + << "In a significant number of places, deal.II checks that some intermediate " + << "value is a finite number (as opposed to plus or minus infinity, or " + << "NaN/Not a Number). In the current function, we encountered a number " + << "that is not finite (its value is " << arg1 << " and therefore " + << "violates the current assertion.\n\n" + << "This may be due to the fact that some operation in this function " + << "created such a value, or because one of the arguments you passed " + << "to the function already had this value from some previous " + << "operation. In the latter case, this function only triggered the " + << "error but may not actually be responsible for the computation of " + << "the number that is not finite.\n\n" + << "There are two common cases where this situation happens. First, your " + << "code (or something in deal.II) divides by zero in a place where this " + << "should not happen. Or, you are trying to solve a linear system " + << "with an unsuitable solver (such as an indefinite or non-symmetric " + << "linear system using a Conjugate Gradient solver); such attempts " + << "oftentimes yield an operation somewhere that tries to divide " + << "by zero or take the square root of a negative value.\n\n" + << "In any case, when trying to find the source of the error, " + << "recall that the location where you are getting this error is " + << "simply the first place in the program where there is a check " + << "that a number (e.g., an element of a solution vector) is in fact " + << "finite, but that the actual error that computed the number " + << "may have happened far earlier. To find this location, you " + << "may want to add checks for finiteness in places of your " + << "program visited before the place where this error is produced." + << "One way to check for finiteness is to use the 'AssertIsFinite' " + << "macro."); /** * Trying to allocate a new object failed due to lack of free memory. @@ -880,6 +912,19 @@ namespace StandardExceptions #define AssertGlobalIndexRange(index,range) Assert((index) < (range), \ ExcIndexRange((index),0,(range))) +/** + * An assertion that checks whether a number is finite or not. + * We explicitly cast the number to std::complex to match + * the signature of the exception (see there for an explanation + * of why we use std::complex at all) and to satisfy the + * fact that std::complex has no implicit conversions. + * + * @ingroup Exceptions + * @author Wolfgang Bangerth, 2015 + */ +#define AssertIsFinite(number) Assert(dealii::numbers::is_finite(number), \ + ExcNumberNotFinite(std::complex(number))) + using namespace StandardExceptions; DEAL_II_NAMESPACE_CLOSE diff --git a/include/deal.II/lac/block_matrix_base.h b/include/deal.II/lac/block_matrix_base.h index 03aa5d2aad..cb29ab1136 100644 --- a/include/deal.II/lac/block_matrix_base.h +++ b/include/deal.II/lac/block_matrix_base.h @@ -1637,7 +1637,7 @@ BlockMatrixBase::set (const size_type i, { prepare_set_operation(); - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); const std::pair row_index = row_block_indices.global_to_local (i), @@ -1823,7 +1823,7 @@ BlockMatrixBase::add (const size_type i, const value_type value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); prepare_add_operation(); @@ -2069,7 +2069,7 @@ void BlockMatrixBase::add (const value_type factor, const BlockMatrixBase &matrix) { - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); prepare_add_operation(); diff --git a/include/deal.II/lac/block_sparse_matrix_ez.h b/include/deal.II/lac/block_sparse_matrix_ez.h index dff450ec9b..1544665905 100644 --- a/include/deal.II/lac/block_sparse_matrix_ez.h +++ b/include/deal.II/lac/block_sparse_matrix_ez.h @@ -353,7 +353,7 @@ BlockSparseMatrixEZ::set (const size_type i, const Number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); const std::pair row_index = row_indices.global_to_local (i), @@ -373,7 +373,7 @@ BlockSparseMatrixEZ::add (const size_type i, const Number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); const std::pair row_index = row_indices.global_to_local (i), diff --git a/include/deal.II/lac/block_vector.h b/include/deal.II/lac/block_vector.h index c860d4da51..8658febeec 100644 --- a/include/deal.II/lac/block_vector.h +++ b/include/deal.II/lac/block_vector.h @@ -380,7 +380,7 @@ BlockVector & BlockVector::operator = (const value_type s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); BaseClass::operator = (s); return *this; diff --git a/include/deal.II/lac/block_vector_base.h b/include/deal.II/lac/block_vector_base.h index c166215645..49c999b379 100644 --- a/include/deal.II/lac/block_vector_base.h +++ b/include/deal.II/lac/block_vector_base.h @@ -1935,7 +1935,7 @@ BlockVectorBase::add (const size_type n_indices, template void BlockVectorBase::add (const value_type a) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); for (size_type i=0; i::add (const value_type a, const BlockVectorBase &v) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -1984,8 +1984,8 @@ void BlockVectorBase::add (const value_type a, const BlockVectorBase &w) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2006,7 +2006,7 @@ void BlockVectorBase::sadd (const value_type x, const BlockVectorBase &v) { - Assert (numbers::is_finite(x), ExcNumberNotFinite()); + AssertIsFinite(x); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2024,8 +2024,8 @@ void BlockVectorBase::sadd (const value_type x, const value_type a, const BlockVectorBase &v) { - Assert (numbers::is_finite(x), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(x); + AssertIsFinite(a); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2045,9 +2045,9 @@ void BlockVectorBase::sadd (const value_type x, const value_type a, const BlockVectorBase &w) { - Assert (numbers::is_finite(x), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(x); + AssertIsFinite(a); + AssertIsFinite(b); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2071,10 +2071,10 @@ void BlockVectorBase::sadd (const value_type x, const value_type a, const BlockVectorBase &y) { - Assert (numbers::is_finite(x), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); - Assert (numbers::is_finite(c), ExcNumberNotFinite()); + AssertIsFinite(x); + AssertIsFinite(a); + AssertIsFinite(b); + AssertIsFinite(c); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2111,8 +2111,8 @@ void BlockVectorBase::equ (const value_type a, const BlockVectorBase &w) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2146,7 +2146,7 @@ void BlockVectorBase::equ (const value_type a, const BlockVector2 &v) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); Assert (n_blocks() == v.n_blocks(), ExcDimensionMismatch(n_blocks(), v.n_blocks())); @@ -2171,7 +2171,7 @@ BlockVectorBase & BlockVectorBase::operator = (const value_type s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); for (size_type i=0; i & BlockVectorBase::operator *= (const value_type factor) { - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); for (size_type i=0; i & BlockVectorBase::operator /= (const value_type factor) { - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); Assert (factor > 0., ExcDivideByZero() ); for (size_type i=0; i::set (const size_type i, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); Assert (cols != 0, ExcNotInitialized()); // it is allowed to set elements of the matrix that are not part of the @@ -1442,7 +1442,7 @@ void ChunkSparseMatrix::add (const size_type i, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); Assert (cols != 0, ExcNotInitialized()); diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index f34d1c05e0..b139753e0a 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -843,7 +843,7 @@ ConstraintMatrix::distribute (VectorType &vec) const new_value += (static_cast (ghosted_vector(it->entries[i].first)) * it->entries[i].second); - Assert(numbers::is_finite(new_value), ExcNumberNotFinite()); + AssertIsFinite(new_value); vec(it->line) = new_value; } @@ -871,7 +871,7 @@ ConstraintMatrix::distribute (VectorType &vec) const new_value += (static_cast (vec(next_constraint->entries[i].first)) * next_constraint->entries[i].second); - Assert(numbers::is_finite(new_value), ExcNumberNotFinite()); + AssertIsFinite(new_value); vec(next_constraint->line) = new_value; } } diff --git a/include/deal.II/lac/filtered_matrix.h b/include/deal.II/lac/filtered_matrix.h index a34979998c..789461e1e8 100644 --- a/include/deal.II/lac/filtered_matrix.h +++ b/include/deal.II/lac/filtered_matrix.h @@ -835,7 +835,7 @@ FilteredMatrix::apply_constraints ( const const_index_value_iterator e = constraints.end(); for (; i!=e; ++i) { - Assert(numbers::is_finite(i->second), ExcNumberNotFinite()); + AssertIsFinite(i->second); (*tmp_vector)(i->first) = -i->second; } @@ -847,7 +847,7 @@ FilteredMatrix::apply_constraints ( // entries themselves for (i=constraints.begin(); i!=e; ++i) { - Assert(numbers::is_finite(i->second), ExcNumberNotFinite()); + AssertIsFinite(i->second); v(i->first) = i->second; } } @@ -880,7 +880,7 @@ FilteredMatrix::post_filter (const VECTOR &in, const const_index_value_iterator e = constraints.end(); for (; i!=e; ++i) { - Assert(numbers::is_finite(in(i->first)), ExcNumberNotFinite()); + AssertIsFinite(in(i->first)); out(i->first) = in(i->first); } } diff --git a/include/deal.II/lac/full_matrix.h b/include/deal.II/lac/full_matrix.h index 16e3ae9c73..791d27f2fe 100644 --- a/include/deal.II/lac/full_matrix.h +++ b/include/deal.II/lac/full_matrix.h @@ -1360,7 +1360,7 @@ inline number FullMatrix::Accessor::value() const { - Assert (numbers::is_finite( matrix->el(a_row, a_col) ), ExcNumberNotFinite()); + AssertIsFinite(matrix->el(a_row, a_col)); return matrix->el(a_row, a_col); } diff --git a/include/deal.II/lac/full_matrix.templates.h b/include/deal.II/lac/full_matrix.templates.h index 2d4c88dde5..e1a113dcd1 100644 --- a/include/deal.II/lac/full_matrix.templates.h +++ b/include/deal.II/lac/full_matrix.templates.h @@ -150,7 +150,7 @@ FullMatrix & FullMatrix::operator *= (const number factor) { - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); number *p = &(*this)(0,0); const number *e = &(*this)(0,0) + n()*m(); @@ -167,14 +167,14 @@ FullMatrix & FullMatrix::operator /= (const number factor) { - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); number *p = &(*this)(0,0); const number *e = &(*this)(0,0) + n()*m(); const number factor_inv = number(1.)/factor; - Assert (numbers::is_finite(factor_inv), ExcNumberNotFinite()); + AssertIsFinite(factor_inv); while (p != e) *p++ *= factor_inv; @@ -296,7 +296,7 @@ void FullMatrix::forward (Vector &dst, for (j=0; j::backward (Vector &dst, for (j=i+1; j::least_squares (Vector &dst, number2 sum = 0.; for (size_type i=n ; ibackward(dst, *aux); @@ -274,7 +274,7 @@ Householder::least_squares (BlockVector &dst, number2 sum = 0.; for (size_type i=n ; i::operator = (const value_type s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); BaseClass::operator = (s); return *this; diff --git a/include/deal.II/lac/petsc_matrix_base.h b/include/deal.II/lac/petsc_matrix_base.h index 8a22c13cf7..7c0546cc99 100644 --- a/include/deal.II/lac/petsc_matrix_base.h +++ b/include/deal.II/lac/petsc_matrix_base.h @@ -1159,7 +1159,7 @@ namespace PETScWrappers const size_type j, const PetscScalar value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); set (i, 1, &j, &value, false); } @@ -1258,7 +1258,7 @@ namespace PETScWrappers for (size_type j=0; j::do_step ( #ifdef DEBUG for (unsigned int i=0; i::set (const size_type i, const size_type j, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); const size_type index = cols->operator()(i, j); @@ -1730,7 +1730,7 @@ SparseMatrix::add (const size_type i, const size_type j, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); if (value == 0) return; diff --git a/include/deal.II/lac/sparse_matrix.templates.h b/include/deal.II/lac/sparse_matrix.templates.h index aa88acffbe..2e80506e7e 100644 --- a/include/deal.II/lac/sparse_matrix.templates.h +++ b/include/deal.II/lac/sparse_matrix.templates.h @@ -580,7 +580,7 @@ SparseMatrix::add (const size_type row, for (size_type j=0; j::set (const size_type row, for (size_type j=0; j::set (const size_type i, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); Assert (i::add (const size_type i, const number value) { - Assert (numbers::is_finite(value), ExcNumberNotFinite()); + AssertIsFinite(value); Assert (iPutScalar(s); @@ -1564,7 +1564,7 @@ namespace TrilinosWrappers VectorBase & VectorBase::operator *= (const TrilinosScalar a) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); const int ierr = vector->Scale(a); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); @@ -1578,11 +1578,11 @@ namespace TrilinosWrappers VectorBase & VectorBase::operator /= (const TrilinosScalar a) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); const TrilinosScalar factor = 1./a; - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); const int ierr = vector->Scale(factor); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); @@ -1633,7 +1633,7 @@ namespace TrilinosWrappers // if we have ghost values, do not allow // writing to this vector at all. Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); size_type n_local = local_size(); for (size_type i=0; iUpdate(a, *(v.vector), 1.); AssertThrow (ierr == 0, ExcTrilinosError(ierr)); @@ -1676,8 +1676,8 @@ namespace TrilinosWrappers Assert (local_size() == w.local_size(), ExcDimensionMismatch(local_size(), w.local_size())); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); const int ierr = vector->Update(a, *(v.vector), b, *(w.vector), 1.); @@ -1697,7 +1697,7 @@ namespace TrilinosWrappers Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); // We assume that the vectors have the same Map // if the local size is the same and if the vectors are not ghosted @@ -1728,8 +1728,8 @@ namespace TrilinosWrappers Assert (!has_ghost_elements(), ExcGhostsPresent()); Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); // We assume that the vectors have the same Map // if the local size is the same and if the vectors are not ghosted @@ -1766,9 +1766,9 @@ namespace TrilinosWrappers ExcDimensionMismatch (size(), v.size())); Assert (size() == w.size(), ExcDimensionMismatch (size(), w.size())); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); + AssertIsFinite(b); // We assume that the vectors have the same Map // if the local size is the same and if the vectors are not ghosted @@ -1810,10 +1810,10 @@ namespace TrilinosWrappers ExcDimensionMismatch (size(), w.size())); Assert (size() == x.size(), ExcDimensionMismatch (size(), x.size())); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); - Assert (numbers::is_finite(c), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); + AssertIsFinite(b); + AssertIsFinite(c); // We assume that the vectors have the same Map // if the local size is the same and if the vectors are not ghosted @@ -1872,7 +1872,7 @@ namespace TrilinosWrappers // if we have ghost values, do not allow // writing to this vector at all. Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); // If we don't have the same map, copy. if (vector->Map().SameAs(v.vector->Map())==false) @@ -1905,8 +1905,8 @@ namespace TrilinosWrappers Assert (v.local_size() == w.local_size(), ExcDimensionMismatch (v.local_size(), w.local_size())); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); // If we don't have the same map, copy. if (vector->Map().SameAs(v.vector->Map())==false) diff --git a/include/deal.II/lac/vector.h b/include/deal.II/lac/vector.h index f17d186a7e..34bd772289 100644 --- a/include/deal.II/lac/vector.h +++ b/include/deal.II/lac/vector.h @@ -1227,7 +1227,7 @@ inline Vector & Vector::operator /= (const Number factor) { - Assert (numbers::is_finite(factor),ExcNumberNotFinite()); + AssertIsFinite(factor); Assert (factor != Number(0.), ExcZero() ); this->operator *= (Number(1.)/factor); diff --git a/include/deal.II/lac/vector.templates.h b/include/deal.II/lac/vector.templates.h index c753b49d23..a41397cc61 100644 --- a/include/deal.II/lac/vector.templates.h +++ b/include/deal.II/lac/vector.templates.h @@ -729,7 +729,7 @@ template Vector & Vector::operator = (const Number s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); if (s != Number()) Assert (vec_size!=0, ExcEmptyObject()); if (vec_size>internal::Vector::minimum_parallel_grain_size) @@ -751,7 +751,7 @@ template <> Vector > & Vector >::operator = (const std::complex s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); if (s != std::complex()) Assert (vec_size!=0, ExcEmptyObject()); if (vec_size!=0) @@ -766,7 +766,7 @@ Vector >::operator = (const std::complex s) template Vector &Vector::operator *= (const Number factor) { - Assert (numbers::is_finite(factor),ExcNumberNotFinite()); + AssertIsFinite(factor); Assert (vec_size!=0, ExcEmptyObject()); @@ -786,7 +786,7 @@ void Vector::add (const Number a, const Vector &v) { - Assert (numbers::is_finite(a),ExcNumberNotFinite()); + AssertIsFinite(a); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); @@ -806,8 +806,8 @@ Vector::sadd (const Number x, const Number a, const Vector &v) { - Assert (numbers::is_finite(x),ExcNumberNotFinite()); - Assert (numbers::is_finite(a),ExcNumberNotFinite()); + AssertIsFinite(x); + AssertIsFinite(a); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); @@ -1226,7 +1226,7 @@ Number Vector::operator * (const Vector &v) const Number sum; internal::Vector::accumulate (internal::Vector::Dot(), val, v.val, Number(), vec_size, val, sum); - Assert(numbers::is_finite(sum), ExcNumberNotFinite()); + AssertIsFinite(sum); return sum; } @@ -1243,7 +1243,7 @@ Vector::norm_sqr () const internal::Vector::accumulate (internal::Vector::Norm2(), val, val, real_type(), vec_size, val, sum); - Assert(numbers::is_finite(sum), ExcNumberNotFinite()); + AssertIsFinite(sum); return sum; } @@ -1315,7 +1315,7 @@ Vector::l2_norm () const sum += (abs_x/scale) * (abs_x/scale); } } - Assert(numbers::is_finite(scale*std::sqrt(sum)), ExcNumberNotFinite()); + AssertIsFinite(scale*std::sqrt(sum)); return scale * std::sqrt(sum); } } @@ -1393,7 +1393,7 @@ Vector::add_and_dot (const Number a, Number sum; internal::Vector::accumulate (internal::Vector::AddAndDot(), V.val, W.val, a, vec_size, val, sum); - Assert(numbers::is_finite(sum), ExcNumberNotFinite()); + AssertIsFinite(sum); return sum; } @@ -1458,8 +1458,8 @@ template void Vector::add (const Number a, const Vector &v, const Number b, const Vector &w) { - Assert (numbers::is_finite(a),ExcNumberNotFinite()); - Assert (numbers::is_finite(b),ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); @@ -1480,7 +1480,7 @@ template void Vector::sadd (const Number x, const Vector &v) { - Assert (numbers::is_finite(x),ExcNumberNotFinite()); + AssertIsFinite(x); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); @@ -1499,9 +1499,9 @@ void Vector::sadd (const Number x, const Number a, const Vector &v, const Number b, const Vector &w) { - Assert (numbers::is_finite(x),ExcNumberNotFinite()); - Assert (numbers::is_finite(a),ExcNumberNotFinite()); - Assert (numbers::is_finite(b),ExcNumberNotFinite()); + AssertIsFinite(x); + AssertIsFinite(a); + AssertIsFinite(b); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); @@ -1561,7 +1561,7 @@ template void Vector::equ (const Number a, const Vector &u) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); @@ -1580,7 +1580,7 @@ template void Vector::equ (const Number a, const Vector &u) { - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); @@ -1601,8 +1601,8 @@ template void Vector::equ (const Number a, const Vector &u, const Number b, const Vector &v) { - Assert (numbers::is_finite(a),ExcNumberNotFinite()); - Assert (numbers::is_finite(b),ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); diff --git a/include/deal.II/numerics/vector_tools.templates.h b/include/deal.II/numerics/vector_tools.templates.h index 8619b896f3..22f94a1d52 100644 --- a/include/deal.II/numerics/vector_tools.templates.h +++ b/include/deal.II/numerics/vector_tools.templates.h @@ -2292,7 +2292,7 @@ namespace VectorTools if (dof_to_boundary_mapping[i] != DoFHandler::invalid_dof_index && ! excluded_dofs[dof_to_boundary_mapping[i]]) { - Assert(numbers::is_finite(boundary_projection(dof_to_boundary_mapping[i])), ExcNumberNotFinite()); + AssertIsFinite(boundary_projection(dof_to_boundary_mapping[i])); // this dof is on one of the // interesting boundary parts @@ -6294,7 +6294,7 @@ namespace VectorTools } // append result of this cell to the end of the vector - Assert (numbers::is_finite(diff), ExcNumberNotFinite()); + AssertIsFinite(diff); return diff; } diff --git a/source/lac/petsc_vector_base.cc b/source/lac/petsc_vector_base.cc index f9934c815c..b127024d25 100644 --- a/source/lac/petsc_vector_base.cc +++ b/source/lac/petsc_vector_base.cc @@ -213,7 +213,7 @@ namespace PETScWrappers VectorBase & VectorBase::operator = (const PetscScalar s) { - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); //TODO[TH]: assert(is_compressed()) @@ -774,7 +774,7 @@ namespace PETScWrappers VectorBase::operator *= (const PetscScalar a) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); const int ierr = VecScale (vector, a); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -788,10 +788,10 @@ namespace PETScWrappers VectorBase::operator /= (const PetscScalar a) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); const PetscScalar factor = 1./a; - Assert (numbers::is_finite(factor), ExcNumberNotFinite()); + AssertIsFinite(factor); const int ierr = VecScale (vector, factor); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -829,7 +829,7 @@ namespace PETScWrappers VectorBase::add (const PetscScalar s) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); const int ierr = VecShift (vector, s); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -850,7 +850,7 @@ namespace PETScWrappers const VectorBase &v) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); const int ierr = VecAXPY (vector, a, v); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -865,8 +865,8 @@ namespace PETScWrappers const VectorBase &w) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); const PetscScalar weights[2] = {a,b}; Vec addends[2] = {v.vector, w.vector}; @@ -882,7 +882,7 @@ namespace PETScWrappers const VectorBase &v) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); + AssertIsFinite(s); const int ierr = VecAYPX (vector, s, v); AssertThrow (ierr == 0, ExcPETScError(ierr)); @@ -896,8 +896,8 @@ namespace PETScWrappers const VectorBase &v) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); // there is nothing like a AXPAY // operation in Petsc, so do it in two @@ -916,9 +916,9 @@ namespace PETScWrappers const VectorBase &w) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); + AssertIsFinite(b); // there is no operation like MAXPAY, so // do it in two steps @@ -943,10 +943,10 @@ namespace PETScWrappers const VectorBase &x) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(s), ExcNumberNotFinite()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); - Assert (numbers::is_finite(c), ExcNumberNotFinite()); + AssertIsFinite(s); + AssertIsFinite(a); + AssertIsFinite(b); + AssertIsFinite(c); // there is no operation like MAXPAY, so // do it in two steps @@ -977,7 +977,7 @@ namespace PETScWrappers const VectorBase &v) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); + AssertIsFinite(a); Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); @@ -1000,8 +1000,8 @@ namespace PETScWrappers const VectorBase &w) { Assert (!has_ghost_elements(), ExcGhostsPresent()); - Assert (numbers::is_finite(a), ExcNumberNotFinite()); - Assert (numbers::is_finite(b), ExcNumberNotFinite()); + AssertIsFinite(a); + AssertIsFinite(b); Assert (size() == v.size(), ExcDimensionMismatch (size(), v.size())); diff --git a/source/numerics/matrix_tools.cc b/source/numerics/matrix_tools.cc index e90e551af9..4b6e04253d 100644 --- a/source/numerics/matrix_tools.cc +++ b/source/numerics/matrix_tools.cc @@ -1118,13 +1118,12 @@ namespace MatrixCreator if (copy_data.dof_is_on_face[pos][j] && dof_to_boundary_mapping[copy_data.dofs[j]] != numbers::invalid_dof_index) { - Assert(numbers::is_finite(copy_data.cell_matrix[pos](i,j)), - ExcNumberNotFinite()); + AssertIsFinite(copy_data.cell_matrix[pos](i,j)); matrix.add(dof_to_boundary_mapping[copy_data.dofs[i]], dof_to_boundary_mapping[copy_data.dofs[j]], copy_data.cell_matrix[pos](i,j)); } - Assert(numbers::is_finite(copy_data.cell_vector[pos](i)), ExcNumberNotFinite()); + AssertIsFinite(copy_data.cell_vector[pos](i)); rhs_vector(dof_to_boundary_mapping[copy_data.dofs[i]]) += copy_data.cell_vector[pos](i); } }