sampledSurfaces.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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::functionObjects::sampledSurfaces
26 
27 Description
28  Set of surfaces to sample
29 
30  Example of function object specification:
31  \verbatim
32  surfaces1
33  {
34  type surfaces;
35  libs ("libsampling.so");
36 
37  writeControl writeTime;
38 
39  fields (p U);
40 
41  surfaceFormat vtk;
42  interpolationScheme cellPoint;
43 
44  surfaces
45  (
46  p1e5
47  {
48  type isoSurface;
49  isoField p;
50  isoValue 1e5;
51  interpolate yes;
52  }
53  );
54  }
55  \endverbatim
56 
57 Usage
58  \table
59  Property | Description | Required | Default value
60  type | type name: surfaces | yes |
61  surfaceFormat | the format in which to write the surface file | yes |
62  interpolationScheme | the method by which values are interpolated \\
63  from the mesh to the surface | yes
64  surfaces | the list of surfaces | yes |
65  \endtable
66 
67 See also
68  Foam::sampledSurfaces
69 
70 SourceFiles
71  sampledSurfaces.C
72 
73 \*---------------------------------------------------------------------------*/
74 
75 #ifndef functionObjects_sampledSurfaces_H
76 #define functionObjects_sampledSurfaces_H
77 
78 #include "functionObject.H"
79 #include "sampledSurface.H"
80 #include "surfaceWriter.H"
81 #include "volFieldsFwd.H"
82 #include "surfaceFieldsFwd.H"
83 #include "wordReList.H"
84 #include "IOobjectList.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 // Forward declaration of classes
92 class Time;
93 class fvMesh;
94 class dictionary;
95 
96 namespace functionObjects
97 {
98 
99 /*---------------------------------------------------------------------------*\
100  Class sampledSurfaces Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 class sampledSurfaces
104 :
105  public functionObject,
106  public PtrList<sampledSurface>
107 {
108  // Private classes
109 
110  //- Class used for surface merging information
111  class mergeInfo
112  {
113  public:
115  faceList faces;
116  labelList pointsMap;
117 
118  //- Clear all storage
119  void clear()
120  {
121  points.clear();
122  faces.clear();
123  pointsMap.clear();
124  }
125  };
126 
127 
128  // Static Data Members
129 
130  //- Output verbosity
131  static bool verbose_;
132 
133  //- Tolerance for merging points (fraction of mesh bounding box)
134  static scalar mergeTol_;
135 
136 
137  // Private Data
138 
139  //- Const reference to fvMesh
140  const fvMesh& mesh_;
141 
142  //- Load fields from files (not from objectRegistry)
143  const bool loadFromFiles_;
144 
145  //- Output path
146  fileName outputPath_;
147 
148 
149  // Read from dictonary
150 
151  //- Names of fields to sample
152  wordReList fieldSelection_;
153 
154  //- Interpolation scheme to use
155  word interpolationScheme_;
156 
157 
158  // surfaces
159 
160  //- Information for merging surfaces
161  List<mergeInfo> mergeList_;
162 
163 
164  // Calculated
165 
166  //- Surface formatter
167  autoPtr<surfaceWriter> formatter_;
168 
169 
170  // Private Member Functions
171 
172 
173  //- Return number of fields
174  label classifyFields();
175 
176  //- Write geometry only
177  void writeGeometry() const;
178 
179  //- Write sampled fieldName on surface and on outputDir path
180  template<class Type>
181  void writeSurface
182  (
183  const Field<Type>& values,
184  const label surfI,
185  const word& fieldName,
186  const fileName& outputDir
187  );
188 
189  //- Sample and write a particular volume field
190  template<class Type>
191  void sampleAndWrite
192  (
194  );
195 
196  //- Sample and write a particular surface field
197  template<class Type>
198  void sampleAndWrite
199  (
201  );
202 
203  //- Sample and write all sampled fields
204  template<class Type> void sampleAndWrite(const IOobjectList& objects);
205 
206 
207 public:
208 
209  //- Runtime type information
210  TypeName("surfaces");
211 
212 
213  // Constructors
214 
215  //- Construct from Time and dictionary
217  (
218  const word& name,
219  const Time& time,
220  const dictionary& dict
221  );
222 
223  //- Construct for given objectRegistry and dictionary
224  // allow the possibility to load fields from files
226  (
227  const word& name,
228  const objectRegistry&,
229  const dictionary&,
230  const bool loadFromFiles = false
231  );
232 
233  //- Disallow default bitwise copy construction
234  sampledSurfaces(const sampledSurfaces&) = delete;
235 
236 
237  //- Destructor
238  virtual ~sampledSurfaces();
239 
240 
241  // Member Functions
242 
243  //- Does any of the surfaces need an update?
244  virtual bool needsUpdate() const;
245 
246  //- Mark the surfaces as needing an update.
247  // May also free up unneeded data.
248  // Return false if all surfaces were already marked as expired.
249  virtual bool expire();
250 
251  //- Update the surfaces as required and merge surface points (parallel).
252  // Return false if no surfaces required an update.
253  virtual bool update();
254 
255  //- Set verbosity level
256  void verbose(const bool verbosity = true);
257 
258  //- Read the sampledSurfaces dictionary
259  virtual bool read(const dictionary&);
260 
261  //- Execute, currently does nothing
262  virtual bool execute();
263 
264  //- Sample and write
265  virtual bool write();
266 
267  //- Update for changes of mesh - expires the surfaces
268  virtual void updateMesh(const mapPolyMesh&);
269 
270  //- Update for mesh point-motion - expires the surfaces
271  virtual void movePoints(const polyMesh&);
272 
273  //- Update for changes of mesh due to readUpdate - expires the surfaces
274  virtual void readUpdate(const polyMesh::readUpdateState state);
275 
276 
277  // Member Operators
278 
279  //- Disallow default bitwise assignment
280  void operator=(const sampledSurfaces&) = delete;
281 };
282 
283 
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 
286 } // End namespace functionObjects
287 } // End namespace Foam
288 
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 
291 #ifdef NoRepository
292  #include "sampledSurfacesTemplates.C"
293 #endif
294 
295 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 
297 #endif
298 
299 // ************************************************************************* //
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
A class for handling file names.
Definition: fileName.H:79
virtual bool execute()
Execute, currently does nothing.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
const word & name() const
Return the name of this functionObject.
void operator=(const sampledSurfaces &)=delete
Disallow default bitwise assignment.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
sampledSurfaces(const word &name, const Time &time, const dictionary &dict)
Construct from Time and dictionary.
List< face > faceList
Definition: faceListFwd.H:43
virtual bool needsUpdate() const
Does any of the surfaces need an update?
virtual void movePoints(const polyMesh &)
Update for mesh point-motion - expires the surfaces.
TypeName("surfaces")
Runtime type information.
Generic GeometricField class.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh - expires the surfaces.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
virtual bool write()
Sample and write.
const pointField & points
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
List< label > labelList
A List of labels.
Definition: labelList.H:56
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step...
objects
virtual bool expire()
Mark the surfaces as needing an update.
void verbose(const bool verbosity=true)
Set verbosity level.
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 bool read(const dictionary &)
Read the sampledSurfaces dictionary.
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:174
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 void readUpdate(const polyMesh::readUpdateState state)
Update for changes of mesh due to readUpdate - expires the surfaces.
Namespace for OpenFOAM.