Skip to content

Commit

Permalink
Propagate bug fixes to other variant of Averaging::addSampleInternal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
trevilo committed May 3, 2024
1 parent b327f69 commit b57eac9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/averaging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit b57eac9

Please sign in to comment.