Merge branch 'master' of ssh://opencfd@repo.or.cz/srv/git/OpenFOAM-1.5.x
[OpenFOAM-1.5.x.git] / src / sampling / probes / probes.H
blobdd9b74557775691186614b29e3053f79be9c4157
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::probes
28 Description
29     Set of locations to sample.
31     Call write() to sample and write files.
33 SourceFiles
34     probes.C
36 \*---------------------------------------------------------------------------*/
38 #ifndef probes_H
39 #define probes_H
41 #include "HashPtrTable.H"
42 #include "OFstream.H"
43 #include "polyMesh.H"
44 #include "pointField.H"
45 #include "volFieldsFwd.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 namespace Foam
52 // Forward declaration of classes
53 class objectRegistry;
54 class dictionary;
55 class fvMesh;
56 class mapPolyMesh;
58 /*---------------------------------------------------------------------------*\
59                           Class probes Declaration
60 \*---------------------------------------------------------------------------*/
62 class probes
64     // Private classes
66         //- Class used for grouping field types
67         template<class Type>
68         class fieldGroup
69         :
70             public wordList
71         {
72         public:
73             //- Construct null
74             fieldGroup()
75             :
76                 wordList()
77             {}
79             //- Construct for a list of field names
80             fieldGroup(const wordList& fieldNames)
81             :
82                 wordList(fieldNames)
83             {}
84         };
87     // Private data
89         //- Name of this set of probes,
90         //  Also used as the name of the probes directory.
91         word name_;
93         //- Const reference to objectRegistry
94         const objectRegistry& obr_;
96         //- Load fields from files (not from objectRegistry)
97         bool loadFromFiles_;
100         // Read from dictonary
102             //- Names of fields to probe
103             wordList fieldNames_;
105             //- Locations to probe
106             vectorField probeLocations_;
109         // Calculated
111             //- Categorized scalar/vector/tensor fields
112             fieldGroup<scalar> scalarFields_;
113             fieldGroup<vector> vectorFields_;
114             fieldGroup<sphericalTensor> sphericalTensorFields_;
115             fieldGroup<symmTensor> symmTensorFields_;
116             fieldGroup<tensor> tensorFields_;
118             // Cells to be probed (obtained from the locations)
119             labelList cellList_;
121             //- Current open files
122             HashPtrTable<OFstream> probeFilePtrs_;
125     // Private Member Functions
127         //- Find cells containing probes
128         void findCells(const fvMesh&);
130         //- classify field types, return true if nFields > 0
131         bool checkFieldTypes();
133         //- Find the fields in the list of the given type, return count
134         template<class Type>
135         label countFields
136         (
137             fieldGroup<Type>& fieldList,
138             const wordList& fieldTypes
139         ) const;
141         //- Sample and write a particular volume field
142         template<class Type>
143         void sampleAndWrite
144         (
145             const GeometricField<Type, fvPatchField, volMesh>&
146         );
148         //- Sample and write all the fields of the given type
149         template <class Type>
150         void sampleAndWrite(const fieldGroup<Type>&);
152         //- Disallow default bitwise copy construct
153         probes(const probes&);
155         //- Disallow default bitwise assignment
156         void operator=(const probes&);
159 public:
161     //- Runtime type information
162     TypeName("probes");
165     // Constructors
167         //- Construct for given objectRegistry and dictionary.
168         //  Allow the possibility to load fields from files
169         probes
170         (
171             const word& name,
172             const objectRegistry&,
173             const dictionary&,
174             const bool loadFromFiles = false
175         );
178     // Destructor
180         virtual ~probes();
183     // Member Functions
185         //- Return name of the set of probes
186         virtual const word& name() const
187         {
188             return name_;
189         }
191         //- Cells to be probed (obtained from the locations)
192         const labelList& cells() const
193         {
194             return cellList_;
195         }
197         //- Sample and write
198         virtual void write();
200         //- Read the probes
201         virtual void read(const dictionary&);
203         //- Execute
204         virtual void execute();
206         //- Update for changes of mesh
207         virtual void updateMesh(const mapPolyMesh&)
208         {}
210         //- Update for changes of mesh
211         virtual void movePoints(const pointField&)
212         {}
214         //- Update for changes of mesh due to readUpdate
215         virtual void readUpdate(const polyMesh::readUpdateState state)
216         {}
218         //- Sample a volume field at all locations
219         template<class Type>
220         tmp<Field<Type> > sample
221         (
222             const GeometricField<Type, fvPatchField, volMesh>&
223         ) const;
225         //- Sample a single field on all sample locations
226         template <class Type>
227         tmp<Field<Type> > sample(const word& fieldName) const;
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 } // End namespace Foam
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 #ifdef NoRepository
238 #   include "probesTemplates.C"
239 #endif
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 #endif
245 // ************************************************************************* //