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-2022 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  writeEmpty | write out files for empty surfaces | no | no
65  surfaces | the list of surfaces | yes |
66  \endtable
67 
68 See also
69  Foam::sampledSurfaces
70 
71 SourceFiles
72  sampledSurfaces.C
73 
74 \*---------------------------------------------------------------------------*/
75 
76 #ifndef functionObjects_sampledSurfaces_H
77 #define functionObjects_sampledSurfaces_H
78 
79 #include "fvMeshFunctionObject.H"
80 #include "sampledSurface.H"
81 #include "surfaceWriter.H"
82 #include "volFieldsFwd.H"
83 #include "surfaceFieldsFwd.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 fvMeshFunctionObject,
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  //- Output path
140  fileName outputPath_;
141 
142 
143  // Read from dictionary
144 
145  //- Names of fields to sample
146  wordList fields_;
147 
148  //- Interpolation scheme to use
149  word interpolationScheme_;
150 
151  //- Should we create files for empty surfaces?
152  Switch writeEmpty_;
153 
154 
155  // Surfaces
156 
157  //- Information for merging surfaces
158  List<mergeInfo> mergeList_;
159 
160 
161  // Calculated
162 
163  //- Surface formatter
164  autoPtr<surfaceWriter> formatter_;
165 
166 
167  // Private Member Functions
168 
169  //- Sample all fields of a type on a given surface
170  template<class Type>
171  PtrList<Field<Type>> sampleLocalType
172  (
173  const label surfi,
174  const wordList& fieldNames,
175  HashPtrTable<interpolation<Type>>& interpolations
176  );
177 
178  //- Sample all fields of a type on a given surface and combine on the
179  // master for writing
180  template<class Type>
181  PtrList<Field<Type>> sampleType
182  (
183  const label surfi,
184  const wordList& fieldNames,
185  HashPtrTable<interpolation<Type>>& interpolations
186  );
187 
188 
189 public:
190 
191  //- Runtime type information
192  TypeName("surfaces");
193 
194 
195  // Constructors
196 
197  //- Construct from Time and dictionary
199  (
200  const word& name,
201  const Time& time,
202  const dictionary& dict
203  );
204 
205  //- Disallow default bitwise copy construction
206  sampledSurfaces(const sampledSurfaces&) = delete;
207 
208 
209  //- Destructor
210  virtual ~sampledSurfaces();
211 
212 
213  // Member Functions
214 
215  //- Does any of the surfaces need an update?
216  virtual bool needsUpdate() const;
217 
218  //- Mark the surfaces as needing an update.
219  // May also free up unneeded data.
220  // Return false if all surfaces were already marked as expired.
221  virtual bool expire();
222 
223  //- Update the surfaces as required and merge surface points (parallel).
224  // Return false if no surfaces required an update.
225  virtual bool update();
226 
227  //- Set verbosity level
228  void verbose(const bool verbosity = true);
229 
230  //- Read the sampledSurfaces dictionary
231  virtual bool read(const dictionary&);
232 
233  //- Return the list of fields required
234  virtual wordList fields() const;
235 
236  //- Execute, currently does nothing
237  virtual bool execute();
238 
239  //- Sample and write
240  virtual bool write();
241 
242  //- Update for mesh point-motion - expires the surfaces
243  virtual void movePoints(const polyMesh&);
244 
245  //- Update topology using the given map - expires the surfaces
246  virtual void topoChange(const polyTopoChangeMap&);
247 
248  //- Update from another mesh using the given map
249  virtual void mapMesh(const polyMeshMap&);
250 
251  //- Update topology using the given map due to readUpdate
252  // - expires the surfaces
253  virtual void readUpdate(const polyMesh::readUpdateState state);
254 
255 
256  // Member Operators
257 
258  //- Disallow default bitwise assignment
259  void operator=(const sampledSurfaces&) = delete;
260 };
261 
262 
263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 
265 } // End namespace functionObjects
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #ifdef NoRepository
271  #include "sampledSurfacesTemplates.C"
272 #endif
273 
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 
276 #endif
277 
278 // ************************************************************************* //
dictionary dict
A class for handling file names.
Definition: fileName.H:79
virtual bool execute()
Execute, currently does nothing.
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 wordList fields() const
Return the list of fields required.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion - expires the surfaces.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
TypeName("surfaces")
Runtime type information.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
static List< word > fieldNames
Definition: globalFoam.H:46
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
virtual bool write()
Sample and write.
const pointField & points
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
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...
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map - expires the surfaces.
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).
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
virtual bool read(const dictionary &)
Read the sampledSurfaces dictionary.
Abstract base class for interpolation.
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:76
readUpdateState
Enumeration defining the state of the mesh after a read update.
Definition: polyMesh.H:90
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
virtual void readUpdate(const polyMesh::readUpdateState state)
Update topology using the given map due to readUpdate.
Namespace for OpenFOAM.