su2code/SU2

Chaotic timeline of primitives used in turb function

ShiheJia opened this issue · 2 comments

Describe the bug
When I read the turb model code, I find the primitives used are usually in different iterations.

What I mean is the NS solver has done Preprocessing/Space_Integration/Time_Integration/Postprocessing and updated the Solution before turb solver in CFluidIteration::Iterate().

And the consequence of that is the two vars Solution and Primitive are out of step for turb solver and the gradients is all related to Primitive but not Solution.

Normally turb solver uses the Primitive and Gradient to compute flux, but when it comes to compute the eddy viscocity(MuT) in Postprocessing function both in SA and SST model.

Take SA model as an example:

'''
void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) {

const su2double cv1_3 = 7.17.17.1, cR1 = 0.5, rough_const = 0.03;

const bool neg_spalart_allmaras = config->GetSAParsedOptions().version == SA_OPTIONS::NEG;

/--- Compute eddy viscosity ---/

for (unsigned long iPoint = 0; iPoint < nPoint; iPoint ++) {

const su2double rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
const su2double mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint);

const su2double nu = mu/rho;
const su2double nu_hat = nodes->GetSolution(iPoint,0);
const su2double roughness = geometry->nodes->GetRoughnessHeight(iPoint);
const su2double dist = geometry->nodes->GetWall_Distance(iPoint) + rough_const * roughness;

su2double Ji = nu_hat/nu;
if (roughness > 1.0e-10)
  Ji += cR1*roughness/(dist+EPS);

const su2double Ji_3 = Ji*Ji*Ji;
const su2double fv1  = Ji_3/(Ji_3+cv1_3);

su2double muT = rho*fv1*nu_hat;

if (neg_spalart_allmaras) muT = max(muT,0.0);

nodes->SetmuT(iPoint,muT);

}

}
'''

Defined in CEulerVariable.hpp and CNSVariable.hpp, the following two functions returns vars in next and current iterations:

rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint);

and they are used together.

I guess this implementation may have an effect on unsteady problems so I wonder if there is any wrong with my thought, so I open this issue.

Any help will be appreciated.

Thanks for the question.
The flow preprocessing is called again before moving to the turbulence solver.
In the future please use Discussions for questions.

Thanks for your guidence.
I found the code snippet you metioned in version 7.4.0 hasnot shown up in my current version 7.2.0. Quite happy to see contributors have revised this.