1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Set of surfaces to sample.
30 The write() method is used to sample and write files.
35 \*---------------------------------------------------------------------------*/
37 #ifndef sampledSurfaces_H
38 #define sampledSurfaces_H
40 #include "sampledSurface.H"
41 #include "surfaceWriter.H"
42 #include "volFieldsFwd.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 /*---------------------------------------------------------------------------*\
53 Class sampledSurfaces Declaration
54 \*---------------------------------------------------------------------------*/
58 public PtrList<sampledSurface>
62 //- Class used for grouping field types
66 public DynamicList<word>
71 autoPtr<surfaceWriter<Type> > formatter;
80 //- Construct for a particular surface format
81 fieldGroup(const word& writeFormat)
84 formatter(surfaceWriter<Type>::New(writeFormat))
87 //- Construct for a particular surface format and a list of field
91 const word& writeFormat,
92 const wordList& fieldNames
95 DynamicList<word>(fieldNames),
96 formatter(surfaceWriter<Type>::New(writeFormat))
99 void reset(const label nElem)
102 DynamicList<word>::setCapacity(nElem);
103 DynamicList<word>::clear();
106 void operator=(const word& writeFormat)
108 formatter = surfaceWriter<Type>::New(writeFormat);
111 void operator=(const wordList& fieldNames)
113 DynamicList<word>::operator=(fieldNames);
118 //- Class used for surface merging information
126 //- Clear all storage
136 // Static data members
139 static bool verbose_;
141 //- Tolerance for merging points (fraction of mesh bounding box)
142 static scalar mergeTol_;
146 //- Name of this set of surfaces,
147 // Also used as the name of the sampledSurfaces directory.
150 //- Const reference to fvMesh
153 //- Load fields from files (not from objectRegistry)
154 const bool loadFromFiles_;
157 fileName outputPath_;
160 // Read from dictonary
162 //- Names of fields to sample
163 wordList fieldNames_;
165 //- Interpolation scheme to use
166 word interpolationScheme_;
168 //- Output format to use
174 //- Information for merging surfaces
175 List<mergeInfo> mergeList_;
180 //- Generic surface formatter
181 autoPtr<surfaceWriter<bool> > genericFormatter_;
183 //- Categorized scalar/vector/tensor fields
184 fieldGroup<scalar> scalarFields_;
185 fieldGroup<vector> vectorFields_;
186 fieldGroup<sphericalTensor> sphericalTensorFields_;
187 fieldGroup<symmTensor> symmTensorFields_;
188 fieldGroup<tensor> tensorFields_;
191 // Private Member Functions
193 //- Classify field types, returns the number of fields
194 label classifyFieldTypes();
196 //- Write geometry only
197 void writeGeometry() const;
199 //- Sample and write a particular volume field
203 const GeometricField<Type, fvPatchField, volMesh>&,
204 const surfaceWriter<Type>& formatter
207 //- Sample and write all the fields of the given type
208 template <class Type>
209 void sampleAndWrite(fieldGroup<Type>&);
211 //- Disallow default bitwise copy construct and assignment
212 sampledSurfaces(const sampledSurfaces&);
213 void operator=(const sampledSurfaces&);
218 //- Runtime type information
219 TypeName("surfaces");
224 //- Construct for given objectRegistry and dictionary
225 // allow the possibility to load fields from files
229 const objectRegistry&,
231 const bool loadFromFiles = false
237 virtual ~sampledSurfaces();
242 //- Does any of the surfaces need an update?
243 virtual bool needsUpdate() const;
245 //- Mark the surfaces as needing an update.
246 // May also free up unneeded data.
247 // Return false if all surfaces were already marked as expired.
248 virtual bool expire();
250 //- Update the surfaces as required and merge surface points (parallel).
251 // Return false if no surfaces required an update.
252 virtual bool update();
255 //- Return name of the set of surfaces
256 virtual const word& name() const
261 //- set verbosity level
262 void verbose(const bool verbosity = true);
264 //- Execute, currently does nothing
265 virtual void execute();
267 //- Execute at the final time-loop, currently does nothing
271 virtual void write();
273 //- Read the sampledSurfaces dictionary
274 virtual void read(const dictionary&);
276 //- Update for changes of mesh - expires the surfaces
277 virtual void updateMesh(const mapPolyMesh&);
279 //- Update for mesh point-motion - expires the surfaces
280 virtual void movePoints(const pointField&);
282 //- Update for changes of mesh due to readUpdate - expires the surfaces
283 virtual void readUpdate(const polyMesh::readUpdateState state);
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
290 } // End namespace Foam
292 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
295 # include "sampledSurfacesTemplates.C"
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
302 // ************************************************************************* //