FreeFOAM The Cross-Platform CFD Toolkit
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) 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 Class
25  Foam::probes
26 
27 Description
28  Set of locations to sample.
29 
30  Call write() to sample and write files.
31 
32 SourceFiles
33  probes.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef probes_H
38 #define probes_H
39 
40 #include <OpenFOAM/HashPtrTable.H>
41 #include <OpenFOAM/OFstream.H>
42 #include <OpenFOAM/polyMesh.H>
43 #include <OpenFOAM/pointField.H>
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 // Forward declaration of classes
52 class objectRegistry;
53 class dictionary;
54 class fvMesh;
55 class mapPolyMesh;
56 
57 /*---------------------------------------------------------------------------*\
58  Class probes Declaration
59 \*---------------------------------------------------------------------------*/
60 
61 class probes
62 {
63 protected:
64 
65  // Protected classes
66 
67  //- Class used for grouping field types
68  template<class Type>
69  class fieldGroup
70  :
71  public wordList
72  {
73  public:
74  //- Construct null
76  :
77  wordList()
78  {}
79 
80  //- Construct for a list of field names
82  :
83  wordList(fieldNames)
84  {}
85  };
86 
87 
88  // Protected data
89 
90  //- Name of this set of probes,
91  // Also used as the name of the probes directory.
93 
94  //- Const reference to objectRegistry
96 
97  //- Load fields from files (not from objectRegistry)
99 
100 
101  // Read from dictonary
102 
103  //- Names of fields to probe
105 
106  //- Locations to probe
108 
109 
110  // Calculated
111 
112  //- Categorized scalar/vector/tensor fields
118 
119  // Cells to be probed (obtained from the locations)
121 
122  //- Current open files
124 
125 
126  // Private Member Functions
127 
128  //- Find element containing probes
129  virtual void findElements(const fvMesh&);
130 
131  //- classify field types, return true if nFields > 0
132  bool checkFieldTypes();
133 
134  //- Find the fields in the list of the given type, return count
135  template<class Type>
136  label countFields
137  (
138  fieldGroup<Type>& fieldList,
139  const wordList& fieldTypes
140  ) const;
141 
142 
143 private:
144 
145  //- Sample and write a particular volume field
146  template<class Type>
147  void sampleAndWrite
148  (
150  );
151 
152  //- Sample and write all the fields of the given type
153  template <class Type>
154  void sampleAndWrite(const fieldGroup<Type>&);
155 
156  //- Disallow default bitwise copy construct
157  probes(const probes&);
158 
159  //- Disallow default bitwise assignment
160  void operator=(const probes&);
161 
162 
163 public:
164 
165  //- Runtime type information
166  TypeName("probes");
167 
168 
169  // Constructors
170 
171  //- Construct for given objectRegistry and dictionary.
172  // Allow the possibility to load fields from files
173  probes
174  (
175  const word& name,
176  const objectRegistry&,
177  const dictionary&,
178  const bool loadFromFiles = false
179  );
180 
181 
182  //- Destructor
183  virtual ~probes();
184 
185 
186  // Member Functions
187 
188  //- Return name of the set of probes
189  virtual const word& name() const
190  {
191  return name_;
192  }
193 
194  //- Return names of fields to probe
195  virtual const wordList& fieldNames() const
196  {
197  return fieldNames_;
198  }
199 
200  //- Return locations to probe
201  virtual const vectorField& probeLocations() const
202  {
203  return probeLocations_;
204  }
205 
206  //- Cells to be probed (obtained from the locations)
207  const labelList& elements() const
208  {
209  return elementList_;
210  }
211 
212  //- Execute, currently does nothing
213  virtual void execute();
214 
215  //- Execute at the final time-loop, currently does nothing
216  virtual void end();
217 
218  //- Sample and write
219  virtual void write();
220 
221  //- Read the probes
222  virtual void read(const dictionary&);
223 
224  //- Update for changes of mesh
225  virtual void updateMesh(const mapPolyMesh&)
226  {}
227 
228  //- Update for changes of mesh
229  virtual void movePoints(const pointField&)
230  {}
231 
232  //- Update for changes of mesh due to readUpdate
233  virtual void readUpdate(const polyMesh::readUpdateState state)
234  {}
235 
236  //- Sample a volume field at all locations
237  template<class Type>
239  (
241  ) const;
242 
243  //- Sample a single field on all sample locations
244  template <class Type>
245  tmp<Field<Type> > sample(const word& fieldName) const;
246 };
247 
248 
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
250 
251 } // End namespace Foam
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #ifdef NoRepository
256 # include <sampling/probesTemplates.C>
257 #endif
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 #endif
262 
263 // ************************ vim: set sw=4 sts=4 et: ************************ //