1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Set of sets to sample.
29 Call sampledSets.write() to sample&write files.
34 \*---------------------------------------------------------------------------*/
39 #include "sampledSet.H"
40 #include "volFieldsFwd.H"
41 #include "meshSearch.H"
42 #include "interpolation.H"
45 #include "wordReList.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 /*---------------------------------------------------------------------------*\
57 Class sampledSets Declaration
58 \*---------------------------------------------------------------------------*/
62 public PtrList<sampledSet>
66 //- Class used for grouping field types
70 public DynamicList<word>
75 autoPtr< writer<Type> > formatter;
84 //- Construct for a particular format
85 fieldGroup(const word& writeFormat)
88 formatter(writer<Type>::New(writeFormat))
91 //- Reset format and field list
94 DynamicList<word>::clear();
98 //- Assign a new formatter
99 void operator=(const word& writeFormat)
101 formatter = writer<Type>::New(writeFormat);
107 //- Class used for sampling volFields
108 template <class Type>
109 class volFieldSampler
111 public List<Field<Type> >
113 //- Name of this collection of values
118 //- Construct interpolating field to the sampleSets
121 const word& interpolationScheme,
122 const GeometricField<Type, fvPatchField, volMesh>& field,
123 const PtrList<sampledSet>&
126 //- Construct mapping field to the sampleSets
129 const GeometricField<Type, fvPatchField, volMesh>& field,
130 const PtrList<sampledSet>&
133 //- Construct from components
136 const List<Field<Type> >& values,
140 //- Return the field name
141 const word& name() const
148 // Static data members
151 static bool verbose_;
156 //- Name of this set of sets,
157 // Also used as the name of the sampledSets directory.
160 //- Const reference to fvMesh
163 //- Keep the dictionary to recreate sets for moving mesh cases
166 //- Load fields from files (not from objectRegistry)
170 fileName outputPath_;
172 //- Mesh search engine
173 meshSearch searchEngine_;
176 // Read from dictonary
178 //- Names of fields to sample
179 wordReList fieldSelection_;
181 //- Interpolation scheme to use
182 word interpolationScheme_;
184 //- Output format to use
188 // Categorized scalar/vector/tensor fields
190 fieldGroup<scalar> scalarFields_;
191 fieldGroup<vector> vectorFields_;
192 fieldGroup<sphericalTensor> sphericalTensorFields_;
193 fieldGroup<symmTensor> symmTensorFields_;
194 fieldGroup<tensor> tensorFields_;
197 // Merging structures
199 PtrList<coordSet> masterSampledSets_;
200 labelListList indexSets_;
203 // Private Member Functions
205 //- Clear old field groups
206 void clearFieldGroups();
208 //- Append fieldName to the appropriate group
209 label appendFieldGroup(const word& fieldName, const word& fieldType);
211 //- Classify field types, returns the number of fields
212 label classifyFields();
214 //- Combine points from all processors. Sort by curveDist and produce
215 // index list. Valid result only on master processor.
216 void combineSampledSets
218 PtrList<coordSet>& masterSampledSets,
219 labelListList& indexSets
222 //- Combine values from all processors.
223 // Valid result only on master processor.
225 void combineSampledValues
227 const PtrList<volFieldSampler<T> >& sampledFields,
228 const labelListList& indexSets,
229 PtrList<volFieldSampler<T> >& masterFields
235 const coordSet& masterSampleSet,
236 const PtrList<volFieldSampler<Type> >& masterFields,
238 const fileName& timeDir,
239 const writer<Type>& formatter
243 void sampleAndWrite(fieldGroup<Type>& fields);
246 //- Disallow default bitwise copy construct and assignment
247 sampledSets(const sampledSets&);
248 void operator=(const sampledSets&);
253 //- Runtime type information
259 //- Construct for given objectRegistry and dictionary
260 // allow the possibility to load fields from files
264 const objectRegistry&,
266 const bool loadFromFiles = false
271 virtual ~sampledSets();
276 //- Return name of the set of probes
277 virtual const word& name() const
282 //- set verbosity level
283 void verbose(const bool verbosity = true);
285 //- Execute, currently does nothing
286 virtual void execute();
288 //- Execute at the final time-loop, currently does nothing
292 virtual void write();
294 //- Read the sampledSets
295 virtual void read(const dictionary&);
297 //- Correct for mesh changes
300 //- Update for changes of mesh
301 virtual void updateMesh(const mapPolyMesh&);
303 //- Update for mesh point-motion
304 virtual void movePoints(const pointField&);
306 //- Update for changes of mesh due to readUpdate
307 virtual void readUpdate(const polyMesh::readUpdateState state);
311 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
313 } // End namespace Foam
315 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 # include "sampledSetsTemplates.C"
321 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
325 // ************************************************************************* //