Added new fieldValues function object
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / field / fieldValues / faceSource / faceSource.H
blobe8e2634b12855625003e8d27454aa16ccd0a836d
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::fieldValues::faceSource
28 Description
29     Face source variant of field value function object. Values of user-
30     specified fields reported for collections of faces.
32     cellObj1                        // Name also used to identify output folder
33     {
34         type            cellSource;
35         functionObjectLibs ("libfieldValueFunctionObjects.so");
36         enabled         true;
37         outputControl   outputTime;
38         log             true;       // log to screen?
39         valueOutput     true;       // Write values at run-time output times?
40         source          faceZone;   // Type of face source: faceZone, patch
41         sourceName      f0;
42         operation       sum;
43         fields
44         (
45             p
46             phi
47             U
48         );
49     }
51     where operation is one of:
52       - none
53       - sum
54       - areaAverage
55       - areaIntegrate
56       - weightedAverage
58 SourceFiles
59     faceSource.C
61 \*---------------------------------------------------------------------------*/
63 #ifndef faceSource_H
64 #define faceSource_H
66 #include "NamedEnum.H"
67 #include "fieldValue.H"
68 #include "labelList.H"
69 #include "surfaceFieldsFwd.H"
70 #include "volFieldsFwd.H"
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 namespace Foam
76 namespace fieldValues
79 /*---------------------------------------------------------------------------*\
80                          Class faceSource Declaration
81 \*---------------------------------------------------------------------------*/
83 class faceSource
85     public fieldValue
88 public:
90     // Public data types
92         //- Source type enumeration
93         enum sourceType
94         {
95             stFaceZone,
96             stPatch
97         };
99         //- Source type names
100         static const NamedEnum<sourceType, 2> sourceTypeNames_;
103         //- Operation type enumeration
104         enum operationType
105         {
106             opNone,
107             opSum,
108             opAreaAverage,
109             opAreaIntegrate,
110             opWeightedAverage
111         };
113         //- Operation type names
114         static const NamedEnum<operationType, 5> operationTypeNames_;
117 private:
119     // Private member functions
121         //- Set faces to evaluate based on a face zone
122         void setFaceZoneFaces();
124         //- Set faces to evaluate based on a patch
125         void setPatchFaces();
128 protected:
130     // Protected data
132         //- Source type
133         sourceType source_;
135         //- Operation to apply to values
136         operationType operation_;
138         //- Local list of face IDs
139         labelList faceId_;
141         //- Local list of patch ID per face
142         labelList facePatchId_;
144         //- List of +1/-1 representing face flip map
145         labelList flipMap_;
147         //- Weight field name - only used for opWeightedAverage mode
148         word weightFieldName_;
151     // Protected member functions
153         //- Initialise, e.g. face addressing
154         void initialise(const dictionary& dict);
156         //- Insert field values into values list
157         template<class Type>
158         bool setFieldValues
159         (
160             const word& fieldName,
161             List<Type>& values
162         ) const;
164         //- Apply the 'operation' to the values
165         template<class Type>
166         Type processValues(const List<Type>& values) const;
168         //- Output file header information
169         virtual void writeFileHeader();
172 public:
174     //- Run-time type information
175     TypeName("faceSource");
178     //- Construct from components
179     faceSource
180     (
181         const word& name,
182         const objectRegistry& obr,
183         const dictionary& dict,
184         const bool loadFromFiles = false
185     );
188     //- Destructor
189     virtual ~faceSource();
192     // Public member functions
194         // Access
196             //- Return the source type
197             inline const sourceType& source() const;
199             //- Return the local list of face IDs
200             inline const labelList& faceId() const;
202             //- Return the local list of patch ID per face
203             inline const labelList& facePatch() const;
205             //- Return the list of +1/-1 representing face flip map
206             inline const labelList& flipMap() const;
209         // Function object functions
211             //- Read from dictionary
212             virtual void read(const dictionary&);
214             //- Calculate and write
215             virtual void write();
217             //- Templated helper function to output field values
218             template<class Type>
219             bool writeValues(const word& fieldName);
221             //- Filter a surface field according to faceIds
222             template<class Type>
223             tmp<Field<Type> > filterField
224             (
225                 const GeometricField<Type, fvsPatchField, surfaceMesh>& field
226             ) const;
228             //- Filter a volume field according to faceIds
229             template<class Type>
230             tmp<Field<Type> > filterField
231             (
232                 const GeometricField<Type, fvPatchField, volMesh>& field
233             ) const;
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 } // End namespace fieldValues
240 } // End namespace Foam
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 #include "faceSourceI.H"
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 #ifdef NoRepository
249     #include "faceSourceTemplates.C"
250 #endif
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
254 #endif
256 // ************************************************************************* //