probes.H
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-2014 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 Class
25  Foam::probes
26 
27 Group
28  grpFunctionObjects
29 
30 Description
31  Set of locations to sample.
32 
33  Call write() to sample and write files.
34 
35 SourceFiles
36  probes.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef probes_H
41 #define probes_H
42 
43 #include "HashPtrTable.H"
44 #include "OFstream.H"
45 #include "polyMesh.H"
46 #include "pointField.H"
47 #include "volFieldsFwd.H"
48 #include "surfaceFieldsFwd.H"
49 #include "surfaceMesh.H"
50 #include "wordReList.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward declaration of classes
58 class objectRegistry;
59 class dictionary;
60 class fvMesh;
61 class mapPolyMesh;
62 
63 /*---------------------------------------------------------------------------*\
64  Class probes Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class probes
68 :
69  public pointField
70 {
71 protected:
72 
73  // Protected classes
74 
75  //- Class used for grouping field types
76  template<class Type>
77  class fieldGroup
78  :
79  public DynamicList<word>
80  {
81  public:
82  //- Construct null
84  :
85  DynamicList<word>(0)
86  {}
87  };
88 
89 
90  // Private data
91 
92  //- Name of this set of probes,
93  // Also used as the name of the probes directory.
95 
96  //- Const reference to fvMesh
97  const fvMesh& mesh_;
98 
99  //- Load fields from files (not from objectRegistry)
101 
102 
103  // Read from dictonary
104 
105  //- Names of fields to probe
107 
108  //- Fixed locations, default = yes
109  // Note: set to false for moving mesh calations where locations
110  // should move with the mesh
112 
113  //- Interpolation scheme name
116 
117 
118  // Calculated
119 
120  //- Categorized scalar/vector/tensor vol fields
126 
127  //- Categorized scalar/vector/tensor surf fields
133 
134  // Cells to be probed (obtained from the locations)
136 
137  // Faces to be probed
139 
140  //- Current open files
142 
143 
144  // Private Member Functions
145 
146  //- Clear old field groups
147  void clearFieldGroups();
148 
149  //- Append fieldName to the appropriate group
150  label appendFieldGroup(const word& fieldName, const word& fieldType);
151 
152  //- Classify field types, returns the number of fields
153  label classifyFields();
154 
155  //- Find cells and faces containing probes
156  virtual void findElements(const fvMesh&);
157 
158  //- Classify field type and Open/close file streams,
159  // returns number of fields to sample
160  label prepare();
161 
162 
163 private:
164 
165  //- Sample and write a particular volume field
166  template<class Type>
167  void sampleAndWrite
168  (
170  );
171 
172 
173  //- Sample and write a particular surface field
174  template<class Type>
175  void sampleAndWrite
176  (
178  );
179 
180  //- Sample and write all the fields of the given type
181  template<class Type>
182  void sampleAndWrite(const fieldGroup<Type>&);
183 
184  //- Sample and write all the surface fields of the given type
185  template<class Type>
186  void sampleAndWriteSurfaceFields(const fieldGroup<Type>&);
187 
188  //- Disallow default bitwise copy construct
189  probes(const probes&);
190 
191  //- Disallow default bitwise assignment
192  void operator=(const probes&);
193 
194 
195 public:
196 
197  //- Runtime type information
198  TypeName("probes");
199 
200 
201  // Constructors
202 
203  //- Construct for given objectRegistry and dictionary.
204  // Allow the possibility to load fields from files
205  probes
206  (
207  const word& name,
208  const objectRegistry&,
209  const dictionary&,
210  const bool loadFromFiles = false
211  );
212 
213 
214  //- Destructor
215  virtual ~probes();
216 
217 
218  // Member Functions
219 
220  //- Return name of the set of probes
221  virtual const word& name() const
222  {
223  return name_;
224  }
225 
226  //- Return names of fields to probe
227  virtual const wordReList& fieldNames() const
228  {
229  return fieldSelection_;
230  }
231 
232  //- Return locations to probe
233  virtual const pointField& probeLocations() const
234  {
235  return *this;
236  }
237 
238  //- Return location for probe i
239  virtual const point& probe(const label i) const
240  {
241  return operator[](i);
242  }
243 
244  //- Cells to be probed (obtained from the locations)
245  const labelList& elements() const
246  {
247  return elementList_;
248  }
249 
250  //- Execute, currently does nothing
251  virtual void execute();
252 
253  //- Execute at the final time-loop, currently does nothing
254  virtual void end();
255 
256  //- Called when time was set at the end of the Time::operator++
257  virtual void timeSet();
258 
259  //- Sample and write
260  virtual void write();
261 
262  //- Read the probes
263  virtual void read(const dictionary&);
264 
265  //- Update for changes of mesh
266  virtual void updateMesh(const mapPolyMesh&);
267 
268  //- Update for changes of mesh
269  virtual void movePoints(const polyMesh&);
270 
271  //- Update for changes of mesh due to readUpdate
272  virtual void readUpdate(const polyMesh::readUpdateState state)
273  {}
274 
275  //- Sample a volume field at all locations
276  template<class Type>
277  tmp<Field<Type> > sample
278  (
280  ) const;
281 
282  //- Sample a single vol field on all sample locations
283  template<class Type>
284  tmp<Field<Type> > sample(const word& fieldName) const;
285 
286  //- Sample a single scalar field on all sample locations
287  template<class Type>
288  tmp<Field<Type> > sampleSurfaceFields(const word& fieldName) const;
289 
290  //- Sample a surface field at all locations
291  template<class Type>
292  tmp<Field<Type> > sample
293  (
295  ) const;
296 };
297 
298 
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
300 
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #ifdef NoRepository
306 # include "probesTemplates.C"
307 #endif
308 
309 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
310 
311 #endif
312 
313 // ************************************************************************* //