Skip to content

Commit

Permalink
WIP integrated wall model
Browse files Browse the repository at this point in the history
  • Loading branch information
timofeymukha committed Sep 27, 2021
1 parent edc0282 commit 9645bec
Show file tree
Hide file tree
Showing 8 changed files with 637 additions and 50 deletions.
1 change: 1 addition & 0 deletions Make/files
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ eddyViscosities/Duprat/DupratEddyViscosity.C
wallModels/wallModelFvPatchScalarField.C
wallModels/KnownWallShearStressWallModelFvPatchScalarField.C
wallModels/LOTWWallModelFvPatchScalarField.C
wallModels/MulticellLOTWWallModelFvPatchScalarField.C
wallModels/EquilibriumODEWallModelFvPatchScalarField.C
wallModels/ODEWallModelFvPatchScalarField.C
wallModels/PGradODEWallModelFvPatchScalarField.C
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,39 @@ Foam::scalar Foam::IntegratedReichardtLawOfTheWall::value
}


Foam::scalar Foam::IntegratedReichardtLawOfTheWall::valueMulticell
(

const MultiCellSampler & sampler,
label index,
scalar uTau,
scalar nu
) const
{
const scalarListList & U =
sampler.db().lookupObject<scalarListListIOList>("U")[index];


scalarList h = sampler.h()[index];
scalarList l = sampler.lengthList()[index];

// Compute cell-length weighted mean of u across sampling cells
scalar uMean = 0;

for(int i=0; i < h.size(); i++)
{
uMean += l[i]*mag(vector(U[i][0], U[i][1], U[i][2]));
}

scalar h1 = mag(h[0] - l[0]/2);
scalar h2 = h[h.size()-1] + l[h.size()-1]/2;

uMean = uMean/(h2 - h1);

return value(uMean, h1, h2, uTau, nu);
}


Foam::scalar Foam::IntegratedReichardtLawOfTheWall::value
(
scalar u,
Expand Down Expand Up @@ -169,54 +202,35 @@ Foam::scalar Foam::IntegratedReichardtLawOfTheWall::derivative
}


Foam::scalar Foam::IntegratedReichardtLawOfTheWall::derivative
Foam::scalar Foam::IntegratedReichardtLawOfTheWall::derivativeMulticell
(
scalar h1,
scalar h2,
const MultiCellSampler & sampler,
label index,
scalar uTau,
scalar nu
) const
{
return -(logTermDerivative(h2, uTau, nu) - logTermDerivative(h1, uTau, nu) +
expTermDerivative(h2, uTau, nu) - expTermDerivative(h1, uTau, nu));
scalarList h = sampler.h()[index];
scalar h1 = mag(h[0] - sampler.lengthList()[index][0]/2);
scalar h2 = h[h.size()-1] +
sampler.lengthList()[index][h.size()-1]/2;

return derivative(h1, h2, uTau, nu);
}


Foam::scalar Foam::IntegratedReichardtLawOfTheWall::value
Foam::scalar Foam::IntegratedReichardtLawOfTheWall::derivative
(

const MultiCellSampler & sampler,
label index,
scalar h1,
scalar h2,
scalar uTau,
scalar nu
scalar nu
) const
{

const scalarListList U = sampler.db().lookupObject<scalarListListIOList>("U")[index];
const scalarList lengthList = sampler.lengthList()[index];
const scalarList h = sampler.h()[index];


// The integrated value of U from h1 to h2
scalar integratedU = 0;


forAll (lengthList, i)
{
const scalar h1 = mag(h[i] - lengthList[i]/2);
const scalar h2 = h[i] + lengthList[i]/2;
const scalar u = mag(vector(U[i][0], U[i][1], U[i][2]));
integratedU += (h2 - h1)*u;
}

const scalar h1 = h[0] - lengthList[0]/2;
const scalar h2 = h[h.size()] + lengthList[h.size()]/2;
return integratedU - (logTerm(h2, uTau, nu) - logTerm(h1, uTau, nu) +
expTerm(h2, uTau, nu) - expTerm(h1, uTau, nu));

{
return -(logTermDerivative(h2, uTau, nu) - logTermDerivative(h1, uTau, nu) +
expTermDerivative(h2, uTau, nu) - expTermDerivative(h1, uTau, nu));
}


Foam::scalar Foam::IntegratedReichardtLawOfTheWall::logTerm
(
scalar y,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ public:
//- Construct from model constants
IntegratedReichardtLawOfTheWall
(
const scalar kappa,
const scalar B1,
const scalar B2,
const scalar C
const scalar kappa=0.4,
const scalar B1=11,
const scalar B2=3,
const scalar C=7.8
);

// Destructor
Expand Down Expand Up @@ -184,9 +184,17 @@ public:
scalar nu
) const override;

scalar valueMulticell
(
const MultiCellSampler & sampler,
label index,
scalar uTau,
scalar nu
) const;

scalar value
(
scalar u,
scalar uIntegral,
scalar h1,
scalar h2,
scalar uTau,
Expand All @@ -204,20 +212,19 @@ public:
scalar nu
) const override;

scalar
derivative
scalar derivativeMulticell
(
scalar h1,
scalar h2,
const MultiCellSampler & sampler,
label index,
scalar uTau,
scalar nu
) const;

//- Return the value of the implicit function defining the law
virtual scalar value
scalar
derivative
(
const MultiCellSampler & sampler,
label index,
scalar h1,
scalar h2,
scalar uTau,
scalar nu
) const;
Expand Down
1 change: 0 additions & 1 deletion samplers/MultiCellSampler/MultiCellSampler.C
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ void Foam::MultiCellSampler::sample() const
eps = mesh_.time().deltaTValue()/averagingTime_;
}

Info << "Sampling" << nl;
forAll(sampledFields_, fieldI)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,49 @@ TEST_F(IntegratedReichardtLawOfTheWallTest, ValueSampler)
ASSERT_FLOAT_EQ(value, -0.20040621277606402);
}


TEST_F(IntegratedReichardtLawOfTheWallTest, ValueMulticellSampler)
{
extern argList * mainArgs;
const argList & args = *mainArgs;
Time runTime(Foam::Time::controlDictName, args);

autoPtr<fvMesh> meshPtr = createMesh(runTime);
const fvMesh & mesh = meshPtr();
createSamplingHeightField(mesh);

const fvPatch & patch = mesh.boundary()["bottomWall"];
volScalarField & h = const_cast<volScalarField &>
(
mesh.thisDb().lookupObject<volScalarField>("h")
);

createVelocityField(mesh);
volVectorField & U = mesh.lookupObjectRef<volVectorField>("U");

// Init U to something varying
for (int i=0; i< U.size(); i++)
{
U.primitiveFieldRef()[i] = mesh.C()[1];
}

h.boundaryFieldRef()[patch.index()] == 2;
MultiCellSampler sampler
(
patch,
3.0,
"cell",
"Crawling",
true,
false
);
IntegratedReichardtLawOfTheWall law =
IntegratedReichardtLawOfTheWall(0.3, 11, 3, 7.8);

scalar value = law.valueMulticell(sampler, 5, 0.04, 8e-6);
ASSERT_FLOAT_EQ(value, -0.20040621277606402);
}

TEST_F(IntegratedReichardtLawOfTheWallTest, DerivativeSampler)
{
extern argList * mainArgs;
Expand Down
Loading

0 comments on commit 9645bec

Please sign in to comment.