-
Notifications
You must be signed in to change notification settings - Fork 919
Consistent mass fluxes between bulk flow and turbulence solvers #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,39 +65,17 @@ void CUpwScalar::ComputeResidual(su2double *val_residual, | |
| CConfig *config) { | ||
|
|
||
| AD::StartPreacc(); | ||
| AD::SetPreaccIn(Normal, nDim); | ||
| AD::SetPreaccIn(TurbVar_i, nVar); AD::SetPreaccIn(TurbVar_j, nVar); | ||
| if (grid_movement) { | ||
| AD::SetPreaccIn(GridVel_i, nDim); AD::SetPreaccIn(GridVel_j, nDim); | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| AD::SetPreaccIn(TurbVar_i, nVar); | ||
| AD::SetPreaccIn(TurbVar_j, nVar); | ||
| AD::SetPreaccIn(MassFlux); | ||
|
|
||
| ExtraADPreaccIn(); | ||
|
|
||
| Density_i = V_i[nDim+2]; | ||
| Density_j = V_j[nDim+2]; | ||
|
|
||
| q_ij = 0.0; | ||
| if (grid_movement) { | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| Velocity_i[iDim] = V_i[iDim+1] - GridVel_i[iDim]; | ||
| Velocity_j[iDim] = V_j[iDim+1] - GridVel_j[iDim]; | ||
| q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; | ||
| } | ||
| } | ||
| else { | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| Velocity_i[iDim] = V_i[iDim+1]; | ||
| Velocity_j[iDim] = V_j[iDim+1]; | ||
| q_ij += 0.5*(Velocity_i[iDim]+Velocity_j[iDim])*Normal[iDim]; | ||
| } | ||
| } | ||
|
|
||
| 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); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it is possible to set |
||
|
|
||
| FinishResidualCalc(val_residual, val_Jacobian_i, val_Jacobian_j, config); | ||
|
|
||
|
|
||
| AD::SetPreaccOut(val_residual, nVar); | ||
| AD::EndPreacc(); | ||
|
|
||
|
|
@@ -113,16 +91,18 @@ CUpwSca_TurbSA::~CUpwSca_TurbSA(void) { | |
| } | ||
|
|
||
| void CUpwSca_TurbSA::ExtraADPreaccIn() { | ||
| AD::SetPreaccIn(V_i, nDim+1); AD::SetPreaccIn(V_j, nDim+1); | ||
| AD::SetPreaccIn(V_i[nDim+2]); AD::SetPreaccIn(V_j[nDim+2]); | ||
| } | ||
|
|
||
| void CUpwSca_TurbSA::FinishResidualCalc(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { | ||
|
|
||
| val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; | ||
| su2double OneOnAveRho = 2.0/(V_i[nDim+2]+V_j[nDim+2]); | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SA is funny and so density is still needed here... |
||
| val_residual[0] = (a0*TurbVar_i[0]+a1*TurbVar_j[0])*OneOnAveRho; | ||
|
|
||
| if (implicit) { | ||
| val_Jacobian_i[0][0] = a0; | ||
| val_Jacobian_j[0][0] = a1; | ||
| val_Jacobian_i[0][0] = a0*OneOnAveRho; | ||
| val_Jacobian_j[0][0] = a1*OneOnAveRho; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1087,27 +1067,20 @@ CUpwSca_TurbSST::CUpwSca_TurbSST(unsigned short val_nDim, | |
| CUpwSca_TurbSST::~CUpwSca_TurbSST(void) { | ||
| } | ||
|
|
||
| void CUpwSca_TurbSST::ExtraADPreaccIn() { | ||
|
|
||
| AD::SetPreaccIn(V_i, nDim+3); | ||
| AD::SetPreaccIn(V_j, nDim+3); | ||
|
|
||
| } | ||
|
|
||
| void CUpwSca_TurbSST::FinishResidualCalc(su2double *val_residual, | ||
| su2double **val_Jacobian_i, | ||
| su2double **val_Jacobian_j, | ||
| 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]; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
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.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
| val_residual[0] = a0*TurbVar_i[0]+a1*TurbVar_j[0]; | ||
| val_residual[1] = a0*TurbVar_i[1]+a1*TurbVar_j[1]; | ||
|
|
||
| if (implicit) { | ||
| val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; | ||
| val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; | ||
| val_Jacobian_i[0][0] = a0; val_Jacobian_i[0][1] = 0.0; | ||
| val_Jacobian_i[1][0] = 0.0; val_Jacobian_i[1][1] = a0; | ||
|
|
||
| val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; | ||
| val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; | ||
| val_Jacobian_j[0][0] = a1; val_Jacobian_j[0][1] = 0.0; | ||
| val_Jacobian_j[1][0] = 0.0; val_Jacobian_j[1][1] = a1; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -1156,11 +1129,11 @@ void CAvgGrad_TurbSST::FinishResidualCalc(su2double *val_residual, su2double **J | |
|
|
||
| /*--- For Jacobians -> Use of TSL approx. to compute derivatives of the gradients ---*/ | ||
| if (implicit) { | ||
| Jacobian_i[0][0] = -diff_kine*proj_vector_ij/Density_i; Jacobian_i[0][1] = 0.0; | ||
| Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij/Density_i; | ||
| Jacobian_i[0][0] = -diff_kine*proj_vector_ij; Jacobian_i[0][1] = 0.0; | ||
| Jacobian_i[1][0] = 0.0; Jacobian_i[1][1] = -diff_omega*proj_vector_ij; | ||
|
|
||
| Jacobian_j[0][0] = diff_kine*proj_vector_ij/Density_j; Jacobian_j[0][1] = 0.0; | ||
| Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij/Density_j; | ||
| Jacobian_j[0][0] = diff_kine*proj_vector_ij; Jacobian_j[0][1] = 0.0; | ||
| Jacobian_j[1][0] = 0.0; Jacobian_j[1][1] = diff_omega*proj_vector_ij; | ||
| } | ||
|
|
||
| } | ||
|
|
@@ -1272,10 +1245,10 @@ void CSourcePieceWise_TurbSST::ComputeResidual(su2double *val_residual, su2doubl | |
|
|
||
| /*--- Implicit part ---*/ | ||
|
|
||
| val_Jacobian_i[0][0] = -beta_star*TurbVar_i[1]*Volume; | ||
| val_Jacobian_i[0][1] = -beta_star*TurbVar_i[0]*Volume; | ||
| val_Jacobian_i[0][0] = -beta_star*Density_i*TurbVar_i[1]*Volume; | ||
| val_Jacobian_i[0][1] = -beta_star*Density_i*TurbVar_i[0]*Volume; | ||
| 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; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| AD::SetPreaccOut(val_residual, nVar); | ||
|
|
||
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.