Skip to content

Commit

Permalink
- Gradient correction fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rois1995 committed Sep 25, 2024
1 parent 317f563 commit a784a4f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions SU2_CFD/include/gradients/correctGradientsSymmetry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,25 @@ inline void correctGradient(const size_t varBegin, const size_t varEnd, const in
}
}

/*--- Normal gradient of the normal velocity. ---*/
const su2double normalGradNormalVel = GeometryToolbox::DotProduct(nDim, n, gradNormalVel);
// /*--- Normal gradient of the normal velocity. ---*/
// const su2double normalGradNormalVel = GeometryToolbox::DotProduct(nDim, n, gradNormalVel);

/*--- Remove the tangential projection (I - n.n^T) of the normal gradients.
* And the normal projection (n.n^T) of the tangential gradients.
* dV = dV - (I - n.n^T) dV n.n^T - n.n^T dV (I - n.n^T) ---*/
// /*--- Remove the tangential projection (I - n.n^T) of the normal gradients.
// * And the normal projection (n.n^T) of the tangential gradients.
// * dV = dV - (I - n.n^T) dV n.n^T - n.n^T dV (I - n.n^T) ---*/

// for (size_t iDim = 0; iDim < nDim; iDim++) {
// for (size_t jDim = 0; jDim < nDim; jDim++) {
// gradients[idxVel + iDim][jDim] -= normalGrad[iDim] * n[jDim] + n[iDim] * gradNormalVel[jDim];
// gradients[idxVel + iDim][jDim] += 2 * n[iDim] * normalGradNormalVel * n[jDim];
// }
// }

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

// Do I really need all of the previous code? Can't I just merge the two for loops? Maybe I am missing the tangential direction
for (size_t iDim = 0; iDim < nDim; iDim++) {
const su2double normalGrad = GeometryToolbox::DotProduct(nDim, n, gradients[idxVel + iDim]);

Check notice

Code scanning / CodeQL

Declaration hides variable Note

Variable normalGrad hides another variable of the same name (on
line 54
).
for (size_t jDim = 0; jDim < nDim; jDim++) {
gradients[idxVel + iDim][jDim] -= normalGrad[iDim] * n[jDim] + n[iDim] * gradNormalVel[jDim];
gradients[idxVel + iDim][jDim] += 2 * n[iDim] * normalGradNormalVel * n[jDim];
gradients[idxVel + iDim][jDim] -= normalGrad * n[jDim];
}
}
}
Expand Down

0 comments on commit a784a4f

Please sign in to comment.