columnAverage.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::functionObjects::columnAverage
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Computes the arithmetic average of given quantities along columns of cells
34  in a given direction for structured-like layered meshes. It is, for example,
35  useful for channel-like cases where spanwise average of a field is desired.
36  However, the \c columnAverage function object does not operate on arbitrary
37  unstructured meshes.
38 
39  For each patch face, calculates the average value of all cells attached in
40  the patch face normal direction, and then pushes the average value back
41  to all cells in the column.
42 
43  Operands:
44  \table
45  Operand | Type | Location
46  input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
47  output file | - | -
48  output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
49  \endtable
50 
51  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
52 
53 Usage
54  Minimal example by using \c system/controlDict.functions:
55  \verbatim
56  columnAverage1
57  {
58  // Mandatory entries (unmodifiable)
59  type columnAverage;
60  libs (fieldFunctionObjects);
61 
62  // Mandatory entries (runtime modifiable)
63  patches (<patch1> <patch2> ... <patchN>);
64  fields (<field1> <field2> ... <fieldN>);
65 
66  // Optional (inherited) entries
67  ...
68  }
69  \endverbatim
70 
71  where the entries mean:
72  \table
73  Property | Description | Type | Req'd | Dflt
74  type | Type name: columnAverage | word | yes | -
75  libs | Library name: fieldFunctionObjects | word | yes | -
76  patches | Names of patches to collapse onto | word | yes | -
77  fields | Names of the operand fields | word | yes | -
78  \endtable
79 
80  The inherited entries are elaborated in:
81  - \link functionObject.H \endlink
82 
83  Usage by the \c postProcess utility is not available.
84 
85 See also
86  - Foam::functionObject
87  - Foam::functionObjects::fvMeshFunctionObject
88  - ExtendedCodeGuide::functionObjects::field::columnAverage
89 
90 SourceFiles
91  columnAverage.C
92  columnAverageTemplates.C
93 
94 \*---------------------------------------------------------------------------*/
95 
96 #ifndef functionObjects_columnAverage_H
97 #define functionObjects_columnAverage_H
98 
99 #include "volFieldsFwd.H"
100 #include "fvMeshFunctionObject.H"
101 #include "volFieldSelection.H"
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 namespace Foam
106 {
107 
108 class globalIndex;
109 class meshStructure;
110 
111 namespace functionObjects
112 {
113 
114 /*---------------------------------------------------------------------------*\
115  Class columnAverage Declaration
116 \*---------------------------------------------------------------------------*/
117 
118 class columnAverage
119 :
120  public fvMeshFunctionObject
121 {
122  // Private Data
123 
124  //- Patches on which to collapse the fields (in sorted order)
125  labelList patchIDs_;
126 
127  //- Fields to collapse
128  volFieldSelection fieldSet_;
129 
130  mutable autoPtr<globalIndex> globalFaces_;
131  mutable autoPtr<globalIndex> globalEdges_;
132  mutable autoPtr<globalIndex> globalPoints_;
133  mutable autoPtr<meshStructure> meshStructurePtr_;
134 
135 
136  // Private Member Functions
137 
138  //- Create the column average field name
139  const word averageName(const word& fieldName) const;
140 
141  //- Return the column-based addressing
142  const meshStructure& meshAddressing(const polyMesh&) const;
143 
144  //- Calculate the averaged field and return true if successful
145  template<class Type>
146  bool columnAverageField(const word& fieldName);
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("columnAverage");
153 
154 
155  // Constructors
156 
157  //- Construct from Time and dictionary
159  (
160  const word& name,
161  const Time& runTime,
162  const dictionary& dict
163  );
164 
165  //- No copy construct
166  columnAverage(const columnAverage&) = delete;
167 
168  //- No copy assignment
169  void operator=(const columnAverage&) = delete;
170 
171 
172  //- Destructor
173  virtual ~columnAverage() = default;
174 
175 
176  // Member Functions
177 
178  //- Read the settings
179  virtual bool read(const dictionary& dict);
180 
181  //- Execute, currently does nothing
182  virtual bool execute();
183 
184  //- Write the results
185  virtual bool write();
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace functionObjects
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #ifdef NoRepository
197  #include "columnAverageTemplates.C"
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
runTime
engineTime & runTime
Definition: createEngineTime.H:13
volFieldsFwd.H
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
columnAverageTemplates.C
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::functionObjects::columnAverage
Computes the arithmetic average of given quantities along columns of cells in a given direction for s...
Definition: columnAverage.H:163
Foam::functionObjects::volFieldSelection
Helper class to manage solver field selections.
Definition: volFieldSelection.H:52
Foam::functionObjects::columnAverage::write
virtual bool write()
Write the results.
Definition: columnAverage.C:173
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::columnAverage::TypeName
TypeName("columnAverage")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
volFieldSelection.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::meshStructure
Detect extruded mesh structure given a set of faces (uindirectPrimitivePatch).
Definition: meshStructure.H:61
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::columnAverage::operator=
void operator=(const columnAverage &)=delete
No copy assignment.
Foam::List< label >
Foam::functionObjects::columnAverage::~columnAverage
virtual ~columnAverage()=default
Destructor.
Foam::functionObjects::columnAverage::read
virtual bool read(const dictionary &dict)
Read the settings.
Definition: columnAverage.C:139
Foam::functionObjects::columnAverage::execute
virtual bool execute()
Execute, currently does nothing.
Definition: columnAverage.C:155
Foam::functionObjects::columnAverage::columnAverage
columnAverage(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: columnAverage.C:123