shearStress.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "shearStress.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace functionObjects
38 {
39  defineTypeNameAndDebug(shearStress, 0);
40  addToRunTimeSelectionTable(functionObject, shearStress, dictionary);
41 }
42 }
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 (
49  const word& name,
50  const Time& runTime,
51  const dictionary& dict
52 )
53 :
54  fvMeshFunctionObject(name, runTime, dict),
55  writeLocalObjects(obr_, false),
56  phaseName_(word::null)
57 {
58  read(dict);
59  resetLocalObjectName(IOobject::groupName(type(), phaseName_));
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
64 
66 {}
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
72 (
73  const dictionary& dict
74 )
75 {
78 
79  phaseName_ = dict.lookupOrDefault<word>("phase", word::null);
80 
81  return true;
82 }
83 
84 
86 {
87  const word fieldName(IOobject::groupName(type(), phaseName_));
88 
89  typedef compressibleMomentumTransportModel cmpModel;
90  typedef incompressibleMomentumTransportModel icoModel;
91 
92  const word momentumTransportModelName
93  (
94  IOobject::groupName(momentumTransportModel::typeName, phaseName_)
95  );
96 
97  if (mesh_.foundObject<cmpModel>(momentumTransportModelName))
98  {
99  const cmpModel& model =
100  mesh_.lookupObject<cmpModel>(momentumTransportModelName);
101 
102  return store(fieldName, model.devTau());
103  }
104  else if (mesh_.foundObject<icoModel>(momentumTransportModelName))
105  {
106  const icoModel& model =
107  mesh_.lookupObject<icoModel>(momentumTransportModelName);
108 
109  return store(fieldName, model.devSigma());
110  }
111  else
112  {
114  << "Unable to find compressible turbulence model "
115  << momentumTransportModelName << " in the database"
116  << exit(FatalError);
117 
118  return false;
119  }
120 }
121 
122 
124 {
125  return writeLocalObjects::write();
126 }
127 
128 
129 // ************************************************************************* //
Foam::surfaceFields.
virtual bool write()
Write function.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
shearStress(const word &name, const Time &runTime, const dictionary &)
Construct from Time and dictionary.
Definition: shearStress.C:48
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool execute()
Calculate the shearStress field.
Definition: shearStress.C:85
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
static word groupName(Name name, const word &group)
static const word null
An empty word.
Definition: word.H:77
virtual bool read(const dictionary &)
Read the data.
Definition: shearStress.C:72
defineTypeNameAndDebug(Qdot, 0)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual bool write()
Do nothing.
Definition: shearStress.C:123
FunctionObject base class for managing a list of objects on behalf of the inheriting function object...
virtual bool read(const dictionary &)
Read the list of objects to be written.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
virtual ~shearStress()
Destructor.
Definition: shearStress.C:65
Abstract base class for turbulence models (RAS, LES and laminar).
Abstract base class for turbulence models (RAS, LES and laminar).
Namespace for OpenFOAM.