initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / sampling / sampledSurface / sampledSurfaces / sampledSurfaces.H
blob15515533be666539d17a794fbdeb1a5859457d94
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::sampledSurfaces
28 Description
29     Set of surfaces to sample.
31     The write() method is used to sample and write files.
33 SourceFiles
34     sampledSurfaces.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef sampledSurfaces_H
39 #define sampledSurfaces_H
41 #include "sampledSurface.H"
42 #include "surfaceWriter.H"
43 #include "volFieldsFwd.H"
44 #include "volPointInterpolation.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 class fvMesh;
52 class dictionary;
54 /*---------------------------------------------------------------------------*\
55                       Class sampledSurfaces Declaration
56 \*---------------------------------------------------------------------------*/
58 class sampledSurfaces
60     public PtrList<sampledSurface>
62     // Private classes
64         //- Class used for grouping field types
65         template<class Type>
66         class fieldGroup
67         :
68             public wordList
69         {
70         public:
72             //- Surface formatter
73             autoPtr<surfaceWriter<Type> > formatter;
75             //- Construct null
76             fieldGroup()
77             :
78                 wordList(0),
79                 formatter(NULL)
80             {}
82             //- Construct for a particular surface format
83             fieldGroup(const word& writeFormat)
84             :
85                 wordList(0),
86                 formatter(surfaceWriter<Type>::New(writeFormat))
87             {}
89             //- Construct for a particular surface format and a list of field names
90             fieldGroup
91             (
92                 const word& writeFormat,
93                 const wordList& fieldNames
94             )
95             :
96                 wordList(fieldNames),
97                 formatter(surfaceWriter<Type>::New(writeFormat))
98             {}
100             void operator=(const word& writeFormat)
101             {
102                 formatter = surfaceWriter<Type>::New(writeFormat);
103             }
105             void operator=(const wordList& fieldNames)
106             {
107                 wordList::operator=(fieldNames);
108             }
109         };
112         //- Class used for surface merging information
113         class mergeInfo
114         {
115         public:
116             pointField points;
117             faceList   faces;
118             labelList  pointsMap;
119         };
122     // Static data members
124         //- output verbosity
125         static bool verbose_;
128     // Private data
130         //- Name of this set of surfaces,
131         //  Also used as the name of the sampledSurfaces directory.
132         word name_;
134         //- Const reference to fvMesh
135         const fvMesh& mesh_;
137         //- Load fields from files (not from objectRegistry)
138         bool loadFromFiles_;
140         //- output path
141         fileName outputPath_;
143         //- pointMesh for interpolation
144         autoPtr<pointMesh> pMeshPtr_;
146         //- volPointInterpolation for interpolation
147         autoPtr<volPointInterpolation> pInterpPtr_;
150         // Read from dictonary
152             //- Names of fields to sample
153             wordList fieldNames_;
155             //- Interpolation scheme to use
156             word interpolationScheme_;
158             //- Output format to use
159             word writeFormat_;
162         // surfaces
164             //- Information for merging surfaces
165             List<mergeInfo> mergeList_;
168         // Calculated
170             //- Categorized scalar/vector/tensor fields
171             fieldGroup<scalar> scalarFields_;
172             fieldGroup<vector> vectorFields_;
173             fieldGroup<sphericalTensor> sphericalTensorFields_;
174             fieldGroup<symmTensor> symmTensorFields_;
175             fieldGroup<tensor> tensorFields_;
178     // Private Member Functions
180         //- Classify field types, return true if nFields > 0
181         bool checkFieldTypes();
183         //- Merge points on surfaces
184         void mergeSurfaces();
186         //- Find the fields in the list of the given type, return count
187         template<class Type>
188         label grep
189         (
190             fieldGroup<Type>& fieldList,
191             const wordList& fieldTypes
192         ) const;
194         //- Set interpolator for the field
195         template<class Type>
196         autoPtr<interpolation<Type> > setInterpolator
197         (
198             const GeometricField<Type, fvPatchField, volMesh>&
199         );
201         //- Sample and write a particular volume field
202         template<class Type>
203         void sampleAndWrite
204         (
205             const GeometricField<Type, fvPatchField, volMesh>&,
206             const surfaceWriter<Type>& formatter
207         );
209         //- Sample and write all the fields of the given type
210         template <class Type>
211         void sampleAndWrite(fieldGroup<Type>&);
213         //- Disallow default bitwise copy construct and assignment
214         sampledSurfaces(const sampledSurfaces&);
215         void operator=(const sampledSurfaces&);
218 public:
220     //- Runtime type information
221     TypeName("surfaces");
224     // Constructors
226         //- Construct for given objectRegistry and dictionary
227         //  allow the possibility to load fields from files
228         sampledSurfaces
229         (
230             const word& name,
231             const objectRegistry&,
232             const dictionary&,
233             const bool loadFromFiles = false
234         );
237     // Destructor
239         virtual ~sampledSurfaces();
242     // Member Functions
244         //- Return name of the set of probes
245         virtual const word& name() const
246         {
247             return name_;
248         }
250         //- set verbosity level
251         void verbose(const bool verbosity = true);
253         //- Sample and write
254         virtual void write();
256         //- Read the sampledSurfaces
257         virtual void read(const dictionary&);
259         //- Correct for mesh changes
260         void correct();
262         //- Update for changes of mesh
263         virtual void updateMesh(const mapPolyMesh&);
265         //- Update for mesh point-motion
266         virtual void movePoints(const pointField&);
268         //- Update for changes of mesh due to readUpdate
269         virtual void readUpdate(const polyMesh::readUpdateState state);
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 } // End namespace Foam
277 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 #ifdef NoRepository
280 #   include "sampledSurfacesTemplates.C"
281 #endif
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 #endif
287 // ************************************************************************* //