From b57eac931e6ad13d326dcc69f3883334122acbdb Mon Sep 17 00:00:00 2001 From: "Todd A. Oliver" Date: Fri, 3 May 2024 15:16:22 -0500 Subject: [PATCH] Propagate bug fixes to other variant of Averaging::addSampleInternal Bugs in the variance handling (calculation indexing and protecting when it is null) were discovered and fixed during the extension of the Averaging class into the LoMachSolver. But, these were present in the variant used on the compressible path also, so we fix them too. --- src/averaging.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/averaging.cpp b/src/averaging.cpp index 68ec92f95..eb2d6e0f5 100644 --- a/src/averaging.cpp +++ b/src/averaging.cpp @@ -347,7 +347,10 @@ void Averaging::addSampleInternal(GasMixture *mixture) { const double *d_inst = inst->Read(); double *d_mean = mean->ReadWrite(); - double *d_vari = vari->ReadWrite(); + double *d_vari = nullptr; + if (vari != nullptr) { + d_vari = vari->ReadWrite(); + } // Get mixture class pointer for use on device // @@ -418,7 +421,7 @@ void Averaging::addSampleInternal(GasMixture *mixture) { // Covariances second (i.e., off-diagonal components, if any) for (int i = d_vari_start; i < d_vari_start + d_vari_components - 1; i++) { - for (int j = d_vari_start + 1; j < d_vari_start + d_vari_components; j++) { + for (int j = i + 1; j < d_vari_start + d_vari_components; j++) { val = d_vari[n + vari_index * dof]; delta_i = (nUp[i] - mean_state[i]); delta_j = (nUp[j] - mean_state[j]);