From a784a4fe8241491c56fc141690be4543552cc109 Mon Sep 17 00:00:00 2001 From: rois1995 Date: Wed, 25 Sep 2024 19:46:16 +0200 Subject: [PATCH] - Gradient correction fix --- .../gradients/correctGradientsSymmetry.hpp | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/include/gradients/correctGradientsSymmetry.hpp b/SU2_CFD/include/gradients/correctGradientsSymmetry.hpp index a17ce827184..0b15437ea48 100644 --- a/SU2_CFD/include/gradients/correctGradientsSymmetry.hpp +++ b/SU2_CFD/include/gradients/correctGradientsSymmetry.hpp @@ -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]; + // } + // } + + // 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]); 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]; } } }