1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Set of surfaces to sample.
31 The write() method is used to sample and write files.
36 \*---------------------------------------------------------------------------*/
38 #ifndef sampledSurfaces_H
39 #define sampledSurfaces_H
41 #include "sampledSurface.H"
42 #include "surfaceWriter.H"
43 #include "volFieldsFwd.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 /*---------------------------------------------------------------------------*\
54 Class sampledSurfaces Declaration
55 \*---------------------------------------------------------------------------*/
59 public PtrList<sampledSurface>
63 //- Class used for grouping field types
67 public DynamicList<word>
72 autoPtr< surfaceWriter<Type> > formatter;
81 //- Construct for a particular surface format
82 fieldGroup(const word& writeFormat)
85 formatter(surfaceWriter<Type>::New(writeFormat))
88 //- Construct for a particular surface format and a list of field
92 const word& writeFormat,
93 const wordList& fieldNames
96 DynamicList<word>(fieldNames),
97 formatter(surfaceWriter<Type>::New(writeFormat))
100 void reset(const label nElem)
103 DynamicList<word>::setCapacity(nElem);
104 DynamicList<word>::clear();
107 void operator=(const word& writeFormat)
109 formatter = surfaceWriter<Type>::New(writeFormat);
112 void operator=(const wordList& fieldNames)
114 DynamicList<word>::operator=(fieldNames);
119 //- Class used for surface merging information
127 //- Clear all storage
137 // Static data members
140 static bool verbose_;
142 //- Tolerance for merging points (fraction of mesh bounding box)
143 static scalar mergeTol_;
147 //- Name of this set of surfaces,
148 // Also used as the name of the sampledSurfaces directory.
151 //- Const reference to fvMesh
154 //- Load fields from files (not from objectRegistry)
155 const bool loadFromFiles_;
158 fileName outputPath_;
161 // Read from dictonary
163 //- Names of fields to sample
164 wordList fieldNames_;
166 //- Interpolation scheme to use
167 word interpolationScheme_;
169 //- Output format to use
175 //- Information for merging surfaces
176 List<mergeInfo> mergeList_;
181 //- Generic surface formatter
182 autoPtr< surfaceWriter<bool> > genericFormatter_;
184 //- Categorized scalar/vector/tensor fields
185 fieldGroup<scalar> scalarFields_;
186 fieldGroup<vector> vectorFields_;
187 fieldGroup<sphericalTensor> sphericalTensorFields_;
188 fieldGroup<symmTensor> symmTensorFields_;
189 fieldGroup<tensor> tensorFields_;
192 // Private Member Functions
194 //- Classify field types, returns the number of fields
195 label classifyFieldTypes();
197 //- Write geometry only
198 void writeGeometry() const;
200 //- Sample and write a particular volume field
204 const GeometricField<Type, fvPatchField, volMesh>&,
205 const surfaceWriter<Type>& formatter
208 //- Sample and write all the fields of the given type
209 template <class Type>
210 void sampleAndWrite(fieldGroup<Type>&);
212 //- Disallow default bitwise copy construct and assignment
213 sampledSurfaces(const sampledSurfaces&);
214 void operator=(const sampledSurfaces&);
219 //- Runtime type information
220 TypeName("surfaces");
225 //- Construct for given objectRegistry and dictionary
226 // allow the possibility to load fields from files
230 const objectRegistry&,
232 const bool loadFromFiles = false
238 virtual ~sampledSurfaces();
243 //- Does any of the surfaces need an update?
244 virtual bool needsUpdate() const;
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();
251 //- Update the surfaces as required and merge surface points (parallel).
252 // Return false if no surfaces required an update.
253 virtual bool update();
256 //- Return name of the set of surfaces
257 virtual const word& name() const
262 //- set verbosity level
263 void verbose(const bool verbosity = true);
265 //- Execute, currently does nothing
266 virtual void execute();
268 //- Execute at the final time-loop, currently does nothing
272 virtual void write();
274 //- Read the sampledSurfaces dictionary
275 virtual void read(const dictionary&);
277 //- Update for changes of mesh - expires the surfaces
278 virtual void updateMesh(const mapPolyMesh&);
280 //- Update for mesh point-motion - expires the surfaces
281 virtual void movePoints(const pointField&);
283 //- Update for changes of mesh due to readUpdate - expires the surfaces
284 virtual void readUpdate(const polyMesh::readUpdateState state);
289 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 } // End namespace Foam
293 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
296 # include "sampledSurfacesTemplates.C"
299 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
303 // ************************************************************************* //