Skip to content

Commit 996dae5

Browse files
committed
Fix NumericVector::compare
The parallel failures from idaholab/moose#23788 are: ``` libMesh terminating: No index 5 in ghosted vector. Vector contains [5,5) And ghost array {4,0} ``` because prior to this commit if the first local index was equal to the last local index we would go ahead and attempt to index into the vector with first local index anyway. Now we avoid that scenario
1 parent 8049421 commit 996dae5

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

src/numerics/numeric_vector.C

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,14 @@ int NumericVector<T>::compare (const NumericVector<T> & other_vector,
114114
int first_different_i = std::numeric_limits<int>::max();
115115
numeric_index_type i = first_local_index();
116116

117-
do
118-
{
119-
if (std::abs((*this)(i) - other_vector(i)) > threshold)
120-
first_different_i = i;
121-
else
122-
i++;
123-
}
124117
while (first_different_i==std::numeric_limits<int>::max()
125-
&& i<last_local_index());
118+
&& i<last_local_index())
119+
{
120+
if (std::abs((*this)(i) - other_vector(i)) > threshold)
121+
first_different_i = i;
122+
else
123+
i++;
124+
}
126125

127126
// Find the correct first differing index in parallel
128127
this->comm().min(first_different_i);

0 commit comments

Comments
 (0)