wallShearStressWriter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  Copyright : (C) 2011 Symscape
3  Website : www.symscape.com
4 -------------------------------------------------------------------------------
5 License
6  This file is part of OpenFOAM.
7 
8  OpenFOAM is free software: you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
14  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16  for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
20 
21 \*---------------------------------------------------------------------------*/
22 
23 #include "wallShearStressWriter.H"
24 #include "fvCFD.H"
25 #include "dictionary.H"
26 #include "Time.H"
27 #include "wallFvPatch.H"
30 
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37  const word wallShearStressWriter::FIELD_NAME("wallShearStress");
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
45 {
46  if (rhoName_ == "rhoInf")
47  {
48  const fvMesh& mesh = refCast<const fvMesh>(obr);
49 
50  return tmp<volScalarField>
51  (
52  new volScalarField
53  (
54  IOobject
55  (
56  "rho",
57  mesh.time().timeName(),
58  mesh
59  ),
60  mesh,
62  )
63  );
64  }
65  else
66  {
67  return (obr.lookupObject<volScalarField>(rhoName_));
68  }
69 }
70 
71 
74  bool & foundField) const
75 {
76  typedef incompressibleTurbulenceModel iTModel;
77  typedef compressibleTurbulenceModel cTModel;
78 
80  {
81  const iTModel& tModel
83 
84  return rho(obr)*tModel.devReff();
85  }
86  else if (obr.foundObject<cTModel>(turbulenceModel::propertiesName))
87  {
88  const cTModel& tModel
90 
91  return tModel.devRhoReff();
92  }
93 
94  foundField = false;
95  return volSymmTensorField::null();
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
100 
103  rhoName_("rho"),
104  rhoRef_(1.)
105 {
106  // Optional entry rhoName
107  dict.readIfPresent("rhoName", rhoName_);
108 
109  // Reference density needed for incompressible calculations
110  dict.readIfPresent("rhoInf", rhoRef_);
111 }
112 
113 
114 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
115 
117 {
118  const fvMesh& mesh = refCast<const fvMesh>(obr);
119 
121  (
122  IOobject
123  (
124  FIELD_NAME,
125  obr.time().timeName(),
126  mesh,
129  ),
130  mesh,
132  (
133  FIELD_NAME,
134  //tdevRhoReff().dimensions() / tmagSf().dimensions(),
137  )
138  );
139 
140  bool foundField = true;
141  tmp<volSymmTensorField> tdevRhoReff = devRhoReff(obr, foundField);
142 
143  if (foundField) {
144  const volSymmTensorField::GeometricBoundaryField& devRhoReffb =
145  tdevRhoReff().boundaryField();
146 
149  tmagSf().boundaryField();
150 
152  wallShearStress.boundaryField();
154  mesh.Sf().boundaryField();
155  const fvPatchList& patches = mesh.boundary();
156 
158  {
159  const fvPatch& currPatch = patches[patchi];
160 
161  if (isA<wallFvPatch>(currPatch))
162  {
163  vectorField& wssp = wShearStressb[patchi];
164  wssp =
165  (Sfb[patchi]/magSfb[patchi]) & devRhoReffb[patchi];
166 
167  writeStatistics(wssp, currPatch.name(), FIELD_NAME);
168  }
169  }
170  }
171 
173 }
174 
175 
176 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
compressibleTurbulenceModel.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::dimDensity
const dimensionSet dimDensity
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::wallShearStressWriter::rhoName_
word rhoName_
Name of density field (optional)
Definition: wallShearStressWriter.H:57
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:117
Foam::wallShearStress::write
virtual void write()
Calculate the wallShearStress and write.
Definition: wallShearStress.C:279
Foam::turbulenceModel::propertiesName
static const word propertiesName
Default name of the turbulence properties dictionary.
Definition: turbulenceModel.H:97
wallFvPatch.H
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
wallShearStressWriter.H
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::fvPatch::name
const word & name() const
Return name.
Definition: fvPatch.H:149
Foam::fvMesh::magSf
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
Definition: fvMeshGeometry.C:358
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
incompressibleTurbulenceModel.H
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::derivedFieldWriter
Basis for writers used in derivedFields e.g., wallShearStressWriter.
Definition: derivedFieldWriter.H:49
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::wallShearStressWriter::write
virtual void write(const objectRegistry &obr)
Write derived field.
Definition: wallShearStressWriter.C:116
Foam::wallShearStressWriter::rhoRef_
scalar rhoRef_
Reference density needed for incompressible calculations.
Definition: wallShearStressWriter.H:60
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::wallShearStressWriter
Write wallShearStress field.
Definition: wallShearStressWriter.H:49
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam::fvMesh::Sf
const surfaceVectorField & Sf() const
Return cell face area vectors.
Definition: fvMeshGeometry.C:347
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::wallShearStressWriter::wallShearStressWriter
wallShearStressWriter(const dictionary &dict)
Definition: wallShearStressWriter.C:101
rho
rho
Definition: pEqn.H:3
Foam::fvMesh::boundary
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:550
Foam::objectRegistry::foundObject
bool foundObject(const word &name) const
Is the named Type found?
Definition: objectRegistryTemplates.C:142
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::wallShearStressWriter::devRhoReff
tmp< volSymmTensorField > devRhoReff(const objectRegistry &obr, bool &foundField) const
Return the effective viscous stress (laminar + turbulent).
Definition: wallShearStressWriter.C:73
Foam::wallShearStressWriter::FIELD_NAME
static const word FIELD_NAME
Field file name.
Definition: wallShearStressWriter.H:76
Foam::Time::timeName
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
patchi
label patchi
Definition: getPatchFieldScalar.H:1
dictionary.H
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:243
fvCFD.H
patches
patches[0]
Definition: createSingleCellMesh.H:36
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type.
Definition: objectRegistryTemplates.C:165
Foam::GeometricField::null
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
Definition: GeometricFieldI.H:30
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::wallShearStressWriter::rho
tmp< Foam::volScalarField > rho(const objectRegistry &obr) const
Return rho field if it exists or rhoRef_ for incompressible rho.
Definition: wallShearStressWriter.C:44
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::GeometricField::GeometricBoundaryField
Definition: GeometricField.H:105
Foam::incompressibleTurbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: incompressibleTurbulenceModel.H:52
Foam::compressibleTurbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: compressibleTurbulenceModel.H:51
Foam::wallShearStress
This function object evaluates and outputs the shear stress at wall patches. The result is written as...
Definition: wallShearStress.H:131