FreeFOAM The Cross-Platform CFD Toolkit
wallHeatFlux.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) 1991-2010 OpenCFD Ltd.
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  wallHeatFlux
26 
27 Description
28  Calculates and writes the heat flux for all patches as the boundary field
29  of a volScalarField and also prints the integrated flux for all wall
30  patches.
31 
32 Usage
33 
34  - wallHeatFlux [OPTIONS]
35 
36  @param -noZero \n
37  Ignore timestep 0.
38 
39  @param -constant \n
40  Include the constant directory.
41 
42  @param -time <time>\n
43  Apply only to specific time.
44 
45  @param -latestTime \n
46  Only apply to latest time step.
47 
48  @param -case <dir>\n
49  Case directory.
50 
51  @param -parallel \n
52  Run in parallel.
53 
54  @param -help \n
55  Display help message.
56 
57  @param -doc \n
58  Display Doxygen API documentation page for this application.
59 
60  @param -srcDoc \n
61  Display Doxygen source documentation page for this application.
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #include <finiteVolume/fvCFD.H>
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 int main(int argc, char *argv[])
73 {
74  timeSelector::addOptions();
75  #include <OpenFOAM/setRootCase.H>
76  #include <OpenFOAM/createTime.H>
77  instantList timeDirs = timeSelector::select0(runTime, args);
78  #include <OpenFOAM/createMesh.H>
79 
80  forAll(timeDirs, timeI)
81  {
82  runTime.setTime(timeDirs[timeI], timeI);
83  Info<< "Time = " << runTime.timeName() << endl;
84  mesh.readUpdate();
85 
86  #include "createFields.H"
87 
88  surfaceScalarField heatFlux =
89  fvc::interpolate(RASModel->alphaEff())*fvc::snGrad(h);
90 
91  const surfaceScalarField::GeometricBoundaryField& patchHeatFlux =
92  heatFlux.boundaryField();
93 
94  Info<< "\nWall heat fluxes [W]" << endl;
95  forAll(patchHeatFlux, patchi)
96  {
97  if (isA<wallFvPatch>(mesh.boundary()[patchi]))
98  {
99  Info<< mesh.boundary()[patchi].name()
100  << " "
101  << sum
102  (
104  *patchHeatFlux[patchi]
105  )
106  << endl;
107  }
108  }
109  Info<< endl;
110 
111  volScalarField wallHeatFlux
112  (
113  IOobject
114  (
115  "wallHeatFlux",
116  runTime.timeName(),
117  mesh
118  ),
119  mesh,
120  dimensionedScalar("wallHeatFlux", heatFlux.dimensions(), 0.0)
121  );
122 
123  forAll(wallHeatFlux.boundaryField(), patchi)
124  {
125  wallHeatFlux.boundaryField()[patchi] = patchHeatFlux[patchi];
126  }
127 
128  wallHeatFlux.write();
129  }
130 
131  Info<< "End" << endl;
132 
133  return 0;
134 }
135 
136 // ************************ vim: set sw=4 sts=4 et: ************************ //