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  //- Tolerance for merging points (fraction of mesh bounding box)
131  static scalar mergeTol_;
132 
133 
134  // Private Data
135 
136  //- Output path
137  fileName outputPath_;
138 
139 
140  // Read from dictionary
141 
142  //- Names of fields to sample
143  wordList fields_;
144 
145  //- Interpolation scheme to use
146  word interpolationScheme_;
147 
148  //- Should we create files for empty surfaces?
149  Switch writeEmpty_;
150 
151 
152  // Surfaces
153 
154  //- Information for merging surfaces
155  List<mergeInfo> mergeList_;
156 
157 
158  // Calculated
159 
160  //- Surface formatter
161  autoPtr<surfaceWriter> formatter_;
162 
163 
164  // Private Member Functions
165 
166  //- Does any of the surfaces need an update?
167  bool needsUpdate() const;
168 
169  //- Mark the surfaces as needing an update.
170  // May also free up unneeded data.
171  // Return false if all surfaces were already marked as expired.
172  bool expire();
173 
174  //- Update the surfaces as required and merge surface points (parallel).
175  // Return false if no surfaces required an update.
176  bool update();
177 
178  //- Sample all fields of a type on a given surface
179  template<class Type>
180  PtrList<Field<Type>> sampleLocalType
181  (
182  const label surfi,
183  const wordList& fieldNames,
184  HashPtrTable<interpolation<Type>>& interpolations
185  );
186 
187  //- Sample all fields of a type on a given surface and combine on the
188  // master for writing
189  template<class Type>
190  PtrList<Field<Type>> sampleType
191  (
192  const label surfi,
193  const wordList& fieldNames,
194  HashPtrTable<interpolation<Type>>& interpolations
195  );
196 
197 
198 public:
199 
200  //- Runtime type information
201  TypeName("surfaces");
202 
203 
204  // Constructors
205 
206  //- Construct from Time and dictionary
208  (
209  const word& name,
210  const Time& time,
211  const dictionary& dict
212  );
213 
214  //- Disallow default bitwise copy construction
215  sampledSurfaces(const sampledSurfaces&) = delete;
216 
217 
218  //- Destructor
219  virtual ~sampledSurfaces();
220 
221 
222  // Member Functions
223 
224  //- Read the sampledSurfaces dictionary
225  virtual bool read(const dictionary&);
226 
227  //- Return the list of fields required
228  virtual wordList fields() const;
229 
230  //- Execute, currently does nothing
231  virtual bool execute();
232 
233  //- Sample and write
234  virtual bool write();
235 
236  //- Update for mesh point-motion - expires the surfaces
237  virtual void movePoints(const polyMesh&);
238 
239  //- Update topology using the given map - expires the surfaces
240  virtual void topoChange(const polyTopoChangeMap&);
241 
242  //- Update from another mesh using the given map
243  virtual void mapMesh(const polyMeshMap&);
244 
245  //- Redistribute or update using the given distribution map
246  virtual void distribute(const polyDistributionMap&);
247 
248 
249  // Member Operators
250 
251  //- Disallow default bitwise assignment
252  void operator=(const sampledSurfaces&) = delete;
253 };
254 
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 } // End namespace functionObjects
259 } // End namespace Foam
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #ifdef NoRepository
264  #include "sampledSurfacesTemplates.C"
265 #endif
266 
267 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
268 
269 #endif
270 
271 // ************************************************************************* //
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:198
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
const word & name() const
Return the name of this functionObject.
virtual wordList fields() const
Return the list of fields required.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map - expires the surfaces.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion - expires the surfaces.
void operator=(const sampledSurfaces &)=delete
Disallow default bitwise assignment.
sampledSurfaces(const word &name, const Time &time, const dictionary &dict)
Construct from Time and dictionary.
virtual bool execute()
Execute, currently does nothing.
TypeName("surfaces")
Runtime type information.
virtual bool write()
Sample and write.
virtual bool read(const dictionary &)
Read the sampledSurfaces dictionary.
Writes run time, CPU time and clock time and optionally the CPU and clock times per time step.
Abstract base class for interpolation.
Definition: interpolation.H:55
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
static List< word > fieldNames
Definition: globalFoam.H:46
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: labelList.H:56
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
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
List< face > faceList
Definition: faceListFwd.H:41
dictionary dict