zeroGradient.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) 2016-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::zeroGradient
28 
29 Group
30  grpFieldFunctionObjects
31 
32 Description
33  Creates a volume field with zero-gradient
34  boundary conditions from another volume field.
35 
36  The result can be used, for example, to post-process near-wall
37  field values.
38 
39  Operands:
40  \table
41  Operand | Type | Location
42  input | vol<Type>Field | $FOAM_CASE/<time>/<inpField>
43  output file | - | -
44  output field | vol<Type>Field | $FOAM_CASE/<time>/<outField>
45  \endtable
46 
47  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
48 
49 Usage
50  Minimal example by using \c system/controlDict.functions:
51  \verbatim
52  zeroGradient1
53  {
54  // Mandatory entries (unmodifiable)
55  type zeroGradient;
56  libs (fieldFunctionObjects);
57 
58  // Mandatory entries (runtime modifiable)
59  fields (<field1> ... <fieldN>); \\(U "(T|k|epsilon|omega)");
60 
61  // Optional entries (runtime modifiable)
62  result @@<name>;
63 
64  // Optional (inherited) entries
65  ...
66  }
67  \endverbatim
68 
69  where the entries mean:
70  \table
71  Property | Description | Type | Req'd | Dflt
72  type | Type name: zeroGradient | word | yes | -
73  libs | Library name: fieldFunctionObjects | word | yes | -
74  fields | Name of the operand fields | wordList | yes | -
75  result | Name of the output field | word | no | zeroGradient(@@)
76  \endtable
77 
78  The inherited entries are elaborated in:
79  - \link functionObject.H \endlink
80 
81  Usage by the \c postProcess utility is not available.
82 
83 Note
84  - A list of fields can contain exact names or regular expressions.
85  The token '\@\@' in the result name is replaced by the name of the source
86  field. In the special case of a single source field (specified as
87  a non-regex), the '\@\@' token checking is suppressed.
88  - The function object will skip over fields that would not benefit
89  i.e., only processor, empty, zeroGradient, symmetry patches.
90  This check should also prevent processing fields multiple times.
91 
92 See also
93  - Foam::functionObject
94  - Foam::functionObjects::fvMeshFunctionObject
95  - ExtendedCodeGuide::functionObjects::field::zeroGradient
96 
97 SourceFiles
98  zeroGradient.C
99  zeroGradientTemplates.C
100 
101 \*---------------------------------------------------------------------------*/
102 
103 #ifndef functionObjects_zeroGradient_H
104 #define functionObjects_zeroGradient_H
105 
106 #include "fvMeshFunctionObject.H"
107 #include "volFieldsFwd.H"
108 #include "OFstream.H"
109 #include "wordRes.H"
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 namespace Foam
114 {
115 namespace functionObjects
116 {
117 
118 /*---------------------------------------------------------------------------*\
119  Class zeroGradient Declaration
120 \*---------------------------------------------------------------------------*/
121 
122 class zeroGradient
123 :
124  public fvMeshFunctionObject
125 {
126  // Private Data
127 
128  //- Name of fields to process
129  wordRes selectFields_;
130 
131  //- Formatting for the result fields
132  word resultName_;
133 
134  //- Hashed names of result fields, and their type
135  HashTable<word> results_;
136 
137 
138  // Private Member Functions
139 
140  //- Accept unless field only has constraint patches
141  // (ie, empty/zero-gradient/processor)
142  // This should also avoid fields that were already processed by
143  // zeroGradient.
144  template<class Type>
145  static bool accept(const GeometricField<Type, fvPatchField, volMesh>&);
146 
147  //- Apply for the volume field type
148  template<class Type>
149  int apply(const word& inputName, int& state);
150 
151  //- Process by trying to apply for various volume field types
152  int process(const word& inputName);
153 
154 
155 public:
156 
157  //- Runtime type information
158  TypeName("zeroGradient");
159 
160 
161  // Constructors
162 
163  //- Construct from Time and dictionary
165  (
166  const word& name,
167  const Time& runTime,
168  const dictionary& dict
169  );
170 
171  //- No copy construct
172  zeroGradient(const zeroGradient&) = delete;
173 
174  //- No copy assignment
175  void operator=(const zeroGradient&) = delete;
176 
177 
178  //- Destructor
179  virtual ~zeroGradient() = default;
180 
181 
182  // Member Functions
183 
184  //- Read the zeroGradient specification
185  virtual bool read(const dictionary& dict);
186 
187  //- Calculate the zeroGradient fields
188  virtual bool execute();
189 
190  //- Write the zeroGradient fields
191  virtual bool write();
192 };
193 
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace functionObjects
198 } // End namespace Foam
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #ifdef NoRepository
203  #include "zeroGradientTemplates.C"
204 #endif
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 #endif
209 
210 // ************************************************************************* //
dictionary dict
Forwards and collection of common volume field types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
engineTime & runTime
void operator=(const zeroGradient &)=delete
No copy assignment.
virtual bool execute()
Calculate the zeroGradient fields.
Definition: zeroGradient.C:126
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
const word & name() const noexcept
Return the name of this functionObject.
zeroGradient(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: zeroGradient.C:88
A class for handling words, derived from Foam::string.
Definition: word.H:63
TypeName("zeroGradient")
Runtime type information.
virtual bool write()
Write the zeroGradient fields.
Definition: zeroGradient.C:173
virtual bool read(const dictionary &dict)
Read the zeroGradient specification.
Definition: zeroGradient.C:105
Creates a volume field with zero-gradient boundary conditions from another volume field...
Definition: zeroGradient.H:163
virtual ~zeroGradient()=default
Destructor.
Namespace for OpenFOAM.