mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
wallShearStress: utility replaced by functionObject used with the '-postProcess' option
This commit is contained in:
@ -52,5 +52,6 @@ MachNo/MachNo.C
|
||||
|
||||
turbulenceFields/turbulenceFields.C
|
||||
yPlus/yPlus.C
|
||||
wallShearStress/wallShearStress.C
|
||||
|
||||
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects
|
||||
|
||||
277
src/functionObjects/field/wallShearStress/wallShearStress.C
Normal file
277
src/functionObjects/field/wallShearStress/wallShearStress.C
Normal file
@ -0,0 +1,277 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "wallShearStress.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "turbulentTransportModel.H"
|
||||
#include "turbulentFluidThermoModel.H"
|
||||
#include "wallPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(wallShearStress, 0);
|
||||
addToRunTimeSelectionTable(functionObject, wallShearStress, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::wallShearStress::writeFileHeader(const label i)
|
||||
{
|
||||
// Add headers to output data
|
||||
writeHeader(file(), "Wall shear stress");
|
||||
writeCommented(file(), "Time");
|
||||
writeTabbed(file(), "patch");
|
||||
writeTabbed(file(), "min");
|
||||
writeTabbed(file(), "max");
|
||||
file() << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::wallShearStress::calcShearStress
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volSymmTensorField& Reff,
|
||||
volVectorField& shearStress
|
||||
)
|
||||
{
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
|
||||
vectorField& ssp = shearStress.boundaryFieldRef()[patchi];
|
||||
const vectorField& Sfp = mesh.Sf().boundaryField()[patchi];
|
||||
const scalarField& magSfp = mesh.magSf().boundaryField()[patchi];
|
||||
const symmTensorField& Reffp = Reff.boundaryField()[patchi];
|
||||
|
||||
ssp = (-Sfp/magSfp) & Reffp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::wallShearStress::wallShearStress
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
writeFiles(name, runTime, dict, name),
|
||||
patchSet_()
|
||||
{
|
||||
if (!isA<fvMesh>(obr_))
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "objectRegistry is not an fvMesh" << exit(FatalError);
|
||||
}
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField* wallShearStressPtr
|
||||
(
|
||||
new volVectorField
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
type(),
|
||||
mesh.time().timeName(),
|
||||
mesh,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
mesh,
|
||||
dimensionedVector
|
||||
(
|
||||
"0",
|
||||
sqr(dimLength)/sqr(dimTime),
|
||||
Zero
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
mesh.objectRegistry::store(wallShearStressPtr);
|
||||
|
||||
read(dict);
|
||||
resetName(typeName);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::wallShearStress::~wallShearStress()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::wallShearStress::read(const dictionary& dict)
|
||||
{
|
||||
writeFiles::read(dict);
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
|
||||
patchSet_ =
|
||||
mesh.boundaryMesh().patchSet
|
||||
(
|
||||
wordReList(dict.lookupOrDefault("patches", wordReList()))
|
||||
);
|
||||
|
||||
Info<< type() << " " << name() << ":" << nl;
|
||||
|
||||
if (patchSet_.empty())
|
||||
{
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<wallPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
patchSet_.insert(patchi);
|
||||
}
|
||||
}
|
||||
|
||||
Info<< " processing all wall patches" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " processing wall patches: " << nl;
|
||||
labelHashSet filteredPatchSet;
|
||||
forAllConstIter(labelHashSet, patchSet_, iter)
|
||||
{
|
||||
label patchi = iter.key();
|
||||
if (isA<wallPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
filteredPatchSet.insert(patchi);
|
||||
Info<< " " << pbm[patchi].name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Requested wall shear stress on non-wall boundary "
|
||||
<< "type patch: " << pbm[patchi].name() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
Info<< endl;
|
||||
|
||||
patchSet_ = filteredPatchSet;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::wallShearStress::execute(const bool postProcess)
|
||||
{
|
||||
typedef compressible::turbulenceModel cmpModel;
|
||||
typedef incompressible::turbulenceModel icoModel;
|
||||
|
||||
const fvMesh& mesh = refCast<const fvMesh>(obr_);
|
||||
|
||||
volVectorField& wallShearStress =
|
||||
const_cast<volVectorField&>
|
||||
(
|
||||
mesh.lookupObject<volVectorField>(type())
|
||||
);
|
||||
|
||||
tmp<volSymmTensorField> Reff;
|
||||
if (mesh.foundObject<cmpModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const cmpModel& model =
|
||||
mesh.lookupObject<cmpModel>(turbulenceModel::propertiesName);
|
||||
|
||||
Reff = model.devRhoReff();
|
||||
}
|
||||
else if (mesh.foundObject<icoModel>(turbulenceModel::propertiesName))
|
||||
{
|
||||
const icoModel& model =
|
||||
mesh.lookupObject<icoModel>(turbulenceModel::propertiesName);
|
||||
|
||||
Reff = model.devReff();
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unable to find turbulence model in the "
|
||||
<< "database" << exit(FatalError);
|
||||
}
|
||||
|
||||
calcShearStress(mesh, Reff(), wallShearStress);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::wallShearStress::write(const bool postProcess)
|
||||
{
|
||||
writeFiles::write();
|
||||
|
||||
const volVectorField& wallShearStress =
|
||||
obr_.lookupObject<volVectorField>(type());
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
180
src/functionObjects/field/wallShearStress/wallShearStress.H
Normal file
180
src/functionObjects/field/wallShearStress/wallShearStress.H
Normal file
@ -0,0 +1,180 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013-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/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::wallShearStress
|
||||
|
||||
Group
|
||||
grpForcesFunctionObjects
|
||||
|
||||
Description
|
||||
This function object evaluates and outputs the shear stress at wall
|
||||
patches. The result is written as a volVectorField to time directories as
|
||||
field 'wallShearStress'
|
||||
|
||||
\f[
|
||||
Stress = R \dot n
|
||||
\f]
|
||||
|
||||
where
|
||||
\vartable
|
||||
R | stress tensor
|
||||
n | patch normal vector (into the domain)
|
||||
\endvartable
|
||||
|
||||
The shear stress (symmetrical) tensor field is retrieved from the
|
||||
turbulence model. All wall patches are included by default; to restrict
|
||||
the calculation to certain patches, use the optional 'patches' entry.
|
||||
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
wallShearStress1
|
||||
{
|
||||
type wallShearStress;
|
||||
libs ("libutilityFunctionObjects.so");
|
||||
...
|
||||
patches (".*Wall");
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
\heading Function object usage
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: wallShearStress | yes |
|
||||
patches | list of patches to process | no | all wall patches
|
||||
\endtable
|
||||
|
||||
SeeAlso
|
||||
Foam::functionObject
|
||||
Foam::functionObjects::writeFiles
|
||||
Foam::functionObjects::pressureTools
|
||||
Foam::functionObjects::timeControl
|
||||
|
||||
SourceFiles
|
||||
wallShearStress.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_wallShearStress_H
|
||||
#define functionObjects_wallShearStress_H
|
||||
|
||||
#include "writeFiles.H"
|
||||
#include "volFieldsFwd.H"
|
||||
#include "HashSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
class fvMesh;
|
||||
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class wallShearStress Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class wallShearStress
|
||||
:
|
||||
public writeFiles
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Optional list of patches to process
|
||||
labelHashSet patchSet_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- File header information
|
||||
virtual void writeFileHeader(const label i);
|
||||
|
||||
//- Calculate the shear stress
|
||||
void calcShearStress
|
||||
(
|
||||
const fvMesh& mesh,
|
||||
const volSymmTensorField& Reff,
|
||||
volVectorField& shearStress
|
||||
);
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
wallShearStress(const wallShearStress&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const wallShearStress&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("wallShearStress");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
wallShearStress
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~wallShearStress();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the wallShearStress data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Calculate the wall shear-stress
|
||||
virtual bool execute(const bool postProcess = false);
|
||||
|
||||
//- Write the wall shear-stress
|
||||
virtual bool write(const bool postProcess = false);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user