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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::functionObjects::zeroGradient
28
29Group
30 grpFieldFunctionObjects
31
32Description
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
49Usage
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
83Note
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
92See also
93 - Foam::functionObject
94 - Foam::functionObjects::fvMeshFunctionObject
95 - ExtendedCodeGuide::functionObjects::field::zeroGradient
96
97SourceFiles
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
113namespace Foam
114{
115namespace functionObjects
116{
117
118/*---------------------------------------------------------------------------*\
119 Class zeroGradient Declaration
120\*---------------------------------------------------------------------------*/
121
122class 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 //- Check that string contains the appropriate substitution token(s)
141 static bool checkFormatName(const std::string& str);
142
143
144 //- Accept unless field only has constraint patches
145 // (ie, empty/zero-gradient/processor)
146 // This should also avoid fields that were already processed by
147 // zeroGradient.
148 template<class Type>
149 static bool accept(const GeometricField<Type, fvPatchField, volMesh>&);
150
151 //- Apply for the volume field type
152 template<class Type>
153 int apply(const word& inputName, int& state);
154
155 //- Process by trying to apply for various volume field types
156 int process(const word& inputName);
157
158
159public:
160
161 //- Runtime type information
162 TypeName("zeroGradient");
163
164
165 // Constructors
166
167 //- Construct from Time and dictionary
169 (
170 const word& name,
171 const Time& runTime,
172 const dictionary& dict
173 );
174
175 //- No copy construct
176 zeroGradient(const zeroGradient&) = delete;
177
178 //- No copy assignment
179 void operator=(const zeroGradient&) = delete;
180
181
182 //- Destructor
183 virtual ~zeroGradient() = default;
184
185
186 // Member Functions
187
188 //- Read the zeroGradient specification
189 virtual bool read(const dictionary& dict);
190
191 //- Calculate the zeroGradient fields
192 virtual bool execute();
193
194 //- Write the zeroGradient fields
195 virtual bool write();
196};
197
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace functionObjects
202} // End namespace Foam
203
204// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
205
206#ifdef NoRepository
208#endif
209
210// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212#endif
213
214// ************************************************************************* //
Generic GeometricField class.
A HashTable similar to std::unordered_map.
Definition: HashTable.H:123
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const word & name() const noexcept
Return the name of this functionObject.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Creates a volume field with zero-gradient boundary conditions from another volume field.
Definition: zeroGradient.H:170
virtual ~zeroGradient()=default
Destructor.
TypeName("zeroGradient")
Runtime type information.
zeroGradient(const zeroGradient &)=delete
No copy construct.
virtual bool read(const dictionary &dict)
Read the zeroGradient specification.
Definition: zeroGradient.C:107
void operator=(const zeroGradient &)=delete
No copy assignment.
virtual bool execute()
Calculate the zeroGradient fields.
Definition: zeroGradient.C:128
virtual bool write()
Write the zeroGradient fields.
Definition: zeroGradient.C:174
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
engineTime & runTime
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73