ENH: add threshold for the number of warnings in MatrixTools::equal()

This commit is contained in:
Kutalmis Bercin
2019-11-13 15:55:12 +00:00
parent 3a5ad7eed7
commit 3afc352757
2 changed files with 12 additions and 1 deletions

View File

@ -35,6 +35,7 @@ bool Foam::MatrixTools::equal
const Matrix<Form1, Type>& A,
const Matrix<Form2, Type>& B,
const bool verbose,
const label lenDiffs,
const scalar relTol,
const scalar absTol
)
@ -54,6 +55,8 @@ bool Foam::MatrixTools::equal
auto iter1 = A.cbegin();
auto iter2 = B.cbegin();
label j = 0;
for (label i = 0; i < len; ++i)
{
if ((absTol + relTol*mag(*iter2)) < Foam::mag(*iter1 - *iter2))
@ -63,8 +66,15 @@ bool Foam::MatrixTools::equal
Info<< "Matrix element " << i
<< " differs beyond tolerance: "
<< *iter1 << " vs " << *iter2 << nl;
++j;
}
if (lenDiffs < j)
{
Info<< "Number of different elements exceeds = " << lenDiffs
<< " Ceasing comparisons for the remaining of elements."
<< nl;
return false;
}
return false;
}
++iter1;

View File

@ -62,6 +62,7 @@ bool equal
const Matrix<Form1, Type>& A,
const Matrix<Form2, Type>& B,
const bool verbose = false,
const label lenDiffs = 10,
const scalar relTol = 1e-5,
const scalar absTol = 1e-8
);