-
Notifications
You must be signed in to change notification settings - Fork 1k
Axisymmetric near-axis fixes using L’Hôpital-consistent formulations #2715
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
Open
raghava-davuluri
wants to merge
8
commits into
su2code:develop
Choose a base branch
from
hypersonic-lab:develop_axifix
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+96
−42
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f4467cf
Trying to fix axisymmetry issue seen in heat flux
Hanquist 1b53ab2
Clarifying the change
Hanquist a26ee2a
Axisymmetric source term: blend dv/dr with v/r near axis
raghava-davuluri 80027c2
Remove redundant velocity definition
raghava-davuluri 060b823
Update regression values for axisymmetric source term
raghava-davuluri cd725f1
Restore ion_gy regression values
raghava-davuluri b765070
Exclude NEMO from axisymmetric auxiliary correction
raghava-davuluri 503e6fd
Remove trailing whitespace
raghava-davuluri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,27 +63,64 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Flow::ComputeResidual(const CConfi | |||||||
| su2double Pressure_i, Enthalpy_i, Velocity_i, sq_vel; | ||||||||
| unsigned short iDim, iVar, jVar; | ||||||||
|
|
||||||||
| if (Coord_i[1] > EPS) { | ||||||||
| /*--- Common calculations for both branches ---*/ | ||||||||
| su2double rho = U_i[0]; // density | ||||||||
| su2double u = U_i[1]/U_i[0]; // u-velocity | ||||||||
| su2double r = Coord_i[1]; // radial coordinate | ||||||||
| su2double dv_dr = PrimVar_Grad_i[2][1]; // ∂v/∂r (radial velocity gradient) | ||||||||
|
|
||||||||
| yinv = 1.0/Coord_i[1]; | ||||||||
| sq_vel = 0.0; | ||||||||
| for (iDim = 0; iDim < nDim; iDim++) { | ||||||||
| Velocity_i = U_i[iDim+1] / U_i[0]; | ||||||||
| sq_vel += Velocity_i * Velocity_i; | ||||||||
| } | ||||||||
| Pressure_i = Gamma_Minus_One*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); | ||||||||
| Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; | ||||||||
|
|
||||||||
| /*--- Smooth blending between gradient formulation and standard formulation ---*/ | ||||||||
| su2double transition_width = 50.0 * EPS; // Smooth transition over 50×EPS (much wider) | ||||||||
| su2double alpha = 0.0; // Blending factor: 0=gradient_form, 1=standard_form | ||||||||
|
|
||||||||
| if (r > transition_width) { | ||||||||
| alpha = 1.0; // Far from axis: use standard v/r formulation | ||||||||
| } else if (r > EPS) { | ||||||||
| // Smooth transition zone: blend between formulations (gentler slope) | ||||||||
| alpha = 0.5 * (1.0 + tanh(2.0 * (r - 0.5*(EPS + transition_width))/(transition_width - EPS))); | ||||||||
| } else { | ||||||||
| alpha = 0.0; // Near axis: use gradient formulation | ||||||||
| } | ||||||||
|
|
||||||||
| sq_vel = 0.0; | ||||||||
| for (iDim = 0; iDim < nDim; iDim++) { | ||||||||
| Velocity_i = U_i[iDim+1] / U_i[0]; | ||||||||
| sq_vel += Velocity_i *Velocity_i; | ||||||||
| } | ||||||||
| /*--- Standard formulation (v/r) ---*/ | ||||||||
| su2double std_res[4]; | ||||||||
| if (r > EPS) { | ||||||||
| yinv = 1.0/r; | ||||||||
| std_res[0] = yinv*Volume*U_i[2]; // ρv/r | ||||||||
| std_res[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; // ρuv/r | ||||||||
| std_res[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); // ρv²/r | ||||||||
| std_res[3] = yinv*Volume*Enthalpy_i*U_i[2]; // ρHv/r | ||||||||
| } else { | ||||||||
| // Avoid division by zero, set to zero (will be blended out anyway) | ||||||||
| std_res[0] = std_res[1] = std_res[2] = std_res[3] = 0.0; | ||||||||
| } | ||||||||
|
|
||||||||
| Pressure_i = Gamma_Minus_One*U_i[0]*(U_i[nDim+1]/U_i[0]-0.5*sq_vel); | ||||||||
| Enthalpy_i = (U_i[nDim+1] + Pressure_i) / U_i[0]; | ||||||||
| /*--- Gradient formulation (∂v/∂r) ---*/ | ||||||||
| su2double grad_res[4]; | ||||||||
| grad_res[0] = Volume * rho * dv_dr; // ρ(∂v/∂r) | ||||||||
| grad_res[1] = Volume * rho * u * dv_dr; // ρu(∂v/∂r) | ||||||||
| grad_res[2] = 0.0; // ρv(∂v/∂r) = 0 since v→0 as r→0 | ||||||||
| grad_res[3] = Volume * rho * Enthalpy_i * dv_dr; // ρH(∂v/∂r) | ||||||||
|
|
||||||||
| residual[0] = yinv*Volume*U_i[2]; | ||||||||
| residual[1] = yinv*Volume*U_i[1]*U_i[2]/U_i[0]; | ||||||||
| residual[2] = yinv*Volume*(U_i[2]*U_i[2]/U_i[0]); | ||||||||
| residual[3] = yinv*Volume*Enthalpy_i*U_i[2]; | ||||||||
| /*--- Blend the two formulations ---*/ | ||||||||
| residual[0] = (1.0 - alpha) * grad_res[0] + alpha * std_res[0]; | ||||||||
| residual[1] = (1.0 - alpha) * grad_res[1] + alpha * std_res[1]; | ||||||||
| residual[2] = (1.0 - alpha) * grad_res[2] + alpha * std_res[2]; | ||||||||
| residual[3] = (1.0 - alpha) * grad_res[3] + alpha * std_res[3]; | ||||||||
|
|
||||||||
| /*--- Inviscid component of the source term. ---*/ | ||||||||
|
|
||||||||
| if (implicit) { | ||||||||
| /*--- Jacobian calculation ---*/ | ||||||||
| if (implicit) { | ||||||||
| if (alpha > 0.5) { | ||||||||
| // Use standard Jacobian when mostly in standard formulation | ||||||||
| yinv = 1.0/r; | ||||||||
|
Comment on lines
+122
to
+123
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.
Suggested change
|
||||||||
| jacobian[0][0] = 0.0; | ||||||||
| jacobian[0][1] = 0.0; | ||||||||
| jacobian[0][2] = 1.0; | ||||||||
|
|
@@ -107,29 +144,18 @@ CNumerics::ResidualType<> CSourceAxisymmetric_Flow::ComputeResidual(const CConfi | |||||||
| for (iVar=0; iVar < nVar; iVar++) | ||||||||
| for (jVar=0; jVar < nVar; jVar++) | ||||||||
| jacobian[iVar][jVar] *= yinv*Volume; | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| /*--- Add the viscous terms if necessary. ---*/ | ||||||||
|
|
||||||||
| if (viscous) ResidualDiffusion(); | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| else { | ||||||||
|
|
||||||||
| for (iVar=0; iVar < nVar; iVar++) | ||||||||
| residual[iVar] = 0.0; | ||||||||
|
|
||||||||
| if (implicit) { | ||||||||
| } else { | ||||||||
| // Near axis: set Jacobian to zero (gradient formulation is more complex) | ||||||||
| for (iVar=0; iVar < nVar; iVar++) { | ||||||||
| for (jVar=0; jVar < nVar; jVar++) | ||||||||
| jacobian[iVar][jVar] = 0.0; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| /*--- Add the viscous terms if necessary. ---*/ | ||||||||
| if (viscous) ResidualDiffusion(); | ||||||||
|
|
||||||||
| return ResidualType<>(residual, jacobian, nullptr); | ||||||||
| } | ||||||||
|
|
||||||||
|
|
@@ -223,17 +249,34 @@ CNumerics::ResidualType<> CSourceGeneralAxisymmetric_Flow::ComputeResidual(const | |||||||
| } | ||||||||
|
|
||||||||
| else { | ||||||||
|
|
||||||||
| for (iVar=0; iVar < nVar; iVar++) | ||||||||
| residual[iVar] = 0.0; | ||||||||
| /*--- At the axis of symmetry, use L'Hôpital's rule: lim(v/r) = dv/dr ---*/ | ||||||||
| const su2double dv_dr = PrimVar_Grad_i[2][1]; // ∂v/∂r (radial velocity gradient) | ||||||||
| const su2double u = U_i[1]/U_i[0]; // axial velocity u | ||||||||
| const su2double rho = U_i[0]; // density | ||||||||
|
|
||||||||
| /* Compute pressure and enthalpy consistently with the general-gas formulation. */ | ||||||||
| const su2double Density_i = rho; | ||||||||
| const su2double Energy_i = U_i[3]/U_i[0]; | ||||||||
| const su2double Pressure_i = V_j[3]; | ||||||||
| const su2double Enthalpy_i = Energy_i + Pressure_i/Density_i; | ||||||||
|
|
||||||||
| /*--- Apply L'Hôpital's rule to axisymmetric source terms ---*/ | ||||||||
| residual[0] = Volume * rho * dv_dr; // ρ(∂v/∂r) | ||||||||
| residual[1] = Volume * rho * u * dv_dr; // ρu(∂v/∂r) | ||||||||
| residual[2] = 0.0; // ρv(∂v/∂r) = 0 since v=0 at axis | ||||||||
| residual[3] = Volume * rho * Enthalpy_i * dv_dr; // ρH(∂v/∂r) | ||||||||
|
|
||||||||
| if (implicit) { | ||||||||
| for (iVar=0; iVar < nVar; iVar++) { | ||||||||
| for (jVar=0; jVar < nVar; jVar++) | ||||||||
| /* For now, set Jacobian to zero at axis (can be improved later to help with convergence). */ | ||||||||
| for (iVar = 0; iVar < nVar; iVar++) { | ||||||||
| for (jVar = 0; jVar < nVar; jVar++) | ||||||||
| jacobian[iVar][jVar] = 0.0; | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| /*--- Add the viscous terms if necessary. ---*/ | ||||||||
| if (viscous) ResidualDiffusion(); | ||||||||
|
|
||||||||
| } | ||||||||
|
|
||||||||
| return ResidualType<>(residual, jacobian, nullptr); | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.