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.
* 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<double>,
+ << "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.
#define AssertGlobalIndexRange(index,range) Assert((index) < (range), \
ExcIndexRange<types::global_dof_index>((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<double>(number)))
+
using namespace StandardExceptions;
DEAL_II_NAMESPACE_CLOSE
{
prepare_set_operation();
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
const std::pair<unsigned int,size_type>
row_index = row_block_indices.global_to_local (i),
const value_type value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
prepare_add_operation();
BlockMatrixBase<MatrixType>::add (const value_type factor,
const BlockMatrixBase<MatrixType> &matrix)
{
- Assert (numbers::is_finite(factor), ExcNumberNotFinite());
+ AssertIsFinite(factor);
prepare_add_operation();
const Number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
const std::pair<size_type,size_type>
row_index = row_indices.global_to_local (i),
const Number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
const std::pair<unsigned int,size_type>
row_index = row_indices.global_to_local (i),
BlockVector<Number>::operator = (const value_type s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
BaseClass::operator = (s);
return *this;
template <class VectorType>
void BlockVectorBase<VectorType>::add (const value_type a)
{
- Assert (numbers::is_finite(a), ExcNumberNotFinite());
+ AssertIsFinite(a);
for (size_type i=0; i<n_blocks(); ++i)
{
const BlockVectorBase<VectorType> &v)
{
- Assert (numbers::is_finite(a), ExcNumberNotFinite());
+ AssertIsFinite(a);
Assert (n_blocks() == v.n_blocks(),
ExcDimensionMismatch(n_blocks(), v.n_blocks()));
const BlockVectorBase<VectorType> &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()));
const BlockVectorBase<VectorType> &v)
{
- Assert (numbers::is_finite(x), ExcNumberNotFinite());
+ AssertIsFinite(x);
Assert (n_blocks() == v.n_blocks(),
ExcDimensionMismatch(n_blocks(), v.n_blocks()));
const BlockVectorBase<VectorType> &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()));
const BlockVectorBase<VectorType> &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()));
const BlockVectorBase<VectorType> &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()));
const BlockVectorBase<VectorType> &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()));
const BlockVector2 &v)
{
- Assert (numbers::is_finite(a), ExcNumberNotFinite());
+ AssertIsFinite(a);
Assert (n_blocks() == v.n_blocks(),
ExcDimensionMismatch(n_blocks(), v.n_blocks()));
BlockVectorBase<VectorType>::operator = (const value_type s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
for (size_type i=0; i<n_blocks(); ++i)
components[i] = s;
BlockVectorBase<VectorType>::operator *= (const value_type factor)
{
- Assert (numbers::is_finite(factor), ExcNumberNotFinite());
+ AssertIsFinite(factor);
for (size_type i=0; i<n_blocks(); ++i)
components[i] *= factor;
BlockVectorBase<VectorType>::operator /= (const value_type factor)
{
- Assert (numbers::is_finite(factor), ExcNumberNotFinite());
+ AssertIsFinite(factor);
Assert (factor > 0., ExcDivideByZero() );
for (size_type i=0; i<n_blocks(); ++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
const number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
Assert (cols != 0, ExcNotInitialized());
new_value += (static_cast<typename VectorType::value_type>
(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;
}
new_value += (static_cast<typename VectorType::value_type>
(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;
}
}
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;
}
// entries themselves
for (i=constraints.begin(); i!=e; ++i)
{
- Assert(numbers::is_finite(i->second), ExcNumberNotFinite());
+ AssertIsFinite(i->second);
v(i->first) = i->second;
}
}
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);
}
}
number
FullMatrix<number>::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);
}
FullMatrix<number>::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();
FullMatrix<number>::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;
for (j=0; j<i; ++j)
s -= number(dst(j)) * (*this)(i,j);
dst(i) = s/(*this)(i,i);
- Assert(numbers::is_finite(dst(i)), ExcNumberNotFinite());
+ AssertIsFinite(dst(i));
}
}
for (j=i+1; j<nu; ++j)
s -= dst(j) * number2((*this)(i,j));
dst(i) = s/number2((*this)(i,i));
- Assert(numbers::is_finite(dst(i)), ExcNumberNotFinite());
+ AssertIsFinite(dst(i));
}
}
number2 sum = 0.;
for (size_type i=n ; i<m ; ++i)
sum += (*aux)(i) * (*aux)(i);
- Assert(numbers::is_finite(sum), ExcNumberNotFinite());
+ AssertIsFinite(sum);
// Compute solution
this->backward(dst, *aux);
number2 sum = 0.;
for (size_type i=n ; i<m ; ++i)
sum += (*aux)(i) * (*aux)(i);
- Assert(numbers::is_finite(sum), ExcNumberNotFinite());
+ AssertIsFinite(sum);
//backward works for
//Vectors only, so copy
BlockVector<Number>::operator = (const value_type s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
BaseClass::operator = (s);
return *this;
const size_type j,
const PetscScalar value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
set (i, 1, &j, &value, false);
}
for (size_type j=0; j<n_cols; ++j)
{
const PetscScalar value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value != PetscScalar())
{
column_indices[n_columns] = col_indices[j];
const PetscScalar value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value == PetscScalar())
{
for (size_type j=0; j<n_cols; ++j)
{
const PetscScalar value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value != PetscScalar())
{
column_indices[n_columns] = col_indices[j];
#ifdef DEBUG
for (unsigned int i=0; i<x_cell.size(); ++i)
{
- Assert(numbers::is_finite(x_cell(i)), ExcNumberNotFinite());
+ AssertIsFinite(x_cell(i));
}
#endif
// Store in result vector
const size_type j,
const number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
const size_type index = cols->operator()(i, j);
const size_type j,
const number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value == 0)
return;
for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
#ifdef DEBUG
if (elide_zero_values==true && value == 0)
for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value == 0)
continue;
for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (index != next_row_index && my_cols[index] == col_indices[j])
goto set_value_checked;
const number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
Assert (i<m(), ExcIndexRange(i,0,m()));
Assert (j<n(), ExcIndexRange(j,0,n()));
const number value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
Assert (i<m(), ExcIndexRange(i,0,m()));
Assert (j<n(), ExcIndexRange(j,0,n()));
const TrilinosScalar value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
set (i, 1, &j, &value, false);
}
for (size_type j=0; j<n_cols; ++j)
{
const double value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value != 0)
{
col_index_ptr[n_columns] = col_indices[j];
const size_type j,
const TrilinosScalar value)
{
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value == 0)
{
n_columns = n_cols;
#ifdef DEBUG
for (size_type j=0; j<n_cols; ++j)
- Assert (numbers::is_finite(values[j]), ExcNumberNotFinite());
+ AssertIsFinite(values[j]);
#endif
}
else
{
const double value = values[j];
- Assert (numbers::is_finite(value), ExcNumberNotFinite());
+ AssertIsFinite(value);
if (value != 0)
{
col_index_ptr[n_columns] = col_indices[j];
VectorBase &
VectorBase::operator = (const TrilinosScalar s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
const int ierr = vector->PutScalar(s);
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));
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));
// 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; i<n_local; i++)
Assert (local_size() == v.local_size(),
ExcDimensionMismatch(local_size(), v.local_size()));
- Assert (numbers::is_finite(a), ExcNumberNotFinite());
+ AssertIsFinite(a);
const int ierr = vector->Update(a, *(v.vector), 1.);
AssertThrow (ierr == 0, ExcTrilinosError(ierr));
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.);
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
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
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
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
// 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)
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)
Vector<Number> &
Vector<Number>::operator /= (const Number factor)
{
- Assert (numbers::is_finite(factor),ExcNumberNotFinite());
+ AssertIsFinite(factor);
Assert (factor != Number(0.), ExcZero() );
this->operator *= (Number(1.)/factor);
Vector<Number> &
Vector<Number>::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)
Vector<std::complex<float> > &
Vector<std::complex<float> >::operator = (const std::complex<float> s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
if (s != std::complex<float>())
Assert (vec_size!=0, ExcEmptyObject());
if (vec_size!=0)
template <typename Number>
Vector<Number> &Vector<Number>::operator *= (const Number factor)
{
- Assert (numbers::is_finite(factor),ExcNumberNotFinite());
+ AssertIsFinite(factor);
Assert (vec_size!=0, ExcEmptyObject());
Vector<Number>::add (const Number a,
const Vector<Number> &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));
const Number a,
const Vector<Number> &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));
Number sum;
internal::Vector::accumulate (internal::Vector::Dot<Number,Number2>(),
val, v.val, Number(), vec_size, val, sum);
- Assert(numbers::is_finite(sum), ExcNumberNotFinite());
+ AssertIsFinite(sum);
return sum;
}
internal::Vector::accumulate (internal::Vector::Norm2<Number,real_type>(),
val, val, real_type(), vec_size, val, sum);
- Assert(numbers::is_finite(sum), ExcNumberNotFinite());
+ AssertIsFinite(sum);
return sum;
}
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);
}
}
Number sum;
internal::Vector::accumulate (internal::Vector::AddAndDot<Number>(),
V.val, W.val, a, vec_size, val, sum);
- Assert(numbers::is_finite(sum), ExcNumberNotFinite());
+ AssertIsFinite(sum);
return sum;
}
void Vector<Number>::add (const Number a, const Vector<Number> &v,
const Number b, const Vector<Number> &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));
void Vector<Number>::sadd (const Number x,
const Vector<Number> &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));
const Vector<Number> &v, const Number b,
const Vector<Number> &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));
void Vector<Number>::equ (const Number a,
const Vector<Number> &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));
void Vector<Number>::equ (const Number a,
const Vector<Number2> &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));
void Vector<Number>::equ (const Number a, const Vector<Number> &u,
const Number b, const Vector<Number> &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));
if (dof_to_boundary_mapping[i] != DoFHandler<dim,spacedim>::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
}
// append result of this cell to the end of the vector
- Assert (numbers::is_finite(diff), ExcNumberNotFinite());
+ AssertIsFinite(diff);
return diff;
}
VectorBase &
VectorBase::operator = (const PetscScalar s)
{
- Assert (numbers::is_finite(s), ExcNumberNotFinite());
+ AssertIsFinite(s);
//TODO[TH]: assert(is_compressed())
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));
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));
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));
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));
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};
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));
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
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
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
const VectorBase &v)
{
Assert (!has_ghost_elements(), ExcGhostsPresent());
- Assert (numbers::is_finite(a), ExcNumberNotFinite());
+ AssertIsFinite(a);
Assert (size() == v.size(),
ExcDimensionMismatch (size(), v.size()));
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()));
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);
}
}