wallGradU.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 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 Application
25  wallGradU
26 
27 Description
28  Calculates and writes the gradient of U at the wall.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "fvCFD.H"
33 #include "wallFvPatch.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 int main(int argc, char *argv[])
38 {
39  timeSelector::addOptions();
40  #include "addRegionOption.H"
41 
42  #include "setRootCase.H"
43  #include "createTime.H"
44 
45  instantList timeDirs = timeSelector::select0(runTime, args);
46 
47  #include "createNamedMesh.H"
48 
49  forAll(timeDirs, timeI)
50  {
51  runTime.setTime(timeDirs[timeI], timeI);
52  Info<< "Time = " << runTime.timeName() << endl;
53 
54  IOobject Uheader
55  (
56  "U",
57  runTime.timeName(),
58  mesh,
59  IOobject::MUST_READ
60  );
61 
62  // Check U exists
63  if (Uheader.headerOk())
64  {
65  mesh.readUpdate();
66 
67  Info<< " Reading U" << endl;
68  volVectorField U(Uheader, mesh);
69 
70  Info<< " Calculating wallGradU" << endl;
71 
72  volVectorField wallGradU
73  (
74  IOobject
75  (
76  "wallGradU",
77  runTime.timeName(),
78  mesh,
79  IOobject::NO_READ,
80  IOobject::AUTO_WRITE
81  ),
82  mesh,
84  (
85  "wallGradU",
86  U.dimensions()/dimLength,
87  vector::zero
88  )
89  );
90 
91  const fvPatchList& patches = mesh.boundary();
92 
93  forAll(wallGradU.boundaryField(), patchi)
94  {
95  const fvPatch& currPatch = patches[patchi];
96 
97  if (isA<wallFvPatch>(currPatch))
98  {
99  wallGradU.boundaryField()[patchi] =
100  -U.boundaryField()[patchi].snGrad();
101  }
102  }
103 
104  wallGradU.write();
105  }
106  else
107  {
108  Info<< " No U" << endl;
109  }
110  }
111 
112  Info<< "End" << endl;
113 
114  return 0;
115 }
116 
117 
118 // ************************************************************************* //
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
wallFvPatch.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:42
U
U
Definition: pEqn.H:46
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:48
Foam::fvPatchList
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:45
Foam::Info
messageStream Info
addRegionOption.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
createNamedMesh.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:55
setRootCase.H
timeDirs
static instantList timeDirs
Definition: globalFoam.H:44
patchi
label patchi
Definition: getPatchFieldScalar.H:1
createTime.H
fvCFD.H
patches
patches[0]
Definition: createSingleCellMesh.H:36
args
Foam::argList args(argc, argv)