2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / O peration | Version: 3.2
|
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
Application
|
|
|
|
wallShearStress
|
|
|
|
|
|
|
|
Description
|
2014-10-02 16:23:22 +00:00
|
|
|
Calculates and reports wall shear stress for all patches, for the
|
|
|
|
specified times when using RAS turbulence models.
|
|
|
|
|
|
|
|
Default behaviour assumes operating in incompressible mode.
|
|
|
|
Use the -compressible option for compressible RAS cases.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "fvCFD.H"
|
|
|
|
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
|
2014-10-02 16:23:22 +00:00
|
|
|
#include "incompressible/RAS/RASModel/RASModel.H"
|
|
|
|
|
|
|
|
#include "basicPsiThermo.H"
|
|
|
|
#include "compressible/RAS/RASModel/RASModel.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
2014-10-02 16:23:22 +00:00
|
|
|
void calcIncompressible
|
|
|
|
(
|
|
|
|
const fvMesh& mesh,
|
|
|
|
const Time& runTime,
|
|
|
|
const volVectorField& U,
|
|
|
|
volVectorField& wallShearStress
|
|
|
|
)
|
|
|
|
{
|
|
|
|
#include "createPhi.H"
|
|
|
|
|
|
|
|
singlePhaseTransportModel laminarTransport(U, phi);
|
|
|
|
|
|
|
|
autoPtr<incompressible::RASModel> model
|
|
|
|
(
|
|
|
|
incompressible::RASModel::New(U, phi, laminarTransport)
|
|
|
|
);
|
|
|
|
|
|
|
|
const volSymmTensorField Reff(model->devReff());
|
|
|
|
|
|
|
|
forAll(wallShearStress.boundaryField(), patchI)
|
|
|
|
{
|
|
|
|
wallShearStress.boundaryField()[patchI] =
|
|
|
|
(
|
|
|
|
-mesh.Sf().boundaryField()[patchI]
|
|
|
|
/mesh.magSf().boundaryField()[patchI]
|
|
|
|
) & Reff.boundaryField()[patchI];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void calcCompressible
|
|
|
|
(
|
|
|
|
const fvMesh& mesh,
|
|
|
|
const Time& runTime,
|
|
|
|
const volVectorField& U,
|
|
|
|
volVectorField& wallShearStress
|
|
|
|
)
|
|
|
|
{
|
|
|
|
IOobject rhoHeader
|
|
|
|
(
|
|
|
|
"rho",
|
|
|
|
runTime.timeName(),
|
|
|
|
mesh,
|
|
|
|
IOobject::MUST_READ,
|
|
|
|
IOobject::NO_WRITE
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!rhoHeader.headerOk())
|
|
|
|
{
|
|
|
|
Info<< " no rho field" << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Info<< "Reading field rho\n" << endl;
|
|
|
|
volScalarField rho(rhoHeader, mesh);
|
|
|
|
|
|
|
|
#include "compressibleCreatePhi.H"
|
|
|
|
|
|
|
|
autoPtr<basicPsiThermo> pThermo
|
|
|
|
(
|
|
|
|
basicPsiThermo::New(mesh)
|
|
|
|
);
|
|
|
|
basicPsiThermo& thermo = pThermo();
|
|
|
|
|
|
|
|
autoPtr<compressible::RASModel> model
|
|
|
|
(
|
|
|
|
compressible::RASModel::New
|
|
|
|
(
|
|
|
|
rho,
|
|
|
|
U,
|
|
|
|
phi,
|
|
|
|
thermo
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
const volSymmTensorField Reff(model->devRhoReff());
|
|
|
|
|
|
|
|
forAll(wallShearStress.boundaryField(), patchI)
|
|
|
|
{
|
|
|
|
wallShearStress.boundaryField()[patchI] =
|
|
|
|
(
|
|
|
|
-mesh.Sf().boundaryField()[patchI]
|
|
|
|
/mesh.magSf().boundaryField()[patchI]
|
|
|
|
) & Reff.boundaryField()[patchI];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
timeSelector::addOptions();
|
2014-10-02 16:23:22 +00:00
|
|
|
|
|
|
|
#include "addRegionOption.H"
|
|
|
|
|
|
|
|
argList::validOptions.insert("compressible","");
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
#include "setRootCase.H"
|
2010-08-25 21:42:57 +00:00
|
|
|
#include "createTime.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
2014-10-02 16:23:22 +00:00
|
|
|
#include "createNamedMesh.H"
|
|
|
|
|
|
|
|
bool compressible = args.optionFound("compressible");
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
forAll(timeDirs, timeI)
|
|
|
|
{
|
|
|
|
runTime.setTime(timeDirs[timeI], timeI);
|
|
|
|
Info<< "Time = " << runTime.timeName() << endl;
|
|
|
|
mesh.readUpdate();
|
|
|
|
|
|
|
|
volVectorField wallShearStress
|
|
|
|
(
|
|
|
|
IOobject
|
|
|
|
(
|
|
|
|
"wallShearStress",
|
|
|
|
runTime.timeName(),
|
|
|
|
mesh,
|
|
|
|
IOobject::NO_READ,
|
|
|
|
IOobject::AUTO_WRITE
|
|
|
|
),
|
|
|
|
mesh,
|
|
|
|
dimensionedVector
|
|
|
|
(
|
|
|
|
"wallShearStress",
|
2014-10-02 16:23:22 +00:00
|
|
|
sqr(dimLength)/sqr(dimTime),
|
2010-05-12 13:27:55 +00:00
|
|
|
vector::zero
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2014-10-02 16:23:22 +00:00
|
|
|
IOobject UHeader
|
|
|
|
(
|
|
|
|
"U",
|
|
|
|
runTime.timeName(),
|
|
|
|
mesh,
|
|
|
|
IOobject::MUST_READ,
|
|
|
|
IOobject::NO_WRITE
|
|
|
|
);
|
|
|
|
|
|
|
|
if (UHeader.headerOk())
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2014-10-02 16:23:22 +00:00
|
|
|
Info<< "Reading field U\n" << endl;
|
|
|
|
volVectorField U(UHeader, mesh);
|
|
|
|
|
|
|
|
if (compressible)
|
|
|
|
{
|
|
|
|
calcCompressible(mesh, runTime, U, wallShearStress);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
calcIncompressible(mesh, runTime, U, wallShearStress);
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
2014-10-02 16:23:22 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Info<< " no U field" << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
Info<< "Writing wall shear stress to field " << wallShearStress.name()
|
|
|
|
<< nl << endl;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
wallShearStress.write();
|
|
|
|
}
|
|
|
|
|
|
|
|
Info<< "End" << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|