mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: Was holding a reference to a tmp
This commit is contained in:
@ -42,15 +42,15 @@ namespace RASModels
|
|||||||
|
|
||||||
tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const
|
tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcNut() const
|
||||||
{
|
{
|
||||||
const label patchi = patch().index();
|
const label patchI = patch().index();
|
||||||
|
|
||||||
const turbulenceModel& turbModel =
|
const turbulenceModel& turbModel =
|
||||||
db().lookupObject<turbulenceModel>("turbulenceModel");
|
db().lookupObject<turbulenceModel>("turbulenceModel");
|
||||||
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchi];
|
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchI];
|
||||||
const scalarField magGradU(mag(Uw.snGrad()));
|
const scalarField magGradU(mag(Uw.snGrad()));
|
||||||
const tmp<volScalarField> tnu = turbModel.nu();
|
const tmp<volScalarField> tnu = turbModel.nu();
|
||||||
const volScalarField& nu = tnu();
|
const volScalarField& nu = tnu();
|
||||||
const scalarField& nuw = nu.boundaryField()[patchi];
|
const scalarField& nuw = nu.boundaryField()[patchI];
|
||||||
|
|
||||||
return max
|
return max
|
||||||
(
|
(
|
||||||
@ -65,23 +65,27 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
|
|||||||
const scalarField& magGradU
|
const scalarField& magGradU
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
|
const label patchI = patch().index();
|
||||||
|
|
||||||
const turbulenceModel& turbModel =
|
const turbulenceModel& turbModel =
|
||||||
db().lookupObject<turbulenceModel>("turbulenceModel");
|
db().lookupObject<turbulenceModel>("turbulenceModel");
|
||||||
const scalarField& y = turbModel.y()[patch().index()];
|
const scalarField& y = turbModel.y()[patchI];
|
||||||
|
|
||||||
const fvPatchVectorField& Uw =
|
const fvPatchVectorField& Uw = turbModel.U().boundaryField()[patchI];
|
||||||
turbModel.U().boundaryField()[patch().index()];
|
|
||||||
const scalarField magUp(mag(Uw.patchInternalField() - Uw));
|
const scalarField magUp(mag(Uw.patchInternalField() - Uw));
|
||||||
|
|
||||||
const scalarField& nuw = turbModel.nu()().boundaryField()[patch().index()];
|
const tmp<volScalarField> tnu = turbModel.nu();
|
||||||
|
const volScalarField& nu = tnu();
|
||||||
|
const scalarField& nuw = nu.boundaryField()[patchI];
|
||||||
|
|
||||||
const scalarField& nutw = *this;
|
const scalarField& nutw = *this;
|
||||||
|
|
||||||
tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
|
tmp<scalarField> tuTau(new scalarField(patch().size(), 0.0));
|
||||||
scalarField& uTau = tuTau();
|
scalarField& uTau = tuTau();
|
||||||
|
|
||||||
forAll(uTau, facei)
|
forAll(uTau, faceI)
|
||||||
{
|
{
|
||||||
scalar ut = sqrt((nutw[facei] + nuw[facei])*magGradU[facei]);
|
scalar ut = sqrt((nutw[faceI] + nuw[faceI])*magGradU[faceI]);
|
||||||
|
|
||||||
if (ut > ROOTVSMALL)
|
if (ut > ROOTVSMALL)
|
||||||
{
|
{
|
||||||
@ -90,17 +94,17 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
scalar kUu = min(kappa_*magUp[facei]/ut, 50);
|
scalar kUu = min(kappa_*magUp[faceI]/ut, 50);
|
||||||
scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
|
scalar fkUu = exp(kUu) - 1 - kUu*(1 + 0.5*kUu);
|
||||||
|
|
||||||
scalar f =
|
scalar f =
|
||||||
- ut*y[facei]/nuw[facei]
|
- ut*y[faceI]/nuw[faceI]
|
||||||
+ magUp[facei]/ut
|
+ magUp[faceI]/ut
|
||||||
+ 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
|
+ 1/E_*(fkUu - 1.0/6.0*kUu*sqr(kUu));
|
||||||
|
|
||||||
scalar df =
|
scalar df =
|
||||||
y[facei]/nuw[facei]
|
y[faceI]/nuw[faceI]
|
||||||
+ magUp[facei]/sqr(ut)
|
+ magUp[faceI]/sqr(ut)
|
||||||
+ 1/E_*kUu*fkUu/ut;
|
+ 1/E_*kUu*fkUu/ut;
|
||||||
|
|
||||||
scalar uTauNew = ut + f/df;
|
scalar uTauNew = ut + f/df;
|
||||||
@ -109,7 +113,7 @@ tmp<scalarField> nutUSpaldingWallFunctionFvPatchScalarField::calcUTau
|
|||||||
|
|
||||||
} while (ut > ROOTVSMALL && err > 0.01 && ++iter < 10);
|
} while (ut > ROOTVSMALL && err > 0.01 && ++iter < 10);
|
||||||
|
|
||||||
uTau[facei] = max(0.0, ut);
|
uTau[faceI] = max(0.0, ut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user