00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 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 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your 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, see <http://www.gnu.org/licenses/>. 00023 00024 Class 00025 Foam::probes 00026 00027 Description 00028 Set of locations to sample. 00029 00030 Call write() to sample and write files. 00031 00032 SourceFiles 00033 probes.C 00034 00035 \*---------------------------------------------------------------------------*/ 00036 00037 #ifndef probes_H 00038 #define probes_H 00039 00040 #include <OpenFOAM/HashPtrTable.H> 00041 #include <OpenFOAM/OFstream.H> 00042 #include <OpenFOAM/polyMesh.H> 00043 #include <OpenFOAM/pointField.H> 00044 #include <finiteVolume/volFieldsFwd.H> 00045 00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00047 00048 namespace Foam 00049 { 00050 00051 // Forward declaration of classes 00052 class objectRegistry; 00053 class dictionary; 00054 class fvMesh; 00055 class mapPolyMesh; 00056 00057 /*---------------------------------------------------------------------------*\ 00058 Class probes Declaration 00059 \*---------------------------------------------------------------------------*/ 00060 00061 class probes 00062 { 00063 protected: 00064 00065 // Protected classes 00066 00067 //- Class used for grouping field types 00068 template<class Type> 00069 class fieldGroup 00070 : 00071 public wordList 00072 { 00073 public: 00074 //- Construct null 00075 fieldGroup() 00076 : 00077 wordList() 00078 {} 00079 00080 //- Construct for a list of field names 00081 fieldGroup(const wordList& fieldNames) 00082 : 00083 wordList(fieldNames) 00084 {} 00085 }; 00086 00087 00088 // Protected data 00089 00090 //- Name of this set of probes, 00091 // Also used as the name of the probes directory. 00092 word name_; 00093 00094 //- Const reference to objectRegistry 00095 const objectRegistry& obr_; 00096 00097 //- Load fields from files (not from objectRegistry) 00098 bool loadFromFiles_; 00099 00100 00101 // Read from dictonary 00102 00103 //- Names of fields to probe 00104 wordList fieldNames_; 00105 00106 //- Locations to probe 00107 vectorField probeLocations_; 00108 00109 00110 // Calculated 00111 00112 //- Categorized scalar/vector/tensor fields 00113 fieldGroup<scalar> scalarFields_; 00114 fieldGroup<vector> vectorFields_; 00115 fieldGroup<sphericalTensor> sphericalTensorFields_; 00116 fieldGroup<symmTensor> symmTensorFields_; 00117 fieldGroup<tensor> tensorFields_; 00118 00119 // Cells to be probed (obtained from the locations) 00120 labelList elementList_; 00121 00122 //- Current open files 00123 HashPtrTable<OFstream> probeFilePtrs_; 00124 00125 00126 // Private Member Functions 00127 00128 //- Find element containing probes 00129 virtual void findElements(const fvMesh&); 00130 00131 //- classify field types, return true if nFields > 0 00132 bool checkFieldTypes(); 00133 00134 //- Find the fields in the list of the given type, return count 00135 template<class Type> 00136 label countFields 00137 ( 00138 fieldGroup<Type>& fieldList, 00139 const wordList& fieldTypes 00140 ) const; 00141 00142 00143 private: 00144 00145 //- Sample and write a particular volume field 00146 template<class Type> 00147 void sampleAndWrite 00148 ( 00149 const GeometricField<Type, fvPatchField, volMesh>& 00150 ); 00151 00152 //- Sample and write all the fields of the given type 00153 template <class Type> 00154 void sampleAndWrite(const fieldGroup<Type>&); 00155 00156 //- Disallow default bitwise copy construct 00157 probes(const probes&); 00158 00159 //- Disallow default bitwise assignment 00160 void operator=(const probes&); 00161 00162 00163 public: 00164 00165 //- Runtime type information 00166 TypeName("probes"); 00167 00168 00169 // Constructors 00170 00171 //- Construct for given objectRegistry and dictionary. 00172 // Allow the possibility to load fields from files 00173 probes 00174 ( 00175 const word& name, 00176 const objectRegistry&, 00177 const dictionary&, 00178 const bool loadFromFiles = false 00179 ); 00180 00181 00182 //- Destructor 00183 virtual ~probes(); 00184 00185 00186 // Member Functions 00187 00188 //- Return name of the set of probes 00189 virtual const word& name() const 00190 { 00191 return name_; 00192 } 00193 00194 //- Return names of fields to probe 00195 virtual const wordList& fieldNames() const 00196 { 00197 return fieldNames_; 00198 } 00199 00200 //- Return locations to probe 00201 virtual const vectorField& probeLocations() const 00202 { 00203 return probeLocations_; 00204 } 00205 00206 //- Cells to be probed (obtained from the locations) 00207 const labelList& elements() const 00208 { 00209 return elementList_; 00210 } 00211 00212 //- Execute, currently does nothing 00213 virtual void execute(); 00214 00215 //- Execute at the final time-loop, currently does nothing 00216 virtual void end(); 00217 00218 //- Sample and write 00219 virtual void write(); 00220 00221 //- Read the probes 00222 virtual void read(const dictionary&); 00223 00224 //- Update for changes of mesh 00225 virtual void updateMesh(const mapPolyMesh&) 00226 {} 00227 00228 //- Update for changes of mesh 00229 virtual void movePoints(const pointField&) 00230 {} 00231 00232 //- Update for changes of mesh due to readUpdate 00233 virtual void readUpdate(const polyMesh::readUpdateState state) 00234 {} 00235 00236 //- Sample a volume field at all locations 00237 template<class Type> 00238 tmp<Field<Type> > sample 00239 ( 00240 const GeometricField<Type, fvPatchField, volMesh>& 00241 ) const; 00242 00243 //- Sample a single field on all sample locations 00244 template <class Type> 00245 tmp<Field<Type> > sample(const word& fieldName) const; 00246 }; 00247 00248 00249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00250 00251 } // End namespace Foam 00252 00253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00254 00255 #ifdef NoRepository 00256 # include <sampling/probesTemplates.C> 00257 #endif 00258 00259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00260 00261 #endif 00262 00263 // ************************ vim: set sw=4 sts=4 et: ************************ //