Skip to content

Conversation

@pcarruscag
Copy link
Member

Proposed Changes

This is mainly to address #721 but it may have good side effects in other areas (see comments below).
Every turbulent testcase will fail and so far I only tested SA and SST on a simple airfoil case.

Related Work

Addresses #721
Should help a bit with #594
May help with #711

PR Checklist

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags).
  • My contribution is commented and consistent with SU2 style.
  • I have added a test case that demonstrates my contribution, if necessary.

a0 = 0.5*(q_ij+fabs(q_ij));
a1 = 0.5*(q_ij-fabs(q_ij));
a0 = max(0.0, MassFlux);
a1 = min(0.0, MassFlux);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it is possible to set a0 = -a1 on the assumption that at convergence the summation of fluxes is 0, with that diagonal dominance is guaranteed (at least for the convective part) which improves the condition number of the assembled Jacobian matrix.

AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j, nVar);
if (grid_movement) {
AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By not computing the mass flux again we greatly reduce the number of input variables for preaccumulation.


val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0];
su2double OneOnAveRho = 2.0/(V_i[nDim+2]+V_j[nDim+2]);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SA is funny and so density is still needed here...

val_Jacobian_i[1][0] = 0.0;
val_Jacobian_i[1][1] = -2.0*beta_blended*TurbVar_i[1]*Volume;
val_Jacobian_i[1][1] = -2.0*beta_blended*Density_i*TurbVar_i[1]*Volume;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Damn, I've been staring at these lines of code for a while and I never realized that Density was missing from the Jacobian computation. Good catch!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not missing, before the Jacobians were w.r.t. rhok and rhow, that is why in the diffusion part they had to be divided by density, I changed it to k and w (only for the SST model) since the mass flux already contains rho. I am not 100% sure this is correct though... In fact CTurbSolver updates the solution via node[iPoint]->AddConservativeSolution. So a better catch by you actually!

@jayantmukho
Copy link
Contributor

I can run this on some OneraM6 meshes to confirm that it works in 3D as well.

@pcarruscag
Copy link
Member Author

Thanks @jayantmukho that would be great. If the meshes you have show grid convergence the results should converge to the same values, both ways of computing the fluxes are second order, but hopefully by using consistent fluxes the error constant is smaller.

CConfig *config) {

val_residual[0] = a0*Density_i*TurbVar_i[0]+a1*Density_j*TurbVar_j[0];
val_residual[1] = a0*Density_i*TurbVar_i[1]+a1*Density_j*TurbVar_j[1];
Copy link
Contributor

@clarkpede clarkpede Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your rationale behind making these density changes?

I understand the problems with reconstruction and why the value of density is questionable. But it seems to me like removing density is incorrect. There's two reasons I think that:

  1. The SST variables are updated by the CVariable::AddConservativeSolution call. In that functions, the delta in the variables is assumed to be weighted by density, e.g. rho*k. Based on that you can conclude that the equations are equations for the density-weighted variables, and the residuals should also be density weighted.
  2. In the source term for the SST variables, (CSourcePieceWise_TurbSST) there are terms like (2/3*rho*k*diverg*Volume). These residuals are density weighted. To be consistent, all the residuals should be density weighted.

For a converged, steady state solution, I think these changes will only change the conditioning. Similarly, I expect no impact for a low-Mach test case. Have you tested these changes on a case like the RAE 2822?

Edit: I just saw the comments you made while I was typing out my review. The mass flux used here (in the convection terms) explains the first question. I still question the density changes in the source terms though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I've been looking at the code a bit more to get an answer).
The rationale was: I did not want to divide the mass flux by an average density which would then break that "summation = 0" property we can use to improve conditioning a bit. Following that logic I linearized the other terms w.r.t. k and w instead of rho k and rho w, I did not change the source residual only its Jacobian. But I forgot to see how the solution was being updated so yeah in the end it is wrong.
Seeing how SA models need a volumetric flux anyway I will probably revert those changes to SST.

* \brief Adds any extra variables to AD
*/
void ExtraADPreaccIn();
inline void ExtraADPreaccIn() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "inline" here is redundant. Functions defined inside a class definition are automatically "inline."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In common practice yes but apparently that is not part of the standard (which I have not read) and so some compilers might complain about multiple definition.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok. So no harm done in leaving it in.

@pcarruscag
Copy link
Member Author

@clarkpede you are right this seems to make no difference to drag and lift regardless of Mach number and coarseness of the grid. But, it is absolutely terrible for convergence in the asymptotic region and therefore to the discrete adjoint, and so it's a garbage idea even if it saves a bit of memory/computation.
I'll post my results in #721 but in the meantime let no one else waste time with this, I owe you and @jayantmukho a beer after this...

@pcarruscag pcarruscag closed this Jul 9, 2019
@clarkpede
Copy link
Contributor

clarkpede commented Jul 10, 2019

@clarkpede you are right this seems to make no difference to drag and lift regardless of Mach number and coarseness of the grid. But, it is absolutely terrible for convergence in the asymptotic region and therefore to the discrete adjoint, and so it's a garbage idea even if it saves a bit of memory/computation.
I'll post my results in #721 but in the meantime let no one else waste time with this, I owe you and @jayantmukho a beer after this...

I wouldn't say it's a garbage idea. You correctly identified a shortcoming in the code (inconsistent mass fluxes). That is a problem that should be fixed, and you came closer than anyone else has to fixing it. But it turns out it's a trickier problem than you or I expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants