All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2019 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 
166 public:
167 
168  //- Runtime type information
169  TypeName("surfaces");
170 
171 
172  // Constructors
173 
174  //- Construct from Time and dictionary
176  (
177  const word& name,
178  const Time& time,
179  const dictionary& dict
180  );
181 
182  //- Construct for given objectRegistry and dictionary
183  // allow the possibility to load fields from files
185  (
186  const word& name,
187  const objectRegistry&,
188  const dictionary&,
189  const bool loadFromFiles = false
190  );
191 
192  //- Disallow default bitwise copy construction
193  sampledSurfaces(const sampledSurfaces&) = delete;
194 
195 
196  //- Destructor
197  virtual ~sampledSurfaces();
198 
199 
200  // Member Functions
201 
202  //- Does any of the surfaces need an update?
203  virtual bool needsUpdate() const;
204 
205  //- Mark the surfaces as needing an update.
206  // May also free up unneeded data.
207  // Return false if all surfaces were already marked as expired.
208  virtual bool expire();
209 
210  //- Update the surfaces as required and merge surface points (parallel).
211  // Return false if no surfaces required an update.
212  virtual bool update();
213 
214  //- Set verbosity level
215  void verbose(const bool verbosity = true);
216 
217  //- Read the sampledSurfaces dictionary
218  virtual bool read(const dictionary&);
219 
220  //- Execute, currently does nothing
221  virtual bool execute();
222 
223  //- Sample and write
224  virtual bool write();
225 
226  //- Update for changes of mesh - expires the surfaces
227  virtual void updateMesh(const mapPolyMesh&);
228 
229  //- Update for mesh point-motion - expires the surfaces
230  virtual void movePoints(const polyMesh&);
231 
232  //- Update for changes of mesh due to readUpdate - expires the surfaces
233  virtual void readUpdate(const polyMesh::readUpdateState state);
234 
235 
236  // Member Operators
237 
238  //- Disallow default bitwise assignment
239  void operator=(const sampledSurfaces&) = delete;
240 };
241 
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #ifdef NoRepository
250  #include "sampledSurfacesTemplates.C"
251 #endif
252 
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 
255 #endif
256 
257 // ************************************************************************* //
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:79
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:158
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 functionObjects.
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:125
A class for handling words, derived from string.
Definition: word.H:59
sampledSurfaces(const word &name, const Time &time, const dictionary &dict)
Construct from Time and dictionary.
virtual void movePoints(const polyMesh &)
Update for mesh point-motion - expires the surfaces.
void operator=(const sampledSurfaces &)=delete
Disallow default bitwise assignment.
objects
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:70
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.