-
Notifications
You must be signed in to change notification settings - Fork 1k
Unsteady incompressible flow simulation with grid movement #767
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
d657e3f
6a15d71
13ff5ed
039ce34
f4c4d48
c907272
987e58a
6f46955
74666b9
79bdbad
bcf715c
8eb7d1d
6ebdbff
500df9b
914a90b
7470687
4e68c6e
f8e6bdf
f81ee4b
276a710
e6ea7eb
708f1a2
6a678f3
8e1c3be
2dcb696
7f183ad
2a06e45
97577f0
ef6c3da
8c9c681
4c4f163
c12d70b
02592d4
e5d456e
2cabc26
4129bac
6a9c87d
3781d7c
ad936f6
e3951df
4051b40
16f6ee9
395275c
5a14750
92b58d7
fa587e2
a91c843
f022a88
6d83e12
a7d10a1
a7d9b01
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 |
|---|---|---|
|
|
@@ -86,8 +86,15 @@ CUpwFDSInc_Flow::~CUpwFDSInc_Flow(void) { | |
|
|
||
| void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { | ||
|
|
||
| su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; | ||
| su2double ProjGridVel = 0.0; | ||
|
|
||
| AD::StartPreacc(); | ||
| AD::SetPreaccIn(V_i, nDim+9); AD::SetPreaccIn(V_j, nDim+9); AD::SetPreaccIn(Normal, nDim); | ||
| if (dynamic_grid) { | ||
| AD::SetPreaccIn(GridVel_i, nDim); | ||
| AD::SetPreaccIn(GridVel_j, nDim); | ||
| } | ||
|
|
||
| /*--- Face area (norm or the normal vector) ---*/ | ||
|
|
||
|
|
@@ -120,6 +127,16 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J | |
| ProjVelocity += MeanVelocity[iDim]*Normal[iDim]; | ||
| } | ||
|
|
||
| /*--- Projected velocity adjustment due to mesh motion ---*/ | ||
|
|
||
| if (dynamic_grid) { | ||
| ProjGridVel = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
| } | ||
| ProjVelocity -= ProjGridVel; | ||
| } | ||
|
|
||
| /*--- Mean variables at points iPoint and jPoint ---*/ | ||
|
|
||
| MeanDensity = 0.5*(DensityInc_i + DensityInc_j); | ||
|
|
@@ -214,6 +231,38 @@ void CUpwFDSInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_J | |
| } | ||
| } | ||
|
|
||
| /*--- Corrections due to grid motion ---*/ | ||
| if (dynamic_grid) { | ||
|
|
||
| /*--- Recompute conservative variables ---*/ | ||
|
|
||
| U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; | ||
| } | ||
| U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; | ||
|
|
||
| ProjVelocity = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) | ||
| ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
|
|
||
| /*--- Residual contributions ---*/ | ||
| for (iVar = 0; iVar < nVar; iVar++) { | ||
| val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); | ||
|
|
||
| /*--- Jacobian contributions ---*/ | ||
| /*--- Implicit terms ---*/ | ||
| if (implicit) { | ||
| for (iDim = 0; iDim < nDim; iDim++){ | ||
| val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; | ||
| val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; | ||
| } | ||
| val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; | ||
| val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (!energy) { | ||
| val_residual[nDim+1] = 0.0; | ||
| if (implicit) { | ||
|
|
@@ -277,6 +326,9 @@ CCentJSTInc_Flow::~CCentJSTInc_Flow(void) { | |
|
|
||
| void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { | ||
|
|
||
| su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; | ||
| su2double ProjGridVel = 0.0; | ||
|
|
||
| /*--- Primitive variables at point i and j ---*/ | ||
|
|
||
| Pressure_i = V_i[0]; Pressure_j = V_j[0]; | ||
|
|
@@ -336,7 +388,39 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /*--- Corrections due to grid motion ---*/ | ||
| if (dynamic_grid) { | ||
|
|
||
| /*--- Recompute conservative variables ---*/ | ||
|
|
||
| U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; | ||
| } | ||
| U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; | ||
|
Member
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 think you have all of the mean quantities computed, is it necessary to recompute here? This might be a compressible vs incompressible difference but, in compressible flows only Energy gets affected by grid motion, is it completely equivalent to use Enthalpy here?
Contributor
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. One of the main changes to the governing equations for the incompressible solver is the simplified energy equation. The final term in the convective flux for the low Mach equations used in the incompressible solver is rhoCpT*v. As part of the change to account for grid motion, the grid velocity is removed from all the velocity terms in the incompressible convective flux, similar to the compressible flow, which I think should still hold true with enthalpy. |
||
|
|
||
| su2double ProjVelocity = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) | ||
| ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
|
|
||
| /*--- Residual contributions ---*/ | ||
| for (iVar = 0; iVar < nVar; iVar++) { | ||
| val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); | ||
|
|
||
| /*--- Jacobian contributions ---*/ | ||
| /*--- Implicit terms ---*/ | ||
| if (implicit) { | ||
| for (iDim = 0; iDim < nDim; iDim++){ | ||
| val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; | ||
| val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; | ||
| } | ||
| val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; | ||
| val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /*--- Computes differences between Laplacians and conservative variables ---*/ | ||
|
|
||
| for (iVar = 0; iVar < nVar; iVar++) { | ||
|
|
@@ -351,6 +435,17 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| /*--- Compute the local spectral radius of the preconditioned system | ||
| and the stretching factor. ---*/ | ||
|
|
||
| /*--- Projected velocity adjustment due to mesh motion ---*/ | ||
|
|
||
| if (dynamic_grid) { | ||
| ProjGridVel = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
| } | ||
| ProjVelocity_i -= ProjGridVel; | ||
| ProjVelocity_j -= ProjGridVel; | ||
| } | ||
|
|
||
| SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); | ||
| SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); | ||
|
|
||
|
|
@@ -396,7 +491,6 @@ void CCentJSTInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| CCentLaxInc_Flow::CCentLaxInc_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { | ||
|
|
@@ -442,6 +536,9 @@ CCentLaxInc_Flow::~CCentLaxInc_Flow(void) { | |
|
|
||
| void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config) { | ||
|
|
||
| su2double U_i[5] = {0.0,0.0,0.0,0.0,0.0}, U_j[5] = {0.0,0.0,0.0,0.0,0.0}; | ||
| su2double ProjGridVel = 0.0, ProjVelocity = 0.0; | ||
|
|
||
| /*--- Primitive variables at point i and j ---*/ | ||
|
|
||
| Pressure_i = V_i[0]; Pressure_j = V_j[0]; | ||
|
|
@@ -503,7 +600,38 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| /*--- Corrections due to grid motion ---*/ | ||
| if (dynamic_grid) { | ||
|
|
||
| /*--- Recompute conservative variables ---*/ | ||
|
|
||
| U_i[0] = DensityInc_i; U_j[0] = DensityInc_j; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| U_i[iDim+1] = DensityInc_i*Velocity_i[iDim]; U_j[iDim+1] = DensityInc_j*Velocity_j[iDim]; | ||
| } | ||
| U_i[nDim+1] = DensityInc_i*Enthalpy_i; U_j[nDim+1] = DensityInc_j*Enthalpy_j; | ||
|
|
||
| for (iDim = 0; iDim < nDim; iDim++) | ||
| ProjVelocity += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
|
|
||
| /*--- Residual contributions ---*/ | ||
| for (iVar = 0; iVar < nVar; iVar++) { | ||
| val_residual[iVar] -= ProjVelocity * 0.5*(U_i[iVar]+U_j[iVar]); | ||
|
|
||
| /*--- Jacobian contributions ---*/ | ||
| /*--- Implicit terms ---*/ | ||
| if (implicit) { | ||
| for (iDim = 0; iDim < nDim; iDim++){ | ||
| val_Jacobian_i[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_i; | ||
| val_Jacobian_j[iDim+1][iDim+1] -= 0.5*ProjVelocity*DensityInc_j; | ||
| } | ||
| val_Jacobian_i[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_i*Cp_i; | ||
| val_Jacobian_j[nDim+1][nDim+1] -= 0.5*ProjVelocity*DensityInc_j*Cp_j; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /*--- Computes differences btw. conservative variables ---*/ | ||
|
|
||
| for (iVar = 0; iVar < nVar; iVar++) | ||
|
|
@@ -519,6 +647,17 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| SoundSpeed_i = sqrt(BetaInc2_i*Area*Area); | ||
| SoundSpeed_j = sqrt(BetaInc2_j*Area*Area); | ||
|
|
||
| /*--- Projected velocity adjustment due to mesh motion ---*/ | ||
|
|
||
| if (dynamic_grid) { | ||
| ProjGridVel = 0.0; | ||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| ProjGridVel += 0.5*(GridVel_i[iDim]+GridVel_j[iDim])*Normal[iDim]; | ||
| } | ||
| ProjVelocity_i -= ProjGridVel; | ||
| ProjVelocity_j -= ProjGridVel; | ||
| } | ||
|
|
||
| Local_Lambda_i = fabs(ProjVelocity_i)+SoundSpeed_i; | ||
| Local_Lambda_j = fabs(ProjVelocity_j)+SoundSpeed_j; | ||
|
|
||
|
|
@@ -558,7 +697,6 @@ void CCentLaxInc_Flow::ComputeResidual(su2double *val_residual, su2double **val_ | |
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| CAvgGradInc_Flow::CAvgGradInc_Flow(unsigned short val_nDim, | ||
|
|
@@ -852,6 +990,72 @@ void CSourceIncBodyForce::ComputeResidual(su2double *val_residual, CConfig *conf | |
|
|
||
| } | ||
|
|
||
| CSourceIncRotatingFrame_Flow::CSourceIncRotatingFrame_Flow(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { | ||
|
|
||
| implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); | ||
|
|
||
| Gamma = config->GetGamma(); | ||
| Gamma_Minus_One = Gamma - 1.0; | ||
|
|
||
| /*--- Retrieve the angular velocity vector from config. ---*/ | ||
| for (unsigned short iDim = 0; iDim < 3; iDim++) | ||
| Omega[iDim] = config->GetRotation_Rate(iDim)/config->GetOmega_Ref(); | ||
|
|
||
| } | ||
|
|
||
| CSourceIncRotatingFrame_Flow::~CSourceIncRotatingFrame_Flow(void) { } | ||
|
|
||
| void CSourceIncRotatingFrame_Flow::ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, CConfig *config) { | ||
|
|
||
| unsigned short iDim, iVar, jVar; | ||
| su2double Momentum[3] = {0,0,0}, | ||
| Velocity_i[3] = {0,0,0}; | ||
|
|
||
| /*--- Primitive variables plus momentum at the node (point i) ---*/ | ||
|
|
||
| DensityInc_i = V_i[nDim+2]; | ||
|
|
||
| for (iDim = 0; iDim < nDim; iDim++) { | ||
| Velocity_i[iDim] = V_i[iDim+1]; | ||
| Momentum[iDim] = DensityInc_i*Velocity_i[iDim]; | ||
| } | ||
|
|
||
| /*--- Calculate rotating frame source term residual as ( Omega X Rho-U ) ---*/ | ||
|
|
||
| if (nDim == 2) { | ||
| val_residual[0] = 0.0; | ||
| val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; | ||
| val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; | ||
| val_residual[3] = 0.0; | ||
| } else { | ||
| val_residual[0] = 0.0; | ||
| val_residual[1] = (Omega[1]*Momentum[2] - Omega[2]*Momentum[1])*Volume; | ||
| val_residual[2] = (Omega[2]*Momentum[0] - Omega[0]*Momentum[2])*Volume; | ||
| val_residual[3] = (Omega[0]*Momentum[1] - Omega[1]*Momentum[0])*Volume; | ||
| val_residual[4] = 0.0; | ||
| } | ||
|
|
||
| /*--- Calculate the source term Jacobian ---*/ | ||
|
|
||
| if (implicit) { | ||
| for (iVar = 0; iVar < nVar; iVar++) | ||
| for (jVar = 0; jVar < nVar; jVar++) | ||
| val_Jacobian_i[iVar][jVar] = 0.0; | ||
| if (nDim == 2) { | ||
| val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; | ||
| val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; | ||
| } else { | ||
| val_Jacobian_i[1][2] = -DensityInc_i*Omega[2]*Volume; | ||
| val_Jacobian_i[1][3] = DensityInc_i*Omega[1]*Volume; | ||
| val_Jacobian_i[2][1] = DensityInc_i*Omega[2]*Volume; | ||
| val_Jacobian_i[2][3] = -DensityInc_i*Omega[0]*Volume; | ||
| val_Jacobian_i[3][1] = -DensityInc_i*Omega[1]*Volume; | ||
| val_Jacobian_i[3][2] = DensityInc_i*Omega[0]*Volume; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
| CSourceBoussinesq::CSourceBoussinesq(unsigned short val_nDim, unsigned short val_nVar, CConfig *config) : CNumerics(val_nDim, val_nVar, config) { | ||
|
|
||
| /*--- Store the pointer to the constant body force vector. ---*/ | ||
|
|
||
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 StartSolver() in CDriver should be deprecated soon. Has this feature also been tested with the single-zone driver, using
SINGLEZONE_DRIVER = YES? This should become the default once #724 is merged.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.
I've now tested this with SINGLEZONE_DRIVER = YES and NO, the primal result is identical. The added test case has the setting SINGLEZONE_DRIVER= YES.