diff --git a/etc/caseDicts/postProcessing/fields/shearStress b/etc/caseDicts/postProcessing/fields/shearStress new file mode 100644 index 0000000000..f452eca42d --- /dev/null +++ b/etc/caseDicts/postProcessing/fields/shearStress @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +------------------------------------------------------------------------------- +Description + Calculates the shear stress, outputting the data as a volSymmTensorField. + +\*---------------------------------------------------------------------------*/ + +type shearStress; +libs ("libfieldFunctionObjects.so"); + +executeControl writeTime; +writeControl writeTime; + +// ************************************************************************* // diff --git a/src/functionObjects/field/Make/files b/src/functionObjects/field/Make/files index 2b950187e2..e9aa3d4b7c 100644 --- a/src/functionObjects/field/Make/files +++ b/src/functionObjects/field/Make/files @@ -47,6 +47,7 @@ PecletNo/PecletNo.C blendingFactor/blendingFactor.C pressure/pressure.C MachNo/MachNo.C +shearStress/shearStress.C turbulenceFields/turbulenceFields.C yPlus/yPlus.C diff --git a/src/functionObjects/field/shearStress/shearStress.C b/src/functionObjects/field/shearStress/shearStress.C new file mode 100644 index 0000000000..7221bbfe97 --- /dev/null +++ b/src/functionObjects/field/shearStress/shearStress.C @@ -0,0 +1,123 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 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 . + +\*---------------------------------------------------------------------------*/ + +#include "shearStress.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "turbulentTransportModel.H" +#include "turbulentFluidThermoModel.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + defineTypeNameAndDebug(shearStress, 0); + addToRunTimeSelectionTable(functionObject, shearStress, dictionary); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::functionObjects::shearStress::shearStress +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + writeLocalObjects(obr_, false), + phaseName_(word::null) +{ + read(dict); + resetLocalObjectName(IOobject::groupName(type(), phaseName_)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::functionObjects::shearStress::~shearStress() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionObjects::shearStress::read +( + const dictionary& dict +) +{ + fvMeshFunctionObject::read(dict); + writeLocalObjects::read(dict); + + phaseName_ = dict.lookupOrDefault("phase", word::null); + + return true; +} + + +bool Foam::functionObjects::shearStress::execute() +{ + const word fieldName(IOobject::groupName(type(), phaseName_)); + + typedef compressible::turbulenceModel cmpModel; + typedef incompressible::turbulenceModel icoModel; + + if (mesh_.foundObject(turbulenceModel::propertiesName)) + { + const cmpModel& model = + mesh_.lookupObject(turbulenceModel::propertiesName); + + return store(fieldName, model.devRhoReff()); + } + else if (mesh_.foundObject(turbulenceModel::propertiesName)) + { + const icoModel& model = + mesh_.lookupObject(turbulenceModel::propertiesName); + + return store(fieldName, model.devReff()); + } + else + { + FatalErrorInFunction + << "Unable to find turbulence model in the " + << "database" << exit(FatalError); + + return false; + } +} + + +bool Foam::functionObjects::shearStress::write() +{ + return writeLocalObjects::write(); +} + + +// ************************************************************************* // diff --git a/src/functionObjects/field/shearStress/shearStress.H b/src/functionObjects/field/shearStress/shearStress.H new file mode 100644 index 0000000000..361c395388 --- /dev/null +++ b/src/functionObjects/field/shearStress/shearStress.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2020 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 . + +Class + Foam::functionObjects::shearStress + +Description + Calculates and writes the shear-stress as the volSymmTensorField field + 'shearStress'. + +See also + Foam::functionObjects::fieldExpression + Foam::functionObjects::fvMeshFunctionObject + +SourceFiles + shearStress.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_shearStress_H +#define functionObjects_shearStress_H + +#include "fieldExpression.H" +#include "writeLocalObjects.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class shearStress Declaration +\*---------------------------------------------------------------------------*/ + +class shearStress +: + public fvMeshFunctionObject, + public writeLocalObjects +{ + // Private Data + + //- The name of the phase + word phaseName_; + + +public: + + //- Runtime type information + TypeName("shearStress"); + + + // Constructors + + //- Construct from Time and dictionary + shearStress + ( + const word& name, + const Time& runTime, + const dictionary& + ); + + + //- Destructor + virtual ~shearStress(); + + + // Member Functions + + //- Read the data + virtual bool read(const dictionary&); + + //- Calculate the shearStress field + virtual bool execute(); + + //- Do nothing + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //