Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • openfoam openfoam
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 426
    • Issues 426
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Development
  • openfoamopenfoam
  • Issues
  • #834
Closed
Open
Issue created May 17, 2018 by Kutalmış Berçin@kutiMaintainer

Micro change in nutUBlendedWallFunction?

Hi,

Please consider Foam::nutTestUBlendedWallFunctionFvPatchScalarField::calcUTau:

    tmp<scalarField> tuTaup(new scalarField(patch().size(), 0.0));
    scalarField& uTaup = tuTaup.ref();

    const scalarField& nutw = *this;

    forAll(uTaup, facei)
    {
        scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
        if (mag(ut) > ROOTVSMALL)
        {
            scalar error = GREAT;
            label iter = 0;
            while (iter++ < 10 && error > 0.001)
            {
                scalar yPlus = y[facei]*ut/nuw[facei];
                scalar uTauVis = magUp[facei]/yPlus;
                scalar uTauLog = kappa_*magUp[facei]/log(E_*yPlus);

                scalar utNew = pow(pow(uTauVis, n_) + pow(uTauLog, n_), 1.0/n_);
                error = mag(ut - utNew)/(ut + ROOTVSMALL);
                ut = 0.5*(ut + utNew);
            }
        }
        uTaup[facei] = ut;
    }
    return tuTaup;

Without sacrificing readability, wouldn't be possible to remove new scalarField(patch().size(), 0.0) and simplify the rest accordingly?

    const scalarField& nutw = *this;

    tmp<scalarField> tuTaup = sqrt((nutw + nuw)*magGradU);
    scalarField& uTaup = tuTaup.ref();

    forAll(uTaup, facei)
    {   
        if (mag(uTaup[facei]) > ROOTVSMALL)
        {   
            scalar error = GREAT;
            label iter = 0;
            while (error > 0.001 && iter++ < 10)
            {
                scalar yPlus = y[facei]*uTaup[facei]/nuw[facei];
                scalar uTauVis = magUp[facei]/yPlus;
                scalar uTauLog = kappa_*magUp[facei]/log(E_*yPlus);

                scalar utNew = pow(pow(uTauVis, n_) + pow(uTauLog, n_), 1.0/n_);
                error = mag(uTaup[facei] - utNew)/(uTaup[facei] + ROOTVSMALL);
                uTaup[facei] = 0.5*(uTaup[facei] + utNew);
            }
        }   
    }   
    return tuTaup;

Also, in while (iter++ < 10 && error > 0.001), I observed for a typical channel case I run that error > 0.001 becomes False quicker than iter++ < 10. Might be wiser to swap error and iter, so that while exits without testing iter redundantly when error < 0.001?

Edited May 17, 2018 by Kutalmış Berçin
Assignee
Assign to
Time tracking