sampledSurfaces.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-2015 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::sampledSurfaces
26 
27 Description
28  Set of surfaces to sample.
29 
30  The write() method is used to sample and write files.
31 
32 SourceFiles
33  sampledSurfaces.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sampledSurfaces_H
38 #define sampledSurfaces_H
39 
40 #include "sampledSurface.H"
41 #include "surfaceWriter.H"
42 #include "volFieldsFwd.H"
43 #include "surfaceFieldsFwd.H"
44 #include "wordReList.H"
45 #include "IOobjectList.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 class fvMesh;
53 class dictionary;
54 
55 /*---------------------------------------------------------------------------*\
56  Class sampledSurfaces Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class sampledSurfaces
60 :
61  public PtrList<sampledSurface>
62 {
63  // Private classes
64 
65 
66  //- Class used for surface merging information
67  class mergeInfo
68  {
69  public:
71  faceList faces;
72  labelList pointsMap;
73 
74  //- Clear all storage
75  void clear()
76  {
77  points.clear();
78  faces.clear();
79  pointsMap.clear();
80  }
81  };
82 
83 
84  // Static data members
85 
86  //- Output verbosity
87  static bool verbose_;
88 
89  //- Tolerance for merging points (fraction of mesh bounding box)
90  static scalar mergeTol_;
91 
92 
93  // Private data
94 
95  //- Name of this set of surfaces,
96  // Also used as the name of the sampledSurfaces directory.
97  const word name_;
98 
99  //- Const reference to fvMesh
100  const fvMesh& mesh_;
101 
102  //- Load fields from files (not from objectRegistry)
103  const bool loadFromFiles_;
104 
105  //- Output path
106  fileName outputPath_;
107 
108 
109  // Read from dictonary
110 
111  //- Names of fields to sample
112  wordReList fieldSelection_;
113 
114  //- Interpolation scheme to use
115  word interpolationScheme_;
116 
117 
118  // surfaces
119 
120  //- Information for merging surfaces
121  List<mergeInfo> mergeList_;
122 
123 
124  // Calculated
125 
126  //- Surface formatter
127  autoPtr<surfaceWriter> formatter_;
128 
129 
130  // Private Member Functions
131 
132 
133  //- Return number of fields
134  label classifyFields();
135 
136  //- Write geometry only
137  void writeGeometry() const;
138 
139  //- Write sampled fieldName on surface and on outputDir path
140  template<class Type>
141  void writeSurface
142  (
143  const Field<Type>& values,
144  const label surfI,
145  const word& fieldName,
146  const fileName& outputDir
147  );
148 
149  //- Sample and write a particular volume field
150  template<class Type>
151  void sampleAndWrite
152  (
154  );
155 
156  //- Sample and write a particular surface field
157  template<class Type>
158  void sampleAndWrite
159  (
161  );
162 
163  //- Sample and write all sampled fields
164  template<class Type> void sampleAndWrite(const IOobjectList& objects);
165 
166  //- Disallow default bitwise copy construct and assignment
168  void operator=(const sampledSurfaces&);
169 
170 
171 public:
172 
173  //- Runtime type information
174  TypeName("surfaces");
175 
176 
177  // Constructors
178 
179  //- Construct for given objectRegistry and dictionary
180  // allow the possibility to load fields from files
182  (
183  const word& name,
184  const objectRegistry&,
185  const dictionary&,
186  const bool loadFromFiles = false
187  );
188 
189 
190  //- Destructor
191  virtual ~sampledSurfaces();
192 
193 
194  // Member Functions
195 
196  //- Does any of the surfaces need an update?
197  virtual bool needsUpdate() const;
198 
199  //- Mark the surfaces as needing an update.
200  // May also free up unneeded data.
201  // Return false if all surfaces were already marked as expired.
202  virtual bool expire();
203 
204  //- Update the surfaces as required and merge surface points (parallel).
205  // Return false if no surfaces required an update.
206  virtual bool update();
207 
208 
209  //- Return name of the set of surfaces
210  virtual const word& name() const
211  {
212  return name_;
213  }
214 
215  //- Set verbosity level
216  void verbose(const bool verbosity = true);
217 
218  //- Execute, currently does nothing
219  virtual void execute();
220 
221  //- Execute at the final time-loop, currently does nothing
222  virtual void end();
223 
224  //- Called when time was set at the end of the Time::operator++
225  virtual void timeSet();
226 
227  //- Sample and write
228  virtual void write();
229 
230  //- Read the sampledSurfaces dictionary
231  virtual void read(const dictionary&);
232 
233  //- Update for changes of mesh - expires the surfaces
234  virtual void updateMesh(const mapPolyMesh&);
235 
236  //- Update for mesh point-motion - expires the surfaces
237  virtual void movePoints(const polyMesh&);
238 
239  //- Update for changes of mesh due to readUpdate - expires the surfaces
240  virtual void readUpdate(const polyMesh::readUpdateState state);
241 };
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 } // End namespace Foam
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #ifdef NoRepository
251 # include "sampledSurfacesTemplates.C"
252 #endif
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
const pointField & points
virtual bool update()
Update the surfaces as required and merge surface points (parallel).
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
virtual void write()
Sample and write.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion - expires the surfaces.
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
virtual void execute()
Execute, currently does nothing.
virtual bool needsUpdate() const
Does any of the surfaces need an update?
virtual const word & name() const
Return name of the set of surfaces.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
Namespace for OpenFOAM.
virtual bool expire()
Mark the surfaces as needing an update.
void clear()
Clear the list, i.e. set size to zero.
Definition: List.C:379
virtual void end()
Execute at the final time-loop, currently does nothing.
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:88
void verbose(const bool verbosity=true)
Set verbosity level.
virtual void read(const dictionary &)
Read the sampledSurfaces dictionary.
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh - expires the surfaces.
Generic GeometricField class.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Registry of regIOobjects.
Set of surfaces to sample.
TypeName("surfaces")
Runtime type information.
A class for handling file names.
Definition: fileName.H:69
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
virtual ~sampledSurfaces()
Destructor.