Skip to content
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

Add local timestep + CFL as volume output #2060

Merged
merged 2 commits into from
Jun 25, 2023

Conversation

j-signorelli
Copy link
Contributor

Proposed Changes

Added local timestep and local CFL as volume output for both the flow and turbulence variables

Related Work

In relation to #2056

PR Checklist

Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

@pcarruscag
Copy link
Member

Thanks, please add yourself to AUTHORS.md

@pcarruscag pcarruscag merged commit e12db69 into su2code:develop Jun 25, 2023
@j-signorelli
Copy link
Contributor Author

Hi @pcarruscag, just wanted to follow up with you on something about this: it looks like to me that the volume output $\Delta t$'s are nondimensional. Would it be worthwhile to mention this in the SU2_CFD -d call? Or even just calculate the actual physical time as the volume output alternatively? This may be confusing.

@pcarruscag
Copy link
Member

Our reference for time is always 1 so they should match physical time even if they appear non-dimensional. What area of the code made it look nondimensional?

@j-signorelli
Copy link
Contributor Author

j-signorelli commented Jun 29, 2023

Oh interesting, just to be fully complete here's what made me think that:

1.I have a well-converged steady-state solution and outputted the minimum DT's for each cell when running with a CFL=1.0, no adaptive. I was unable to restart this for an unsteady one with no changes in BCs without using a DT orders-of-magnitude smaller.

  1. When I run /Tutorials/compressible_flow/Turbulent_OneraM6 with MIN_DELTA_TIME set as a screen output, I get orders-of-magnitude different final timestep when I run with REF_DIMENSIONALIZATION= DIMENSIONAL instead of FREESTREAM_VEL_EQ_ONE.

  2. When I run SU2_CFD -d on the /Tutorials/compressible_flow/Unsteady_NACA0012 example using FREESTREAM_VEL_EQ_ONE I see the attached image below, which appears to nondimensionalize using length/velocity.

Unsteady_NACA0012_SU2CFDd

  1. I also looked briefly at the code it appeared that the calculations were using nondimensional values; here's what I looked at:

Setting of local timestep:

if (Vol != 0.0) {
su2double Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint);
if(viscous) {
su2double dt_visc = nodes->GetLocalCFL(iPoint)*K_v*Vol*Vol / nodes->GetMax_Lambda_Visc(iPoint);
Local_Delta_Time = min(Local_Delta_Time, dt_visc);
}
minDt = min(minDt, Local_Delta_Time);
maxDt = max(maxDt, Local_Delta_Time);
nodes->SetDelta_Time(iPoint, min(Local_Delta_Time, config->GetMax_DeltaTime()));
}
else {
nodes->SetDelta_Time(iPoint,0.0);
}
}

Calculation of Lambda's:

auto jPoint = geometry->nodes->GetPoint(iPoint,iNeigh);
auto iEdge = geometry->nodes->GetEdge(iPoint,iNeigh);
auto Normal = geometry->edges->GetNormal(iEdge);
auto Area2 = GeometryToolbox::SquaredNorm(nDim, Normal);
/*--- Mean Values ---*/
su2double Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal));
su2double Mean_SoundSpeed = soundSpeed(*nodes, iPoint, jPoint) * sqrt(Area2);
/*--- Adjustment for grid movement ---*/
if (dynamic_grid) {
const su2double *GridVel_i = geometry->nodes->GetGridVel(iPoint);
const su2double *GridVel_j = geometry->nodes->GetGridVel(jPoint);
for (unsigned short iDim = 0; iDim < nDim; iDim++)
Mean_ProjVel -= 0.5 * (GridVel_i[iDim] + GridVel_j[iDim]) * Normal[iDim];
}
/*--- Inviscid contribution ---*/
su2double Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed;
nodes->AddMax_Lambda_Inv(iPoint,Lambda);
/*--- Viscous contribution ---*/
if (!viscous) continue;
Lambda = lambdaVisc(*nodes, iPoint, jPoint) * Area2;
nodes->AddMax_Lambda_Visc(iPoint, Lambda);

GetProjVel:

/*!
* \brief Get the projected velocity in a unitary vector direction (compressible solver).
* \param[in] val_vector - Direction of projection.
* \return Value of the projected velocity.
*/
inline su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final {
su2double ProjVel = 0.0;
for (unsigned long iDim = 0; iDim < nDim; iDim++)
ProjVel += Primitive(iPoint,iDim+indices.Velocity())*val_vector[iDim];
return ProjVel;
}

Then at this point admittedly I just assumed that the MatrixType Primitive of CEulerVariable was indeed nondimensional. I am not familiar with where/when data is stored/updated throughout SU2 as nondimensional v dimensional.

@pcarruscag
Copy link
Member

You are right, but in nondim mode all outputs are the nondim ones, so this is consistent.

@j-signorelli
Copy link
Contributor Author

Would it be worthwhile to output the time step reference line for steady simulations in the "Solver Preprocessing" section as well then? This is only done for unsteady simulations.

@pcarruscag
Copy link
Member

Sure sounds good

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

Successfully merging this pull request may close these issues.

2 participants