wallShearStress: utility replaced by functionObject used with the '-postProcess' option

This commit is contained in:
Henry Weller 2016-06-09 16:05:13 +01:00
parent e175594e9f
commit 4734b1af5b
9 changed files with 48 additions and 262 deletions

View File

@ -1,3 +0,0 @@
wallShearStress.C
EXE = $(FOAM_APPBIN)/wallShearStress

View File

@ -1,23 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lcompressibleTurbulenceModels \
-lincompressibleTransportModels \
-lcompressibleTransportModels \
-lfluidThermophysicalModels \
-lspecie \
-lgenericPatchFields \
-lfiniteVolume \
-lfvOptions \
-lmeshTools

View File

@ -1,211 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM 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.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
wallShearStress
Description
Calculates and reports the turbulent wall shear stress for all patches,
for the specified times.
Compressible modes is automatically selected based on the existence of the
"thermophysicalProperties" dictionary required to construct the
thermodynamics package.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void calcIncompressible
(
const fvMesh& mesh,
const Time& runTime,
const volVectorField& U,
volVectorField& wallShearStress
)
{
#include "createPhi.H"
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::turbulenceModel> model
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
const volSymmTensorField Reff(model->devReff());
volVectorField::Boundary& wallShearStressBf =
wallShearStress.boundaryFieldRef();
forAll(wallShearStressBf, patchi)
{
wallShearStressBf[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<fluidThermo> pThermo(fluidThermo::New(mesh));
fluidThermo& thermo = pThermo();
autoPtr<compressible::turbulenceModel> model
(
compressible::turbulenceModel::New(rho, U, phi, thermo)
);
const volSymmTensorField Reff(model->devRhoReff());
volVectorField::Boundary& wallShearStressBf =
wallShearStress.boundaryFieldRef();
forAll(wallShearStressBf, patchi)
{
wallShearStressBf[patchi] =
(
-mesh.Sf().boundaryField()[patchi]
/mesh.magSf().boundaryField()[patchi]
) & Reff.boundaryField()[patchi];
}
}
int main(int argc, char *argv[])
{
timeSelector::addOptions();
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMesh.H"
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",
sqr(dimLength)/sqr(dimTime),
Zero
)
);
IOobject UHeader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (UHeader.headerOk())
{
Info<< "Reading field U\n" << endl;
volVectorField U(UHeader, mesh);
if
(
IOobject
(
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
)
{
calcCompressible(mesh, runTime, U, wallShearStress);
}
else
{
calcIncompressible(mesh, runTime, U, wallShearStress);
}
}
else
{
Info<< " no U field" << endl;
}
Info<< "Writing wall shear stress to field " << wallShearStress.name()
<< nl << endl;
wallShearStress.write();
}
Info<< "End" << endl;
return 0;
}
// ************************************************************************* //

1
bin/wallShearStress Symbolic link
View File

@ -0,0 +1 @@
supercededByPostProcessOption

View File

@ -0,0 +1,18 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
wallShearStress
{
type wallShearStress;
libs ("libfieldFunctionObjects.so");
executeControl writeTime;
writeControl writeTime;
}
// ************************************************************************* //

View File

@ -52,5 +52,6 @@ MachNo/MachNo.C
turbulenceFields/turbulenceFields.C
yPlus/yPlus.C
wallShearStress/wallShearStress.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects

View File

@ -67,7 +67,6 @@ void Foam::functionObjects::wallShearStress::calcShearStress
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
const polyPatch& pp = mesh.boundaryMesh()[patchi];
vectorField& ssp = shearStress.boundaryFieldRef()[patchi];
const vectorField& Sfp = mesh.Sf().boundaryField()[patchi];
@ -75,21 +74,6 @@ void Foam::functionObjects::wallShearStress::calcShearStress
const symmTensorField& Reffp = Reff.boundaryField()[patchi];
ssp = (-Sfp/magSfp) & Reffp;
vector minSsp = gMin(ssp);
vector maxSsp = gMax(ssp);
if (Pstream::master())
{
file() << mesh.time().value()
<< token::TAB << pp.name()
<< token::TAB << minSsp
<< token::TAB << maxSsp
<< endl;
}
Log << " min/max(" << pp.name() << ") = "
<< minSsp << ", " << maxSsp << endl;
}
}
@ -212,8 +196,6 @@ bool Foam::functionObjects::wallShearStress::execute(const bool postProcess)
typedef compressible::turbulenceModel cmpModel;
typedef incompressible::turbulenceModel icoModel;
writeFiles::write();
const fvMesh& mesh = refCast<const fvMesh>(obr_);
volVectorField& wallShearStress =
@ -222,9 +204,6 @@ bool Foam::functionObjects::wallShearStress::execute(const bool postProcess)
mesh.lookupObject<volVectorField>(type())
);
Log << type() << " " << name() << " output:" << nl;
tmp<volSymmTensorField> Reff;
if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName))
{
@ -260,12 +239,37 @@ bool Foam::functionObjects::wallShearStress::write(const bool postProcess)
const volVectorField& wallShearStress =
obr_.lookupObject<volVectorField>(type());
Log << type() << " " << name() << " output:" << nl
<< " writing field " << wallShearStress.name() << nl
<< endl;
Log << type() << " " << name() << " write:" << nl
<< " writing field " << wallShearStress.name() << endl;
wallShearStress.write();
const fvMesh& mesh = refCast<const fvMesh>(obr_);
const fvPatchList& patches = mesh.boundary();
forAllConstIter(labelHashSet, patchSet_, iter)
{
label patchi = iter.key();
const fvPatch& pp = patches[patchi];
const vectorField& ssp = wallShearStress.boundaryField()[patchi];
vector minSsp = gMin(ssp);
vector maxSsp = gMax(ssp);
if (Pstream::master())
{
file() << mesh.time().value()
<< token::TAB << pp.name()
<< token::TAB << minSsp
<< token::TAB << maxSsp
<< endl;
}
Log << " min/max(" << pp.name() << ") = "
<< minSsp << ", " << maxSsp << endl;
}
return true;
}

View File

@ -1,4 +1,3 @@
wallShearStress/wallShearStress.C
forces/forces.C
forceCoeffs/forceCoeffs.C