FreeFOAM The Cross-Platform CFD Toolkit
sample.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  sample
26 
27 Description
28  Sample field data with a choice of interpolation schemes, sampling options
29  and write formats.
30 
31  Keywords:
32 
33  @param setFormat : set output format, choice of \n
34  - @c xmgr
35  - @c jplot
36  - @c gnuplot
37  - @c raw
38 
39  @param surfaceFormat : surface output format, choice of \n
40  - @c null : suppress output
41  - @c foamFile : separate points, faces and values file
42  - @c dx : DX scalar or vector format
43  - @c vtk : VTK ascii format
44  - @c raw : x y z value format for use with e.g. gnuplot 'splot'.
45  - @c obj : Wavefron stl. Does not contain values!
46  - @c stl : ascii stl. Does not contain values!
47 
48  @param interpolationScheme : interpolation scheme, choice of \n
49  - @c cell : use cell-centre value; constant over cells (default)
50  - @c cellPoint : use cell-centre and vertex values
51  - @c cellPointFace : use cell-centre, vertex and face values. \n
52  -# vertex values determined from neighbouring cell-centre values
53  -# face values determined using the current face interpolation scheme
54  for the field (linear, limitedLinear, etc.)
55 
56  @param fields : list of fields to sample
57 
58  @param sets : list of sets to sample, choice of \n
59  - @c uniform : evenly distributed points on line
60  - @c face : one point per face intersection
61  - @c midPoint : one point per cell, inbetween two face intersections
62  - @c midPointAndFace : combination of face and midPoint
63  - @c curve : specified points, not nessecary on line, uses
64  tracking
65  - @c cloud : specified points, uses findCell
66  .
67  Option axis: how to write point coordinate. Choice of
68  - @c x/y/z: x/y/z coordinate only
69  - @c xyz: three columns
70  (probably does not make sense for anything but raw)
71  - @c distance: distance from start of sampling line (if uses line)
72  or distance from first specified sampling point
73  .
74  Type specific options:
75  - @c uniform, face, midPoint, midPointAndFace : start and end coordinate
76  - @c uniform: extra number of sampling points
77  - @c curve, @c cloud: list of coordinates
78 
79  @param surfaces : list of surfaces to sample, choice of \n
80  - @c plane : values on plane defined by point, normal.
81  - @c patch : values on patch.
82 
83 Usage
84 
85  - sample [OPTION]
86 
87  @param -noZero \n
88  Do not sample the @em 0 directory.
89 
90  @param -case <dir> \n
91  Path to the case directory. Defaults to the
92  current working directory.
93 
94  @param -parallel \n
95  Run in parallel.
96 
97  @param -latestTime \n
98  Only sample the latest time directory.
99 
100  @param -time <time> \n
101  Only sample the @em time directory.
102 
103  @param -constant \n
104  Include the constant directory.
105 
106  @param -help \n
107  Display help message.
108 
109  @param -doc \n
110  Display Doxygen API documentation page for this application.
111 
112  @param -srcDoc \n
113  Display Doxygen source documentation page for this application.
114 
115 Notes
116  Runs in parallel
117 
118 \*---------------------------------------------------------------------------*/
119 
120 #include <OpenFOAM/argList.H>
121 #include <OpenFOAM/timeSelector.H>
122 #include <sampling/IOsampledSets.H>
124 
125 using namespace Foam;
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 // Main program:
129 
130 int main(int argc, char *argv[])
131 {
133  #include <OpenFOAM/addRegionOption.H>
134  argList::validOptions.insert("dict", "dictionary name");
135 
136  #include <OpenFOAM/setRootCase.H>
137  #include <OpenFOAM/createTime.H>
139  #include <OpenFOAM/createNamedMesh.H>
140 
141  word sampleDict = "sampleDict";
142  if (args.optionFound("dict"))
143  {
144  sampleDict = args.option("dict");
145  Info<< "Reading sample dictionary: " << sampleDict << nl << endl;
146  }
147 
148  IOsampledSets sSets
149  (
150  sampledSets::typeName,
151  mesh,
152  sampleDict,
154  true
155  );
156 
157  IOsampledSurfaces sSurfs
158  (
159  sampledSurfaces::typeName,
160  mesh,
161  sampleDict,
163  true
164  );
165 
166  forAll(timeDirs, timeI)
167  {
168  runTime.setTime(timeDirs[timeI], timeI);
169  Info<< "Time = " << runTime.timeName() << endl;
170 
171  // Handle geometry/topology changes
173 
174  sSets.readUpdate(state);
175  sSurfs.readUpdate(state);
176 
177  sSets.write();
178  sSurfs.write();
179 
180  Info<< endl;
181  }
182 
183  Info<< "End\n" << endl;
184 
185  return 0;
186 }
187 
188 
189 // ************************ vim: set sw=4 sts=4 et: ************************ //