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