00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2009-2011 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::fieldValues::faceSource 00026 00027 Description 00028 Face source variant of field value function object. Values of user- 00029 specified fields reported for collections of faces. 00030 00031 faceObj1 // Name also used to identify output folder 00032 { 00033 type faceSource; 00034 functionObjectLibs ("libfieldValueFunctionObjects.so"); 00035 enabled true; 00036 outputControl outputTime; 00037 log true; // log to screen? 00038 valueOutput true; // Write values at run-time output times? 00039 source faceZone; // Type of face source: 00040 // faceZone, patch, sampledSurface 00041 sourceName f0; // faceZone or patch, see below 00042 operation sum; 00043 fields 00044 ( 00045 p 00046 phi 00047 U 00048 ); 00049 } 00050 00051 source: 00052 - faceZone : requires a 'sourceName' entry to specify the faceZone 00053 - patch : "" patch 00054 - sampledSurface : requires a 'sampledSurfaceDict' subdictionary. See e.g. 00055 sampleDict. 00056 00057 operation is one of: 00058 - none 00059 - sum 00060 - areaAverage 00061 - areaIntegrate 00062 - weightedAverage 00063 - min 00064 - max 00065 00066 Notes: 00067 - faces on empty patches get ignored 00068 - if the field is a volField the faceZone can only consist of boundary 00069 faces. 00070 - all fields get oriented according to the faceZone (so you might e.g. see 00071 negative pressure) 00072 - using sampledSurfaces: 00073 - they do not do surface fields 00074 - they use cell values - they do not do any interpolation. 00075 - take care when using isoSurfaces - these might have duplicate 00076 triangles so integration might be wrong 00077 00078 SourceFiles 00079 faceSource.C 00080 00081 \*---------------------------------------------------------------------------*/ 00082 00083 #ifndef faceSource_H 00084 #define faceSource_H 00085 00086 #include <OpenFOAM/NamedEnum.H> 00087 #include <fieldFunctionObjects/fieldValue.H> 00088 #include <finiteVolume/surfaceFieldsFwd.H> 00089 #include <finiteVolume/volFieldsFwd.H> 00090 00091 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00092 00093 namespace Foam 00094 { 00095 00096 class sampledSurface; 00097 00098 namespace fieldValues 00099 { 00100 00101 /*---------------------------------------------------------------------------*\ 00102 Class faceSource Declaration 00103 \*---------------------------------------------------------------------------*/ 00104 00105 class faceSource 00106 : 00107 public fieldValue 00108 { 00109 00110 public: 00111 00112 // Public data types 00113 00114 //- Source type enumeration 00115 enum sourceType 00116 { 00117 stFaceZone, 00118 stPatch, 00119 stSampledSurface 00120 }; 00121 00122 //- Source type names 00123 static const NamedEnum<sourceType, 3> sourceTypeNames_; 00124 00125 00126 //- Operation type enumeration 00127 enum operationType 00128 { 00129 opNone, 00130 opSum, 00131 opAreaAverage, 00132 opAreaIntegrate, 00133 opWeightedAverage, 00134 opMin, 00135 opMax 00136 }; 00137 00138 //- Operation type names 00139 static const NamedEnum<operationType, 7> operationTypeNames_; 00140 00141 00142 private: 00143 00144 // Private member functions 00145 00146 //- Set faces to evaluate based on a face zone 00147 void setFaceZoneFaces(); 00148 00149 //- Set faces to evaluate based on a patch 00150 void setPatchFaces(); 00151 00152 //- Set faces according to sampledSurface 00153 void sampledSurfaceFaces(const dictionary&); 00154 00155 00156 protected: 00157 00158 // Protected data 00159 00160 //- Source type 00161 sourceType source_; 00162 00163 //- Operation to apply to values 00164 operationType operation_; 00165 00166 //- Weight field name - only used for opWeightedAverage mode 00167 word weightFieldName_; 00168 00169 //- Global number of faces 00170 label nFaces_; 00171 00172 // If operating on mesh faces (faceZone,patch) 00173 00174 //- Local list of face IDs 00175 labelList faceId_; 00176 00177 //- Local list of patch ID per face 00178 labelList facePatchId_; 00179 00180 //- List of +1/-1 representing face flip map (1 use as is, -1 negate) 00181 labelList faceSign_; 00182 00183 // If operating on sampledSurface 00184 00185 //- underlying sampledSurface 00186 autoPtr<sampledSurface> surfacePtr_; 00187 00188 00189 // Protected member functions 00190 00191 //- Initialise, e.g. face addressing 00192 void initialise(const dictionary& dict); 00193 00194 //- Return true if the field name is valid 00195 template<class Type> 00196 bool validField(const word& fieldName) const; 00197 00198 //- Return field values by looking up field name 00199 template<class Type> 00200 tmp<Field<Type> > setFieldValues(const word& fieldName) const; 00201 00202 //- Apply the 'operation' to the values 00203 template<class Type> 00204 Type processValues 00205 ( 00206 const Field<Type>& values, 00207 const scalarField& magSf, 00208 const scalarField& weightField 00209 ) const; 00210 00211 //- Output file header information 00212 virtual void writeFileHeader(); 00213 00214 00215 public: 00216 00217 //- Run-time type information 00218 TypeName("faceSource"); 00219 00220 00221 //- Construct from components 00222 faceSource 00223 ( 00224 const word& name, 00225 const objectRegistry& obr, 00226 const dictionary& dict, 00227 const bool loadFromFiles = false 00228 ); 00229 00230 00231 //- Destructor 00232 virtual ~faceSource(); 00233 00234 00235 // Public member functions 00236 00237 // Access 00238 00239 //- Return the source type 00240 inline const sourceType& source() const; 00241 00242 //- Return the local list of face IDs 00243 inline const labelList& faceId() const; 00244 00245 //- Return the local list of patch ID per face 00246 inline const labelList& facePatch() const; 00247 00248 //- Return the list of +1/-1 representing face flip map 00249 inline const labelList& faceSign() const; 00250 00251 00252 // Function object functions 00253 00254 //- Read from dictionary 00255 virtual void read(const dictionary&); 00256 00257 //- Calculate and write 00258 virtual void write(); 00259 00260 //- Templated helper function to output field values 00261 template<class Type> 00262 bool writeValues(const word& fieldName); 00263 00264 //- Filter a surface field according to faceIds 00265 template<class Type> 00266 tmp<Field<Type> > filterField 00267 ( 00268 const GeometricField<Type, fvsPatchField, surfaceMesh>& field, 00269 const bool applyOrientation 00270 ) const; 00271 00272 //- Filter a volume field according to faceIds 00273 template<class Type> 00274 tmp<Field<Type> > filterField 00275 ( 00276 const GeometricField<Type, fvPatchField, volMesh>& field, 00277 const bool applyOrientation 00278 ) const; 00279 }; 00280 00281 00282 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00283 00284 } // End namespace fieldValues 00285 } // End namespace Foam 00286 00287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00288 00289 #include "faceSourceI.H" 00290 00291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00292 00293 #ifdef NoRepository 00294 #include "faceSourceTemplates.C" 00295 #endif 00296 00297 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00298 00299 #endif 00300 00301 // ************************ vim: set sw=4 sts=4 et: ************************ //