FreeFOAM The Cross-Platform CFD Toolkit
enstrophy.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  enstrophy
26 
27 Description
28  Calculates and writes the enstrophy of the velocity field U.
29 
30  The -noWrite option just outputs the max/min values without writing the
31  field.
32 
33 Usage
34 
35  - enstrophy [OPTIONS]
36 
37  @param -noWrite \n
38  Suppress output to files.
39 
40  @param -dict <dictionary name>\n
41  Use named dictionary instead of system/controlDict.
42 
43  @param -noZero \n
44  Ignore timestep 0.
45 
46  @param -constant \n
47  Include the constant directory.
48 
49  @param -time <time>\n
50  Apply only to specific time.
51 
52  @param -latestTime \n
53  Only apply to latest time step.
54 
55  @param -case <dir>\n
56  Case directory.
57 
58  @param -parallel \n
59  Run in parallel.
60 
61  @param -help \n
62  Display help message.
63 
64  @param -doc \n
65  Display Doxygen API documentation page for this application.
66 
67  @param -srcDoc \n
68  Display Doxygen source documentation page for this application.
69 
70 \*---------------------------------------------------------------------------*/
71 
72 #include <postCalc/calc.H>
73 #include <finiteVolume/fvc.H>
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
78 {
79  bool writeResults = !args.optionFound("noWrite");
80 
81  IOobject Uheader
82  (
83  "U",
84  runTime.timeName(),
85  mesh,
86  IOobject::MUST_READ
87  );
88 
89  if (Uheader.headerOk())
90  {
91  Info<< " Reading U" << endl;
92  volVectorField U(Uheader, mesh);
93 
94  Info<< " Calculating enstrophy" << endl;
95  volScalarField enstrophy
96  (
97  IOobject
98  (
99  "enstrophy",
100  runTime.timeName(),
101  mesh,
102  IOobject::NO_READ
103  ),
104  0.5*magSqr(fvc::curl(U))
105  );
106 
107  Info<< "enstrophy(U) max/min : "
108  << max(enstrophy).value() << " "
109  << min(enstrophy).value() << endl;
110 
111  if (writeResults)
112  {
113  enstrophy.write();
114  }
115  }
116  else
117  {
118  Info<< " No U" << endl;
119  }
120 
121  Info<< "\nEnd\n" << endl;
122 }
123 
124 
125 // ************************ vim: set sw=4 sts=4 et: ************************ //