1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
26 Foam::fieldValues::cellSource
29 Cell source variant of field value function object. Values of user-
30 specified fields reported for collections of cells.
32 cellObj1 // Name also used to identify output folder
35 functionObjectLibs ("libfieldValueFunctionObjects.so");
37 outputControl outputTime;
38 log true; // log to screen?
39 valueOutput true; // Write values at run-time output times?
40 source cellZone; // Type of cell source
42 operation volAverage; // none, sum, volAverage, volIntegrate
53 \*---------------------------------------------------------------------------*/
58 #include "NamedEnum.H"
59 #include "fieldValue.H"
60 #include "labelList.H"
61 #include "volFieldsFwd.H"
63 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 /*---------------------------------------------------------------------------*\
71 Class cellSource Declaration
72 \*---------------------------------------------------------------------------*/
83 //- Source type enumeration
90 static const NamedEnum<sourceType, 1> sourceTypeNames_;
93 //- Operation type enumeration
102 //- Operation type names
103 static const NamedEnum<operationType, 4> operationTypeNames_;
108 // Private member functions
110 //- Set cells to evaluate based on a cell zone
111 void setCellZoneCells();
113 //- Set cells to evaluate based on a patch
114 void setPatchCells();
124 //- Operation to apply to values
125 operationType operation_;
127 //- Local list of cell IDs
131 // Protected member functions
133 //- Initialise, e.g. cell addressing
136 //- Insert field values into values list
140 const word& fieldName,
144 //- Apply the 'operation' to the values
146 Type processValues(const List<Type>& values) const;
148 //- Output file header information
149 virtual void writeFileHeader();
154 //- Run-time type information
155 TypeName("cellSource");
158 //- Construct from components
162 const objectRegistry& obr,
163 const dictionary& dict,
164 const bool loadFromFiles = false
169 virtual ~cellSource();
172 // Public member functions
176 //- Return the source type
177 inline const sourceType& source() const;
179 //- Return the local list of cell IDs
180 inline const labelList& cellId() const;
183 // Function object functions
185 //- Read from dictionary
186 virtual void read(const dictionary&);
188 //- Calculate and write
189 virtual void write();
191 //- Templated helper function to output field values
193 bool writeValues(const word& fieldName);
195 //- Filter a field according to cellIds
197 tmp<Field<Type> > filterField(const Field<Type>& field) const;
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 } // End namespace fieldValues
204 } // End namespace Foam
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 #include "cellSourceI.H"
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 #include "cellSourceTemplates.C"
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 // ************************************************************************* //