00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 2009-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::fieldValues::cellSource 00026 00027 Description 00028 Cell source variant of field value function object. Values of user- 00029 specified fields reported for collections of cells. 00030 00031 cellObj1 // Name also used to identify output folder 00032 { 00033 type cellSource; 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 cellZone; // Type of cell source 00040 sourceName c0; 00041 operation volAverage; 00042 fields 00043 ( 00044 p 00045 U 00046 ); 00047 } 00048 00049 where operation is one of: 00050 - none 00051 - sum 00052 - volAverage 00053 - volIntegrate 00054 - weightedAverage 00055 00056 SourceFiles 00057 cellSource.C 00058 00059 \*---------------------------------------------------------------------------*/ 00060 00061 #ifndef cellSource_H 00062 #define cellSource_H 00063 00064 #include <OpenFOAM/NamedEnum.H> 00065 #include <fieldFunctionObjects/fieldValue.H> 00066 #include <OpenFOAM/labelList.H> 00067 #include <finiteVolume/volFieldsFwd.H> 00068 00069 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00070 00071 namespace Foam 00072 { 00073 namespace fieldValues 00074 { 00075 00076 /*---------------------------------------------------------------------------*\ 00077 Class cellSource Declaration 00078 \*---------------------------------------------------------------------------*/ 00079 00080 class cellSource 00081 : 00082 public fieldValue 00083 { 00084 00085 public: 00086 00087 // Public data types 00088 00089 //- Source type enumeration 00090 enum sourceType 00091 { 00092 stCellZone, 00093 stAll 00094 }; 00095 00096 //- Source type names 00097 static const NamedEnum<sourceType, 2> sourceTypeNames_; 00098 00099 00100 //- Operation type enumeration 00101 enum operationType 00102 { 00103 opNone, 00104 opSum, 00105 opVolAverage, 00106 opVolIntegrate, 00107 opWeightedAverage, 00108 opMin, 00109 opMax 00110 }; 00111 00112 //- Operation type names 00113 static const NamedEnum<operationType, 7> operationTypeNames_; 00114 00115 00116 private: 00117 00118 // Private member functions 00119 00120 //- Set cells to evaluate based on a cell zone 00121 void setCellZoneCells(); 00122 00123 //- Set cells to evaluate based on a patch 00124 void setPatchCells(); 00125 00126 00127 protected: 00128 00129 // Protected data 00130 00131 //- Source type 00132 sourceType source_; 00133 00134 //- Operation to apply to values 00135 operationType operation_; 00136 00137 //- Global number of cells 00138 label nCells_; 00139 00140 //- Local list of cell IDs 00141 labelList cellId_; 00142 00143 //- Weight field name - only used for opWeightedAverage mode 00144 word weightFieldName_; 00145 00146 00147 // Protected member functions 00148 00149 //- Initialise, e.g. cell addressing 00150 void initialise(const dictionary& dict); 00151 00152 //- Return true if the field name is valid 00153 template<class Type> 00154 bool validField(const word& fieldName) const; 00155 00156 //- Insert field values into values list 00157 template<class Type> 00158 tmp<Field<Type> > setFieldValues 00159 ( 00160 const word& fieldName 00161 ) const; 00162 00163 //- Apply the 'operation' to the values 00164 template<class Type> 00165 Type processValues 00166 ( 00167 const Field<Type>& values, 00168 const scalarField& V, 00169 const scalarField& weightField 00170 ) const; 00171 00172 //- Output file header information 00173 virtual void writeFileHeader(); 00174 00175 00176 public: 00177 00178 //- Run-time type information 00179 TypeName("cellSource"); 00180 00181 00182 //- Construct from components 00183 cellSource 00184 ( 00185 const word& name, 00186 const objectRegistry& obr, 00187 const dictionary& dict, 00188 const bool loadFromFiles = false 00189 ); 00190 00191 00192 //- Destructor 00193 virtual ~cellSource(); 00194 00195 00196 // Public member functions 00197 00198 // Access 00199 00200 //- Return the source type 00201 inline const sourceType& source() const; 00202 00203 //- Return the local list of cell IDs 00204 inline const labelList& cellId() const; 00205 00206 00207 // Function object functions 00208 00209 //- Read from dictionary 00210 virtual void read(const dictionary&); 00211 00212 //- Calculate and write 00213 virtual void write(); 00214 00215 //- Templated helper function to output field values 00216 template<class Type> 00217 bool writeValues(const word& fieldName); 00218 00219 //- Filter a field according to cellIds 00220 template<class Type> 00221 tmp<Field<Type> > filterField(const Field<Type>& field) const; 00222 }; 00223 00224 00225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00226 00227 } // End namespace fieldValues 00228 } // End namespace Foam 00229 00230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00231 00232 #include "cellSourceI.H" 00233 00234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00235 00236 #ifdef NoRepository 00237 #include "cellSourceTemplates.C" 00238 #endif 00239 00240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00241 00242 #endif 00243 00244 // ************************ vim: set sw=4 sts=4 et: ************************ //