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