OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

probes.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::probes
00027 
00028 Description
00029     Set of locations to sample.
00030 
00031     Call write() to sample and write files.
00032 
00033 SourceFiles
00034     probes.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef probes_H
00039 #define probes_H
00040 
00041 #include "HashPtrTable.H"
00042 #include "OFstream.H"
00043 #include "polyMesh.H"
00044 #include "pointField.H"
00045 #include "volFieldsFwd.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // Forward declaration of classes
00053 class objectRegistry;
00054 class dictionary;
00055 class fvMesh;
00056 class mapPolyMesh;
00057 
00058 /*---------------------------------------------------------------------------*\
00059                           Class probes Declaration
00060 \*---------------------------------------------------------------------------*/
00061 
00062 class probes
00063 {
00064     // Private classes
00065 
00066         //- Class used for grouping field types
00067         template<class Type>
00068         class fieldGroup
00069         :
00070             public wordList
00071         {
00072         public:
00073             //- Construct null
00074             fieldGroup()
00075             :
00076                 wordList()
00077             {}
00078 
00079             //- Construct for a list of field names
00080             fieldGroup(const wordList& fieldNames)
00081             :
00082                 wordList(fieldNames)
00083             {}
00084         };
00085 
00086 
00087     // Private data
00088 
00089         //- Name of this set of probes,
00090         //  Also used as the name of the probes directory.
00091         word name_;
00092 
00093         //- Const reference to objectRegistry
00094         const objectRegistry& obr_;
00095 
00096         //- Load fields from files (not from objectRegistry)
00097         bool loadFromFiles_;
00098 
00099 
00100         // Read from dictonary
00101 
00102             //- Names of fields to probe
00103             wordList fieldNames_;
00104 
00105             //- Locations to probe
00106             vectorField probeLocations_;
00107 
00108 
00109         // Calculated
00110 
00111             //- Categorized scalar/vector/tensor fields
00112             fieldGroup<scalar> scalarFields_;
00113             fieldGroup<vector> vectorFields_;
00114             fieldGroup<sphericalTensor> sphericalTensorFields_;
00115             fieldGroup<symmTensor> symmTensorFields_;
00116             fieldGroup<tensor> tensorFields_;
00117 
00118             // Cells to be probed (obtained from the locations)
00119             labelList cellList_;
00120 
00121             //- Current open files
00122             HashPtrTable<OFstream> probeFilePtrs_;
00123 
00124 
00125     // Private Member Functions
00126 
00127         //- Find cells containing probes
00128         void findCells(const fvMesh&);
00129 
00130         //- classify field types, return true if nFields > 0
00131         bool checkFieldTypes();
00132 
00133         //- Find the fields in the list of the given type, return count
00134         template<class Type>
00135         label countFields
00136         (
00137             fieldGroup<Type>& fieldList,
00138             const wordList& fieldTypes
00139         ) const;
00140 
00141         //- Sample and write a particular volume field
00142         template<class Type>
00143         void sampleAndWrite
00144         (
00145             const GeometricField<Type, fvPatchField, volMesh>&
00146         );
00147 
00148         //- Sample and write all the fields of the given type
00149         template <class Type>
00150         void sampleAndWrite(const fieldGroup<Type>&);
00151 
00152         //- Disallow default bitwise copy construct
00153         probes(const probes&);
00154 
00155         //- Disallow default bitwise assignment
00156         void operator=(const probes&);
00157 
00158 
00159 public:
00160 
00161     //- Runtime type information
00162     TypeName("probes");
00163 
00164 
00165     // Constructors
00166 
00167         //- Construct for given objectRegistry and dictionary.
00168         //  Allow the possibility to load fields from files
00169         probes
00170         (
00171             const word& name,
00172             const objectRegistry&,
00173             const dictionary&,
00174             const bool loadFromFiles = false
00175         );
00176 
00177 
00178     //- Destructor
00179     virtual ~probes();
00180 
00181 
00182     // Member Functions
00183 
00184         //- Return name of the set of probes
00185         virtual const word& name() const
00186         {
00187             return name_;
00188         }
00189 
00190         //- Return names of fields to probe
00191         virtual const wordList& fieldNames() const
00192         {
00193             return fieldNames_;
00194         }
00195 
00196         //- Return locations to probe
00197         virtual const vectorField& probeLocations() const
00198         {
00199             return probeLocations_;
00200         }
00201 
00202         //- Cells to be probed (obtained from the locations)
00203         const labelList& cells() const
00204         {
00205             return cellList_;
00206         }
00207 
00208         //- Execute, currently does nothing
00209         virtual void execute();
00210 
00211         //- Execute at the final time-loop, currently does nothing
00212         virtual void end();
00213 
00214         //- Sample and write
00215         virtual void write();
00216 
00217         //- Read the probes
00218         virtual void read(const dictionary&);
00219 
00220         //- Update for changes of mesh
00221         virtual void updateMesh(const mapPolyMesh&)
00222         {}
00223 
00224         //- Update for changes of mesh
00225         virtual void movePoints(const pointField&)
00226         {}
00227 
00228         //- Update for changes of mesh due to readUpdate
00229         virtual void readUpdate(const polyMesh::readUpdateState state)
00230         {}
00231 
00232         //- Sample a volume field at all locations
00233         template<class Type>
00234         tmp<Field<Type> > sample
00235         (
00236             const GeometricField<Type, fvPatchField, volMesh>&
00237         ) const;
00238 
00239         //- Sample a single field on all sample locations
00240         template <class Type>
00241         tmp<Field<Type> > sample(const word& fieldName) const;
00242 };
00243 
00244 
00245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00246 
00247 } // End namespace Foam
00248 
00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00250 
00251 #ifdef NoRepository
00252 #   include "probesTemplates.C"
00253 #endif
00254 
00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00256 
00257 #endif
00258 
00259 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd