FreeFOAM The Cross-Platform CFD Toolkit
writeCellCentres.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  writeCellCentres
26 
27 Description
28  Write the three components of the cell centres as volScalarFields so
29  they can be used in postprocessing in thresholding.
30 
31 Usage
32 
33  - writeCellCentres [OPTIONS]
34 
35  @param -noZero \n
36  Ignore timestep 0.
37 
38  @param -constant \n
39  Include the constant directory.
40 
41  @param -time <time>\n
42  Apply only to specific time.
43 
44  @param -latestTime \n
45  Only apply to latest time step.
46 
47  @param -case <dir>\n
48  Case directory.
49 
50  @param -parallel \n
51  Run in parallel.
52 
53  @param -help \n
54  Display help message.
55 
56  @param -doc \n
57  Display Doxygen API documentation page for this application.
58 
59  @param -srcDoc \n
60  Display Doxygen source documentation page for this application.
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #include <OpenFOAM/argList.H>
65 #include <OpenFOAM/timeSelector.H>
66 #include <OpenFOAM/Time.H>
67 #include <finiteVolume/fvMesh.H>
68 #include <OpenFOAM/vectorIOField.H>
69 #include <finiteVolume/volFields.H>
70 
71 using namespace Foam;
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 // Main program:
76 
77 int main(int argc, char *argv[])
78 {
80 
81 # include <OpenFOAM/setRootCase.H>
82 # include <OpenFOAM/createTime.H>
83 
85 
86 # include <OpenFOAM/createMesh.H>
87 
88  forAll(timeDirs, timeI)
89  {
90  runTime.setTime(timeDirs[timeI], timeI);
91 
92  Info<< "Time = " << runTime.timeName() << endl;
93 
94  // Check for new mesh
95  mesh.readUpdate();
96 
98  (
99  IOobject
100  (
101  "cellCentres",
102  runTime.timeName(),
103  mesh,
106  ),
107  mesh.C()
108  );
109 
110  // Info<< "Writing cellCentre positions to " << cc.name() << " in "
111  // << runTime.timeName() << endl;
112  //
113  // cc.write();
114 
115  Info<< "Writing components of cellCentre positions to volScalarFields"
116  << " ccx, ccy, ccz in " << runTime.timeName() << endl;
117 
118  for (direction i=0; i<vector::nComponents; i++)
119  {
120  volScalarField cci
121  (
122  IOobject
123  (
124  "cc" + word(vector::componentNames[i]),
125  runTime.timeName(),
126  mesh,
129  ),
130  mesh.C().component(i)
131  );
132 
133  cci.write();
134  }
135  }
136 
137  Info<< "\nEnd" << endl;
138 
139  return 0;
140 }
141 
142 
143 // ************************ vim: set sw=4 sts=4 et: ************************ //