mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add threshold for the number of warnings in MatrixTools::equal()
This commit is contained in:
@ -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;
|
||||
|
||||
@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user