Commit 18822ec4 authored by GILLES Sebastien's avatar GILLES Sebastien

#1451 Extend AreEqual(PetscVector) so that ghost values are also checked.

parent 6138319e
......@@ -102,8 +102,6 @@ namespace MoReFEM
}
Vector::~Vector()
{
if (do_petsc_destroy_)
......@@ -447,33 +445,40 @@ namespace MoReFEM
{
inequality_description.clear();
PetscInt size = vec1.GetProcessorWiseSize(invoking_file, invoking_line);
{
#ifndef NDEBUG
PetscInt size2 = vec2.GetProcessorWiseSize(invoking_file, invoking_line);
assert(size == size2);
#endif // NDEBUG
}
AccessVectorContent<Utilities::Access::read_only> local_array_1(vec1, invoking_file, invoking_line);
AccessVectorContent<Utilities::Access::read_only> local_array_2(vec2, invoking_file, invoking_line);
PetscInt Nprocessor_wise = vec1.GetProcessorWiseSize(invoking_file, invoking_line);
assert(Nprocessor_wise == vec2.GetProcessorWiseSize(invoking_file, invoking_line));
assert(static_cast<PetscInt>(local_array_1.GetSize(__FILE__, __LINE__)) == size);
assert(static_cast<PetscInt>(local_array_2.GetSize(__FILE__, __LINE__)) == size);
AccessGhostContent with_ghost1(vec1, invoking_file, invoking_line);
AccessGhostContent with_ghost2(vec2, invoking_file, invoking_line);
AccessVectorContent<Utilities::Access::read_only> local_array_1(with_ghost1.GetVectorWithGhost(),
invoking_file, invoking_line);
AccessVectorContent<Utilities::Access::read_only> local_array_2(with_ghost2.GetVectorWithGhost(),
invoking_file, invoking_line);
const auto Nprocessor_wise_plus_ghost = static_cast<PetscInt>(local_array_1.GetSize(__FILE__, __LINE__));
assert(Nprocessor_wise_plus_ghost == static_cast<PetscInt>(local_array_2.GetSize(__FILE__, __LINE__)));
const PetscScalar* values1 = local_array_1.GetArray();
const PetscScalar* values2 = local_array_2.GetArray();
bool ret = true;
for (PetscInt index = 0; index < size && ret;)
for (PetscInt index = 0; index < Nprocessor_wise_plus_ghost && ret;)
{
{
if (std::fabs(values1[index] - values2[index]) > epsilon)
{
std::ostringstream oconv;
oconv << "Inequality found for index " << index << ": vector 1 displays " << values1[index] << " while "
"vector2 displays " << values2[index] << std::endl;
oconv << "Inequality found for index " << index << ": vector 1 displays " << values1[index]
<< " while vector2 displays " << values2[index] << '.';
if (index >= Nprocessor_wise)
oconv << " This index refers to a ghost value (Nprocessor_wise = " << Nprocessor_wise
<< ").";
oconv << std::endl;
inequality_description = oconv.str();
ret = false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment