const PetscScalar gamma = alpha * beta;
// Check real access
- Assert (PetscRealPart (gamma)==0., ExcInternalError());
- Assert (PetscImaginaryPart (gamma) ==5., ExcInternalError());
+ AssertThrow (PetscRealPart (gamma)==0., ExcInternalError());
+ AssertThrow (PetscImaginaryPart (gamma) ==5., ExcInternalError());
// This is legal too!
- Assert (gamma==std::complex<double> (0.,5), ExcInternalError());
+ AssertThrow (gamma==std::complex<double> (0.,5), ExcInternalError());
deallog << "OK" << std::endl;
}
const PetscScalar beta = alpha/2.;
// Check real access
- Assert (PetscRealPart (alpha)==1., ExcInternalError());
- Assert (PetscRealPart (beta) ==0.5, ExcInternalError());
+ AssertThrow (PetscRealPart (alpha)==1., ExcInternalError());
+ AssertThrow (PetscRealPart (beta) ==0.5, ExcInternalError());
// operate on alpha (now alpha==beta)
alpha /= 2.;
// Check complex access
- Assert (PetscImaginaryPart (alpha)==1., ExcInternalError());
- Assert (PetscImaginaryPart (beta) ==1., ExcInternalError());
+ AssertThrow (PetscImaginaryPart (alpha)==1., ExcInternalError());
+ AssertThrow (PetscImaginaryPart (beta) ==1., ExcInternalError());
// This is legal too!
- Assert (alpha==beta, ExcInternalError());
+ AssertThrow (alpha==beta, ExcInternalError());
deallog << "OK" << std::endl;
}
const std::complex<double> beta = alpha;
// These should be the same of course
- Assert (alpha==beta, ExcInternalError());
+ AssertThrow (alpha==beta, ExcInternalError());
deallog << "OK" << std::endl;
}
const PetscScalar alpha = beta;
// These should be the same of course
- Assert (alpha==beta, ExcInternalError());
+ AssertThrow (alpha==beta, ExcInternalError());
deallog << "OK" << std::endl;
}
const PetscScalar alpha = 1.0 + 2.0*PETSC_i;
// Test if PetscScalar is an std::complex.
- Assert (alpha==std::complex<double> (1.,2.), ExcInternalError());
+ AssertThrow (alpha==std::complex<double> (1.,2.), ExcInternalError());
deallog << "OK" << std::endl;
}
// Initialise (no argument) to zero.
const PetscScalar alpha;
- Assert (alpha==std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (alpha==std::complex<double> (0.,0.), ExcInternalError());
// Initialise (real argument) to zero.
const PetscScalar beta = 0.;
- Assert (beta==alpha, ExcInternalError());
+ AssertThrow (beta==alpha, ExcInternalError());
// Initialise (real+complex argument) to zero.
const PetscScalar gamma = 0. + 0.*PETSC_i;
- Assert (gamma==beta, ExcInternalError());
+ AssertThrow (gamma==beta, ExcInternalError());
// If alpha==beta==gamma, then:
- Assert (alpha==gamma, ExcInternalError());
+ AssertThrow (alpha==gamma, ExcInternalError());
deallog << "OK" << std::endl;
}
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
{
- Assert (m(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
}
else
{
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
deallog << "OK" << std::endl;
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
{
- Assert (m(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,i*j*.5+.5), ExcInternalError());
}
else
{
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
deallog << "OK" << std::endl;
void test (PETScWrappers::SparseMatrix &m)
{
- Assert (m.m() == 5, ExcInternalError());
- Assert (m.n() == 5, ExcInternalError());
+ AssertThrow (m.m() == 5, ExcInternalError());
+ AssertThrow (m.n() == 5, ExcInternalError());
deallog << "OK" << std::endl;
}
m.compress (VectorOperation::insert);
deallog << m.n_nonzero_elements() << std::endl;
- Assert (m.n_nonzero_elements() == counter,
- ExcInternalError());
+ AssertThrow (m.n_nonzero_elements() == counter,
+ ExcInternalError());
deallog << "OK" << std::endl;
}
// compare against the exact value of the l1-norm (max col-sum)
deallog << m.l1_norm() << std::endl;
- Assert (m.l1_norm() == 7, ExcInternalError());
+ AssertThrow (m.l1_norm() == 7, ExcInternalError());
deallog << "OK" << std::endl;
}
// compare against the exact value of the linfty-norm (max row-sum).
deallog << m.linfty_norm() << std::endl;
- Assert (m.linfty_norm() == 8.5, ExcInternalError());
+ AssertThrow (m.linfty_norm() == 8.5, ExcInternalError());
deallog << "OK" << std::endl;
}
// compare against the exact value of the l2-norm (max row-sum)
deallog << m.frobenius_norm() << std::endl;
- Assert (m.frobenius_norm() == norm, ExcInternalError());
+ AssertThrow (m.frobenius_norm() == norm, ExcInternalError());
deallog << "OK" << std::endl;
}
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
{
- Assert (m(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError());
}
else
{
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
deallog << "OK" << std::endl;
for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
{
- Assert (m(i,j) == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,(i*j*.5+.5)/4*3), ExcInternalError());
}
else
{
- Assert (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
- Assert (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m(i,j) == std::complex<double> (0.,0.), ExcInternalError());
+ AssertThrow (m.el(i,j) == std::complex<double> (0.,0.), ExcInternalError());
}
deallog << "OK" << std::endl;
v.compress (VectorOperation::insert);
- Assert (v.size() == 100, ExcInternalError());
+ AssertThrow (v.size() == 100, ExcInternalError());
deallog << "OK" << std::endl;
}
for (unsigned int k=0; k<v.size(); ++k)
{
const PetscScalar el = v(k);
- Assert ( ( (pattern[k] == true) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == k) )
- ||
- ( (pattern[k] == false) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == 0.)),
- ExcInternalError());
+ AssertThrow ( ( (pattern[k] == true) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == k) )
+ ||
+ ( (pattern[k] == false) && (PetscRealPart(el) == 0.) && (PetscImaginaryPart(el) == 0.)),
+ ExcInternalError());
}
deallog << "OK" << std::endl;
// check that they are ok, and this time all of them
for (unsigned int i=0; i<v.size(); ++i)
- Assert ( ( (pattern[i]==true) && (v(i).real()==i) && (v(i).imag()==i) ) ||
- //&& (v(i)==std::complex<double> (1.,1.)) ) ||
- ( (pattern[i]==false) && (v(i).real()==0.) && (v(i).imag()==0.) ),
- ExcInternalError());
+ AssertThrow ( ( (pattern[i]==true) && (v(i).real()==i) && (v(i).imag()==i) ) ||
+ //&& (v(i)==std::complex<double> (1.,1.)) ) ||
+ ( (pattern[i]==false) && (v(i).real()==0.) && (v(i).imag()==0.) ),
+ ExcInternalError());
deallog << "OK" << std::endl;
}
v.compress (VectorOperation::insert);
// then check the norm
- Assert (v.l1_norm() == norm, ExcInternalError());
+ AssertThrow (v.l1_norm() == norm, ExcInternalError());
deallog << "OK" << std::endl;
}
// then check the l2-norm
PetscReal l2_norm = v.l2_norm();
- Assert (l2_norm==std::sqrt(norm), ExcInternalError());
+ AssertThrow (l2_norm==std::sqrt(norm), ExcInternalError());
deallog << "OK" << std::endl;
}
v.compress (VectorOperation::insert);
// then check the norm
- Assert (v.linfty_norm() == norm, ExcInternalError());
+ AssertThrow (v.linfty_norm() == norm, ExcInternalError());
deallog << "OK" << std::endl;
}
w.compress (VectorOperation::insert);
// make sure the scalar product is zero
- Assert (v*w == product, ExcInternalError());
+ AssertThrow (v*w == product, ExcInternalError());
deallog << "OK" << std::endl;
}
// check that is what we get by casting PetscScalar to std::real()
// and std::imag()
for (unsigned int k=0; k<v.size(); ++k)
- Assert ((static_cast<std::complex<double> > (v(k)).real ()==k) &&
- (static_cast<std::complex<double> > (v(k)).imag ()==v.size()-k),
- ExcInternalError());
+ AssertThrow ((static_cast<std::complex<double> > (v(k)).real ()==k) &&
+ (static_cast<std::complex<double> > (v(k)).imag ()==v.size()-k),
+ ExcInternalError());
// check that is what we get by
// dealii::internal::VectorReference::real() and
// dealii::internal::VectorReference::imag()
for (unsigned int k=0; k<v.size(); ++k)
- Assert ((v(k).real ()==k) && (v(k).imag ()==v.size()-k),
- ExcInternalError());
+ AssertThrow ((v(k).real ()==k) && (v(k).imag ()==v.size()-k),
+ ExcInternalError());
deallog << "OK" << std::endl;
}
PetscReal el_r = static_cast<double> (k+l);
PetscReal el_i = static_cast<double> (-1.*(k+l));
- Assert ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i),
- ExcInternalError());
+ AssertThrow ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i),
+ ExcInternalError());
}
deallog << "OK" << std::endl;
// check the matrix is correctly filled
for (unsigned int k=0; k<m.m(); ++k)
for (unsigned int l=0; l<m.n(); ++l)
- Assert (m(k,l).real () == -1.*(m(k,l).imag ()),
- ExcInternalError());
+ AssertThrow (m(k,l).real () == -1.*(m(k,l).imag ()),
+ ExcInternalError());
deallog << "OK" << std::endl;
}
// Check elements have the correct value
for (unsigned int k=0; k<m.m(); ++k)
for (unsigned int l=0; l<m.n(); ++l)
- Assert ((m(k,l).real () == (k+l)*dealii::numbers::PI) &&
- (m(k,l).imag () == -1.*(k+l)*dealii::numbers::PI),
- ExcInternalError());
+ AssertThrow ((m(k,l).real () == (k+l)*dealii::numbers::PI) &&
+ (m(k,l).imag () == -1.*(k+l)*dealii::numbers::PI),
+ ExcInternalError());
// Use the conjugate to check elements have equal (and opposite)
// values.
{
PetscScalar m_conjugate = PetscConj (m(k,l));
- Assert (m_conjugate.real () == m_conjugate.imag (),
- ExcInternalError());
+ AssertThrow (m_conjugate.real () == m_conjugate.imag (),
+ ExcInternalError());
}
deallog << "OK" << std::endl;
for (unsigned int q=0; q<n_q_points; ++q)
{
- Assert ( PetscRealPart(values[q]) == values_Re[q], ExcInternalError() );
- Assert ( PetscImaginaryPart(values[q]) == values_Im[q], ExcInternalError() );
+ AssertThrow ( PetscRealPart(values[q]) == values_Re[q], ExcInternalError() );
+ AssertThrow ( PetscImaginaryPart(values[q]) == values_Im[q], ExcInternalError() );
}
}
}
w(k) = v(k);
// check that they're equal
- Assert (v==w, ExcInternalError());
+ AssertThrow (v==w, ExcInternalError());
deallog << "OK" << std::endl;
}
w(k) += v(k);
// check that they're equal
- Assert (v==w, ExcInternalError());
+ AssertThrow (v==w, ExcInternalError());
deallog << "OK" << std::endl;
}
w(k) = std::complex<double> (k+1.,k+1.);
}
- Assert (!(v==w), ExcInternalError());
+ AssertThrow (!(v==w), ExcInternalError());
deallog << "OK" << std::endl;
}
// then copy elements and make sure the vectors are actually equal
v = w;
- Assert (v==w, ExcInternalError());
+ AssertThrow (v==w, ExcInternalError());
deallog << "OK" << std::endl;
}
w(k) = v(k);
// check that they're equal
- Assert (v==w, ExcInternalError());
+ AssertThrow (v==w, ExcInternalError());
v=w;
// check that they're still equal
- Assert (v==w, ExcInternalError());
+ AssertThrow (v==w, ExcInternalError());
deallog << "OK" << std::endl;
}