1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 Foam::fieldValues::cellSource
28 Cell source variant of field value function object. Values of user-
29 specified fields reported for collections of cells.
31 cellObj1 // Name also used to identify output folder
34 functionObjectLibs ("libfieldValueFunctionObjects.so");
36 outputControl outputTime;
37 log true; // log to screen?
38 valueOutput true; // Write values at run-time output times?
39 source cellZone; // Type of cell source
49 where operation is one of:
59 \*---------------------------------------------------------------------------*/
64 #include "NamedEnum.H"
65 #include "fieldValue.H"
66 #include "labelList.H"
67 #include "volFieldsFwd.H"
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 /*---------------------------------------------------------------------------*\
77 Class cellSource Declaration
78 \*---------------------------------------------------------------------------*/
89 //- Source type enumeration
97 static const NamedEnum<sourceType, 2> sourceTypeNames_;
100 //- Operation type enumeration
112 //- Operation type names
113 static const NamedEnum<operationType, 7> operationTypeNames_;
118 // Private Member Functions
120 //- Set cells to evaluate based on a cell zone
121 void setCellZoneCells();
123 //- Set cells to evaluate based on a patch
124 void setPatchCells();
134 //- Operation to apply to values
135 operationType operation_;
137 //- Global number of cells
140 //- Local list of cell IDs
143 //- Weight field name - only used for opWeightedAverage mode
144 word weightFieldName_;
147 // Protected Member Functions
149 //- Initialise, e.g. cell addressing
150 void initialise(const dictionary& dict);
152 //- Return true if the field name is valid
154 bool validField(const word& fieldName) const;
156 //- Insert field values into values list
158 tmp<Field<Type> > setFieldValues
160 const word& fieldName
163 //- Apply the 'operation' to the values
167 const Field<Type>& values,
168 const scalarField& V,
169 const scalarField& weightField
172 //- Output file header information
173 virtual void writeFileHeader();
178 //- Run-time type information
179 TypeName("cellSource");
182 //- Construct from components
186 const objectRegistry& obr,
187 const dictionary& dict,
188 const bool loadFromFiles = false
193 virtual ~cellSource();
196 // Public Member Functions
200 //- Return the source type
201 inline const sourceType& source() const;
203 //- Return the local list of cell IDs
204 inline const labelList& cellId() const;
207 // Function object functions
209 //- Read from dictionary
210 virtual void read(const dictionary&);
212 //- Calculate and write
213 virtual void write();
215 //- Templated helper function to output field values
217 bool writeValues(const word& fieldName);
219 //- Filter a field according to cellIds
221 tmp<Field<Type> > filterField(const Field<Type>& field) const;
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 } // End namespace fieldValues
228 } // End namespace Foam
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 #include "cellSourceI.H"
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 #include "cellSourceTemplates.C"
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 // ************************************************************************* //